Fossil SCM
wikiedit: the attachment area now explains that new pages cannot have attachments until the page is saved once.
Commit
70716bbc0e5f1cce1370aa81166ccd7b6ae9c33df9b05c2e5a7e4835f35508b4
Parent
a36cd610afc35ac…
1 file changed
+14
-7
+14
-7
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -527,11 +527,11 @@ | ||
| 527 | 527 | else if(0===name.indexOf('branch/')) wtype = 'branch'; |
| 528 | 528 | else if(0===name.indexOf('tag/')) wtype = 'tag'; |
| 529 | 529 | /* ^^^ note that we're not validating that, e.g., checkin/XYZ |
| 530 | 530 | has a full artifact ID after "checkin/". */ |
| 531 | 531 | const winfo = { |
| 532 | - name: name, type: wtype, mimetype: 'text/x-fossil-wiki', | |
| 532 | + name: name, type: wtype, mimetype: 'text/x-markdown', | |
| 533 | 533 | version: null, parent: null |
| 534 | 534 | }; |
| 535 | 535 | this.cache.pageList.push( |
| 536 | 536 | winfo/*keeps entry from getting lost from the list on save*/ |
| 537 | 537 | ); |
| @@ -1137,13 +1137,18 @@ | ||
| 1137 | 1137 | } |
| 1138 | 1138 | D.clearElement(f.eAttach); |
| 1139 | 1139 | const wi = this.winfo; |
| 1140 | 1140 | if(!wi){ |
| 1141 | 1141 | D.append(f.eAttach,"No page loaded."); |
| 1142 | - return; | |
| 1142 | + return this; | |
| 1143 | 1143 | } |
| 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 | + } | |
| 1145 | 1150 | const btnReload = D.button("Reload list"); |
| 1146 | 1151 | const self = this; |
| 1147 | 1152 | btnReload.addEventListener('click', function(){ |
| 1148 | 1153 | const isStashed = $stash.hasStashedContent(wi); |
| 1149 | 1154 | F.fetch('wikiajax/attachments',{ |
| @@ -1164,11 +1169,11 @@ | ||
| 1164 | 1169 | D.a(F.repoUrl('attachadd',{ |
| 1165 | 1170 | page: wi.name, |
| 1166 | 1171 | from: F.repoUrl('wikiedit',{name: wi.name})}), |
| 1167 | 1172 | "Add attachments..." ) |
| 1168 | 1173 | ); |
| 1169 | - return; | |
| 1174 | + return this; | |
| 1170 | 1175 | } |
| 1171 | 1176 | D.append( |
| 1172 | 1177 | f.eAttach, |
| 1173 | 1178 | D.append(D.p(), |
| 1174 | 1179 | btnReload," ", |
| @@ -1213,10 +1218,11 @@ | ||
| 1213 | 1218 | const li = D.li(ul); |
| 1214 | 1219 | D.append(li, urlCopy, " ", imgUrl); |
| 1215 | 1220 | F.copyButton(urlCopy, {copyFromElement: imgUrl}); |
| 1216 | 1221 | }); |
| 1217 | 1222 | }); |
| 1223 | + return this; | |
| 1218 | 1224 | }; |
| 1219 | 1225 | |
| 1220 | 1226 | /** Updates the in-tab title/edit status information */ |
| 1221 | 1227 | P.updateEditStatus = function f(){ |
| 1222 | 1228 | if(!f.eLinks){ |
| @@ -1226,23 +1232,24 @@ | ||
| 1226 | 1232 | const wi = this.winfo; |
| 1227 | 1233 | D.clearElement(f.eName, f.eLinks); |
| 1228 | 1234 | if(!wi){ |
| 1229 | 1235 | D.append(f.eName, '(no page loaded)'); |
| 1230 | 1236 | this.updateAttachmentsView(); |
| 1231 | - return; | |
| 1237 | + return this; | |
| 1232 | 1238 | } |
| 1233 | 1239 | D.append(f.eName,getEditMarker(wi, false),wi.name); |
| 1234 | - if(!wi.version) return; | |
| 1240 | + this.updateAttachmentsView(); | |
| 1241 | + if(!wi.version) return this; | |
| 1235 | 1242 | D.append( |
| 1236 | 1243 | f.eLinks, |
| 1237 | 1244 | D.a(F.repoUrl('wiki',{name:wi.name}),"viewer"), |
| 1238 | 1245 | D.a(F.repoUrl('whistory',{name:wi.name}),'history'), |
| 1239 | 1246 | D.a(F.repoUrl('attachlist',{page:wi.name}),"attachments"), |
| 1240 | 1247 | D.a(F.repoUrl('attachadd',{page:wi.name,from: F.repoUrl('wikiedit',{name: wi.name})}), "attach"), |
| 1241 | 1248 | D.a(F.repoUrl('wikiedit',{name:wi.name}),"editor permalink") |
| 1242 | 1249 | ); |
| 1243 | - this.updateAttachmentsView(); | |
| 1250 | + return this; | |
| 1244 | 1251 | }; |
| 1245 | 1252 | |
| 1246 | 1253 | /** |
| 1247 | 1254 | Update the page title and header based on the state of |
| 1248 | 1255 | this.winfo. A no-op if this.winfo is not set. Returns this. |
| 1249 | 1256 |
| --- 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 |