Fossil SCM
Added reload capability to /wikiedit attachment list.
Commit
91bb602ad609ad6de4a3bd37e4bea9b929a5c07abbee78e6e228f1578397916f
Parent
74c6b9c5be2c104…
1 file changed
+34
-3
+34
-3
| --- src/fossil.page.wikiedit.js | ||
| +++ src/fossil.page.wikiedit.js | ||
| @@ -1138,19 +1138,50 @@ | ||
| 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 | 1142 | return; |
| 1143 | - }else if(!wi.attachments || !wi.attachments.length){ | |
| 1144 | - D.append(f.eAttach,"No attachments found for the current page."); | |
| 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',{ | |
| 1150 | + responseType: 'json', | |
| 1151 | + urlParams: {page: wi.name}, | |
| 1152 | + onload: function(r){ | |
| 1153 | + wi.attachments = r; | |
| 1154 | + if(isStashed) self.stashContentChange(true); | |
| 1155 | + F.message("Reloaded attachment list for ["+wi.name+"]."); | |
| 1156 | + self.updateAttachmentsView(); | |
| 1157 | + } | |
| 1158 | + }); | |
| 1159 | + }); | |
| 1160 | + if(!wi.attachments || !wi.attachments.length){ | |
| 1161 | + D.append(f.eAttach, | |
| 1162 | + btnReload, | |
| 1163 | + " No attachments found for page ["+wi.name+"]. ", | |
| 1164 | + D.a(F.repoUrl('attachadd',{ | |
| 1165 | + page: wi.name, | |
| 1166 | + from: F.repoUrl('wikiedit',{name: wi.name})}), | |
| 1167 | + "Add attachments..." ) | |
| 1168 | + ); | |
| 1145 | 1169 | return; |
| 1146 | 1170 | } |
| 1147 | 1171 | D.append( |
| 1148 | 1172 | f.eAttach, |
| 1149 | 1173 | D.append(D.p(), |
| 1174 | + btnReload," ", | |
| 1150 | 1175 | D.a(F.repoUrl('attachlist',{page:wi.name}), |
| 1151 | - "Attachments for page ["+wi.name+"]")) | |
| 1176 | + "Attachments for page ["+wi.name+"]."), | |
| 1177 | + " ", | |
| 1178 | + D.a(F.repoUrl('attachadd',{ | |
| 1179 | + page:wi.name, | |
| 1180 | + from: F.repoUrl('wikiedit',{name: wi.name})}), | |
| 1181 | + "Add attachments..." ) | |
| 1182 | + ) | |
| 1152 | 1183 | ); |
| 1153 | 1184 | wi.attachments.forEach(function(a){ |
| 1154 | 1185 | const wrap = D.div(); |
| 1155 | 1186 | D.append(f.eAttach, wrap); |
| 1156 | 1187 | D.append(wrap, |
| 1157 | 1188 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -1138,19 +1138,50 @@ | |
| 1138 | D.clearElement(f.eAttach); |
| 1139 | const wi = this.winfo; |
| 1140 | if(!wi){ |
| 1141 | D.append(f.eAttach,"No page loaded."); |
| 1142 | return; |
| 1143 | }else if(!wi.attachments || !wi.attachments.length){ |
| 1144 | D.append(f.eAttach,"No attachments found for the current page."); |
| 1145 | return; |
| 1146 | } |
| 1147 | D.append( |
| 1148 | f.eAttach, |
| 1149 | D.append(D.p(), |
| 1150 | D.a(F.repoUrl('attachlist',{page:wi.name}), |
| 1151 | "Attachments for page ["+wi.name+"]")) |
| 1152 | ); |
| 1153 | wi.attachments.forEach(function(a){ |
| 1154 | const wrap = D.div(); |
| 1155 | D.append(f.eAttach, wrap); |
| 1156 | D.append(wrap, |
| 1157 |
| --- src/fossil.page.wikiedit.js | |
| +++ src/fossil.page.wikiedit.js | |
| @@ -1138,19 +1138,50 @@ | |
| 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',{ |
| 1150 | responseType: 'json', |
| 1151 | urlParams: {page: wi.name}, |
| 1152 | onload: function(r){ |
| 1153 | wi.attachments = r; |
| 1154 | if(isStashed) self.stashContentChange(true); |
| 1155 | F.message("Reloaded attachment list for ["+wi.name+"]."); |
| 1156 | self.updateAttachmentsView(); |
| 1157 | } |
| 1158 | }); |
| 1159 | }); |
| 1160 | if(!wi.attachments || !wi.attachments.length){ |
| 1161 | D.append(f.eAttach, |
| 1162 | btnReload, |
| 1163 | " No attachments found for page ["+wi.name+"]. ", |
| 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," ", |
| 1175 | D.a(F.repoUrl('attachlist',{page:wi.name}), |
| 1176 | "Attachments for page ["+wi.name+"]."), |
| 1177 | " ", |
| 1178 | D.a(F.repoUrl('attachadd',{ |
| 1179 | page:wi.name, |
| 1180 | from: F.repoUrl('wikiedit',{name: wi.name})}), |
| 1181 | "Add attachments..." ) |
| 1182 | ) |
| 1183 | ); |
| 1184 | wi.attachments.forEach(function(a){ |
| 1185 | const wrap = D.div(); |
| 1186 | D.append(f.eAttach, wrap); |
| 1187 | D.append(wrap, |
| 1188 |