Fossil SCM

wikiedit: the attachment area now explains that new pages cannot have attachments until the page is saved once.

stephan 2021-07-17 10:48 wikiedit-attachment-list
Commit 70716bbc0e5f1cce1370aa81166ccd7b6ae9c33df9b05c2e5a7e4835f35508b4
1 file changed +14 -7
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -527,11 +527,11 @@
527527
else if(0===name.indexOf('branch/')) wtype = 'branch';
528528
else if(0===name.indexOf('tag/')) wtype = 'tag';
529529
/* ^^^ note that we're not validating that, e.g., checkin/XYZ
530530
has a full artifact ID after "checkin/". */
531531
const winfo = {
532
- name: name, type: wtype, mimetype: 'text/x-fossil-wiki',
532
+ name: name, type: wtype, mimetype: 'text/x-markdown',
533533
version: null, parent: null
534534
};
535535
this.cache.pageList.push(
536536
winfo/*keeps entry from getting lost from the list on save*/
537537
);
@@ -1137,13 +1137,18 @@
11371137
}
11381138
D.clearElement(f.eAttach);
11391139
const wi = this.winfo;
11401140
if(!wi){
11411141
D.append(f.eAttach,"No page loaded.");
1142
- return;
1142
+ return this;
11431143
}
1144
-
1144
+ else if(!wi.version){
1145
+ D.append(f.eAttach,
1146
+ "Page ["+wi.name+"] cannot have ",
1147
+ "attachments until it is saved once.");
1148
+ return this;
1149
+ }
11451150
const btnReload = D.button("Reload list");
11461151
const self = this;
11471152
btnReload.addEventListener('click', function(){
11481153
const isStashed = $stash.hasStashedContent(wi);
11491154
F.fetch('wikiajax/attachments',{
@@ -1164,11 +1169,11 @@
11641169
D.a(F.repoUrl('attachadd',{
11651170
page: wi.name,
11661171
from: F.repoUrl('wikiedit',{name: wi.name})}),
11671172
"Add attachments..." )
11681173
);
1169
- return;
1174
+ return this;
11701175
}
11711176
D.append(
11721177
f.eAttach,
11731178
D.append(D.p(),
11741179
btnReload," ",
@@ -1213,10 +1218,11 @@
12131218
const li = D.li(ul);
12141219
D.append(li, urlCopy, " ", imgUrl);
12151220
F.copyButton(urlCopy, {copyFromElement: imgUrl});
12161221
});
12171222
});
1223
+ return this;
12181224
};
12191225
12201226
/** Updates the in-tab title/edit status information */
12211227
P.updateEditStatus = function f(){
12221228
if(!f.eLinks){
@@ -1226,23 +1232,24 @@
12261232
const wi = this.winfo;
12271233
D.clearElement(f.eName, f.eLinks);
12281234
if(!wi){
12291235
D.append(f.eName, '(no page loaded)');
12301236
this.updateAttachmentsView();
1231
- return;
1237
+ return this;
12321238
}
12331239
D.append(f.eName,getEditMarker(wi, false),wi.name);
1234
- if(!wi.version) return;
1240
+ this.updateAttachmentsView();
1241
+ if(!wi.version) return this;
12351242
D.append(
12361243
f.eLinks,
12371244
D.a(F.repoUrl('wiki',{name:wi.name}),"viewer"),
12381245
D.a(F.repoUrl('whistory',{name:wi.name}),'history'),
12391246
D.a(F.repoUrl('attachlist',{page:wi.name}),"attachments"),
12401247
D.a(F.repoUrl('attachadd',{page:wi.name,from: F.repoUrl('wikiedit',{name: wi.name})}), "attach"),
12411248
D.a(F.repoUrl('wikiedit',{name:wi.name}),"editor permalink")
12421249
);
1243
- this.updateAttachmentsView();
1250
+ return this;
12441251
};
12451252
12461253
/**
12471254
Update the page title and header based on the state of
12481255
this.winfo. A no-op if this.winfo is not set. Returns this.
12491256
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -527,11 +527,11 @@
527 else if(0===name.indexOf('branch/')) wtype = 'branch';
528 else if(0===name.indexOf('tag/')) wtype = 'tag';
529 /* ^^^ note that we're not validating that, e.g., checkin/XYZ
530 has a full artifact ID after "checkin/". */
531 const winfo = {
532 name: name, type: wtype, mimetype: 'text/x-fossil-wiki',
533 version: null, parent: null
534 };
535 this.cache.pageList.push(
536 winfo/*keeps entry from getting lost from the list on save*/
537 );
@@ -1137,13 +1137,18 @@
1137 }
1138 D.clearElement(f.eAttach);
1139 const wi = this.winfo;
1140 if(!wi){
1141 D.append(f.eAttach,"No page loaded.");
1142 return;
1143 }
1144
 
 
 
 
 
1145 const btnReload = D.button("Reload list");
1146 const self = this;
1147 btnReload.addEventListener('click', function(){
1148 const isStashed = $stash.hasStashedContent(wi);
1149 F.fetch('wikiajax/attachments',{
@@ -1164,11 +1169,11 @@
1164 D.a(F.repoUrl('attachadd',{
1165 page: wi.name,
1166 from: F.repoUrl('wikiedit',{name: wi.name})}),
1167 "Add attachments..." )
1168 );
1169 return;
1170 }
1171 D.append(
1172 f.eAttach,
1173 D.append(D.p(),
1174 btnReload," ",
@@ -1213,10 +1218,11 @@
1213 const li = D.li(ul);
1214 D.append(li, urlCopy, " ", imgUrl);
1215 F.copyButton(urlCopy, {copyFromElement: imgUrl});
1216 });
1217 });
 
1218 };
1219
1220 /** Updates the in-tab title/edit status information */
1221 P.updateEditStatus = function f(){
1222 if(!f.eLinks){
@@ -1226,23 +1232,24 @@
1226 const wi = this.winfo;
1227 D.clearElement(f.eName, f.eLinks);
1228 if(!wi){
1229 D.append(f.eName, '(no page loaded)');
1230 this.updateAttachmentsView();
1231 return;
1232 }
1233 D.append(f.eName,getEditMarker(wi, false),wi.name);
1234 if(!wi.version) return;
 
1235 D.append(
1236 f.eLinks,
1237 D.a(F.repoUrl('wiki',{name:wi.name}),"viewer"),
1238 D.a(F.repoUrl('whistory',{name:wi.name}),'history'),
1239 D.a(F.repoUrl('attachlist',{page:wi.name}),"attachments"),
1240 D.a(F.repoUrl('attachadd',{page:wi.name,from: F.repoUrl('wikiedit',{name: wi.name})}), "attach"),
1241 D.a(F.repoUrl('wikiedit',{name:wi.name}),"editor permalink")
1242 );
1243 this.updateAttachmentsView();
1244 };
1245
1246 /**
1247 Update the page title and header based on the state of
1248 this.winfo. A no-op if this.winfo is not set. Returns this.
1249
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -527,11 +527,11 @@
527 else if(0===name.indexOf('branch/')) wtype = 'branch';
528 else if(0===name.indexOf('tag/')) wtype = 'tag';
529 /* ^^^ note that we're not validating that, e.g., checkin/XYZ
530 has a full artifact ID after "checkin/". */
531 const winfo = {
532 name: name, type: wtype, mimetype: 'text/x-markdown',
533 version: null, parent: null
534 };
535 this.cache.pageList.push(
536 winfo/*keeps entry from getting lost from the list on save*/
537 );
@@ -1137,13 +1137,18 @@
1137 }
1138 D.clearElement(f.eAttach);
1139 const wi = this.winfo;
1140 if(!wi){
1141 D.append(f.eAttach,"No page loaded.");
1142 return this;
1143 }
1144 else if(!wi.version){
1145 D.append(f.eAttach,
1146 "Page ["+wi.name+"] cannot have ",
1147 "attachments until it is saved once.");
1148 return this;
1149 }
1150 const btnReload = D.button("Reload list");
1151 const self = this;
1152 btnReload.addEventListener('click', function(){
1153 const isStashed = $stash.hasStashedContent(wi);
1154 F.fetch('wikiajax/attachments',{
@@ -1164,11 +1169,11 @@
1169 D.a(F.repoUrl('attachadd',{
1170 page: wi.name,
1171 from: F.repoUrl('wikiedit',{name: wi.name})}),
1172 "Add attachments..." )
1173 );
1174 return this;
1175 }
1176 D.append(
1177 f.eAttach,
1178 D.append(D.p(),
1179 btnReload," ",
@@ -1213,10 +1218,11 @@
1218 const li = D.li(ul);
1219 D.append(li, urlCopy, " ", imgUrl);
1220 F.copyButton(urlCopy, {copyFromElement: imgUrl});
1221 });
1222 });
1223 return this;
1224 };
1225
1226 /** Updates the in-tab title/edit status information */
1227 P.updateEditStatus = function f(){
1228 if(!f.eLinks){
@@ -1226,23 +1232,24 @@
1232 const wi = this.winfo;
1233 D.clearElement(f.eName, f.eLinks);
1234 if(!wi){
1235 D.append(f.eName, '(no page loaded)');
1236 this.updateAttachmentsView();
1237 return this;
1238 }
1239 D.append(f.eName,getEditMarker(wi, false),wi.name);
1240 this.updateAttachmentsView();
1241 if(!wi.version) return this;
1242 D.append(
1243 f.eLinks,
1244 D.a(F.repoUrl('wiki',{name:wi.name}),"viewer"),
1245 D.a(F.repoUrl('whistory',{name:wi.name}),'history'),
1246 D.a(F.repoUrl('attachlist',{page:wi.name}),"attachments"),
1247 D.a(F.repoUrl('attachadd',{page:wi.name,from: F.repoUrl('wikiedit',{name: wi.name})}), "attach"),
1248 D.a(F.repoUrl('wikiedit',{name:wi.name}),"editor permalink")
1249 );
1250 return this;
1251 };
1252
1253 /**
1254 Update the page title and header based on the state of
1255 this.winfo. A no-op if this.winfo is not set. Returns this.
1256

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button