Fossil SCM

Added reload capability to /wikiedit attachment list.

stephan 2021-07-16 18:15 wikiedit-attachment-list
Commit 91bb602ad609ad6de4a3bd37e4bea9b929a5c07abbee78e6e228f1578397916f
1 file changed +34 -3
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -1138,19 +1138,50 @@
11381138
D.clearElement(f.eAttach);
11391139
const wi = this.winfo;
11401140
if(!wi){
11411141
D.append(f.eAttach,"No page loaded.");
11421142
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
+ );
11451169
return;
11461170
}
11471171
D.append(
11481172
f.eAttach,
11491173
D.append(D.p(),
1174
+ btnReload," ",
11501175
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
+ )
11521183
);
11531184
wi.attachments.forEach(function(a){
11541185
const wrap = D.div();
11551186
D.append(f.eAttach, wrap);
11561187
D.append(wrap,
11571188
--- 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

Keyboard Shortcuts

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