Fossil SCM

Re-enabled the discard-all-edits button in wikiedit and made it look the same in both wikiedit and fileedit.

stephan 2020-08-13 11:49 trunk
Commit 39a5289b9b7c20affe5c37b476723ef64929a66610d82bccdc46acac14df3f34
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -465,11 +465,11 @@
465465
D.attr(D.div(),'id','fileedit-stash-selector'),
466466
'input-with-label'
467467
);
468468
const sel = this.e.select = D.select();
469469
const btnClear = this.e.btnClear
470
- = D.button("Clear");
470
+ = D.button("Discard Edits");
471471
D.append(wrapper, "Local edits (",
472472
D.append(D.code(),
473473
F.storage.storageImplName()),
474474
"):",
475475
sel, btnClear);
@@ -495,11 +495,11 @@
495495
}
496496
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
497497
F.confirmer(btnClear, {
498498
/* must come after insertion into the DOM for the pinSize option to work. */
499499
pinSize: true,
500
- confirmText: "DELETE all local edits?",
500
+ confirmText: "DISCARD all local edits?",
501501
onconfirm: function(e){
502502
if(P.finfo){
503503
const stashed = P.getStashedFinfo(P.finfo);
504504
P.clearStash();
505505
if(stashed) P.loadFile(/*reload after discarding edits*/);
506506
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -465,11 +465,11 @@
465 D.attr(D.div(),'id','fileedit-stash-selector'),
466 'input-with-label'
467 );
468 const sel = this.e.select = D.select();
469 const btnClear = this.e.btnClear
470 = D.button("Clear");
471 D.append(wrapper, "Local edits (",
472 D.append(D.code(),
473 F.storage.storageImplName()),
474 "):",
475 sel, btnClear);
@@ -495,11 +495,11 @@
495 }
496 domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
497 F.confirmer(btnClear, {
498 /* must come after insertion into the DOM for the pinSize option to work. */
499 pinSize: true,
500 confirmText: "DELETE all local edits?",
501 onconfirm: function(e){
502 if(P.finfo){
503 const stashed = P.getStashedFinfo(P.finfo);
504 P.clearStash();
505 if(stashed) P.loadFile(/*reload after discarding edits*/);
506
--- src/fossil.page.fileedit.js
+++ src/fossil.page.fileedit.js
@@ -465,11 +465,11 @@
465 D.attr(D.div(),'id','fileedit-stash-selector'),
466 'input-with-label'
467 );
468 const sel = this.e.select = D.select();
469 const btnClear = this.e.btnClear
470 = D.button("Discard Edits");
471 D.append(wrapper, "Local edits (",
472 D.append(D.code(),
473 F.storage.storageImplName()),
474 "):",
475 sel, btnClear);
@@ -495,11 +495,11 @@
495 }
496 domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
497 F.confirmer(btnClear, {
498 /* must come after insertion into the DOM for the pinSize option to work. */
499 pinSize: true,
500 confirmText: "DISCARD all local edits?",
501 onconfirm: function(e){
502 if(P.finfo){
503 const stashed = P.getStashedFinfo(P.finfo);
504 P.clearStash();
505 if(stashed) P.loadFile(/*reload after discarding edits*/);
506
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -277,11 +277,13 @@
277277
}
278278
};
279279
280280
/**
281281
Internal helper to get an edit status indicator for the given
282
- winfo object.
282
+ winfo object. Pass it a winfo object or one of the "constants"
283
+ which are assigned as member properties of this function (see
284
+ below its definition).
283285
*/
284286
const getEditMarker = function f(winfo, textOnly){
285287
const esm = F.config.editStateMarkers;
286288
if(f.NEW===winfo){ /* force is-new */
287289
return textOnly ? esm.isNew :
@@ -313,15 +315,17 @@
313315
getEditMarker.NEW = 1;
314316
getEditMarker.MODIFIED = 2;
315317
getEditMarker.DELETED = 3;
316318
317319
/**
318
- Returns true if the given winfo object appears to be "new", else
319
- returns false.
320
+ Returns undefined if winfo is falsy, true if the given winfo
321
+ object appears to be "new", else returns false.
320322
*/
321323
const winfoIsNew = function(winfo){
322
- return 'sandbox'===winfo.type ? false : !winfo.version;
324
+ if(!winfo) return undefined;
325
+ else if('sandbox' === winfo.type) return false;
326
+ else return !winfo.version;
323327
};
324328
325329
/**
326330
Sets up and maintains the widgets for the list of wiki pages.
327331
*/
@@ -679,12 +683,11 @@
679683
const wrapper = D.addClass(
680684
D.attr(D.div(),'id','wikiedit-stash-selector'),
681685
'input-with-label'
682686
);
683687
const sel = this.e.select = D.select();
684
- const btnClear = this.e.btnClear
685
- = D.addClass(D.button("Clear"),'hidden');
688
+ const btnClear = this.e.btnClear = D.button("Discard Edits");
686689
D.append(wrapper, "Local edits (",
687690
D.append(D.code(),
688691
F.storage.storageImplName()),
689692
"):",
690693
sel, btnClear);
@@ -698,27 +701,31 @@
698701
P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail));
699702
sel.addEventListener('change',function(e){
700703
const opt = this.selectedOptions[0];
701704
if(opt && opt._winfo) P.loadPage(opt._winfo);
702705
});
703
- if(P.config.useConfirmerButtons.discardStash){
704
- F.confirmer(btnClear, {
705
- confirmText: "REALLY delete ALL local edits?",
706
- onconfirm: ()=>P.clearStash(),
707
- ticks: F.config.confirmerButtonTicks
708
- });
709
- }else{
710
- btnClear.addEventListener('click', ()=>P.clearStash(), false);
711
- }
712706
if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/
713707
D.append(wrapper, D.append(
714708
D.addClass(D.span(),'warning'),
715709
"Warning: persistent storage is not available, "+
716710
"so uncomitted edits will not survive a page reload."
717711
));
718712
}
719713
domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
714
+ if(P.config.useConfirmerButtons.discardStash){
715
+ /* Must come after btnClear is in the DOM AND the button must
716
+ not be hidden, else pinned sizing won't work. */
717
+ F.confirmer(btnClear, {
718
+ pinSize: true,
719
+ confirmText: "DISCARD all local edits?",
720
+ onconfirm: ()=>P.clearStash(),
721
+ ticks: F.config.confirmerButtonTicks
722
+ });
723
+ }else{
724
+ btnClear.addEventListener('click', ()=>P.clearStash(), false);
725
+ }
726
+ D.addClass(btnClear,'hidden');
720727
$stash._fireStashEvent(/*read the page-load-time stash*/);
721728
delete this.init;
722729
},
723730
/**
724731
Regenerates the edit selection list.
@@ -746,15 +753,15 @@
746753
D.addClass(this.e.btnClear, 'hidden');
747754
D.option(D.disable(this.e.select),"No local edits");
748755
return;
749756
}
750757
D.enable(this.e.select);
751
- if(false){
752
- /* The problem with this Clear button is that it allows the user
753
- to nuke a non-empty newly-added page without the failsafe confirmation
754
- we have if they use P.e.btnReload. Not yet sure how best to resolve that,
755
- so we'll leave the button hidden for the time being. */
758
+ if(true){
759
+ /* The problem with this Clear button is that it allows the
760
+ user to nuke a non-empty newly-added page without the
761
+ failsafe confirmation we have if they use
762
+ P.e.btnReload. Not yet sure how best to resolve that. */
756763
D.removeClass(this.e.btnClear, 'hidden');
757764
}
758765
D.disable(D.option(this.e.select,0,"Select a local edit..."));
759766
const currentWinfo = theWinfo || P.winfo || {name:''};
760767
ilist.sort(f.compare).forEach(function(winfo,n){
@@ -1127,12 +1134,14 @@
11271134
Change the save button depending on whether we have stuff to save
11281135
or not.
11291136
*/
11301137
P.updateSaveButton = function(){
11311138
/**
1132
- // Current disabled, per forum feedback and MSIE compatibility, but
1133
- // might be revisited...
1139
+ // Currently disabled, per forum feedback and platform-level
1140
+ // event-handling compatibility, but might be revisited. We now
1141
+ // use an is-dirty flag instead to prevent saving when no change
1142
+ // event has fired for the current doc.
11341143
if(!this.winfo || !this.getStashedWinfo(this.winfo)){
11351144
D.disable(this.e.btnSave).innerText =
11361145
"No changes to save";
11371146
D.disable(this.e.btnSaveClose);
11381147
}else{
11391148
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -277,11 +277,13 @@
277 }
278 };
279
280 /**
281 Internal helper to get an edit status indicator for the given
282 winfo object.
 
 
283 */
284 const getEditMarker = function f(winfo, textOnly){
285 const esm = F.config.editStateMarkers;
286 if(f.NEW===winfo){ /* force is-new */
287 return textOnly ? esm.isNew :
@@ -313,15 +315,17 @@
313 getEditMarker.NEW = 1;
314 getEditMarker.MODIFIED = 2;
315 getEditMarker.DELETED = 3;
316
317 /**
318 Returns true if the given winfo object appears to be "new", else
319 returns false.
320 */
321 const winfoIsNew = function(winfo){
322 return 'sandbox'===winfo.type ? false : !winfo.version;
 
 
323 };
324
325 /**
326 Sets up and maintains the widgets for the list of wiki pages.
327 */
@@ -679,12 +683,11 @@
679 const wrapper = D.addClass(
680 D.attr(D.div(),'id','wikiedit-stash-selector'),
681 'input-with-label'
682 );
683 const sel = this.e.select = D.select();
684 const btnClear = this.e.btnClear
685 = D.addClass(D.button("Clear"),'hidden');
686 D.append(wrapper, "Local edits (",
687 D.append(D.code(),
688 F.storage.storageImplName()),
689 "):",
690 sel, btnClear);
@@ -698,27 +701,31 @@
698 P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail));
699 sel.addEventListener('change',function(e){
700 const opt = this.selectedOptions[0];
701 if(opt && opt._winfo) P.loadPage(opt._winfo);
702 });
703 if(P.config.useConfirmerButtons.discardStash){
704 F.confirmer(btnClear, {
705 confirmText: "REALLY delete ALL local edits?",
706 onconfirm: ()=>P.clearStash(),
707 ticks: F.config.confirmerButtonTicks
708 });
709 }else{
710 btnClear.addEventListener('click', ()=>P.clearStash(), false);
711 }
712 if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/
713 D.append(wrapper, D.append(
714 D.addClass(D.span(),'warning'),
715 "Warning: persistent storage is not available, "+
716 "so uncomitted edits will not survive a page reload."
717 ));
718 }
719 domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
 
 
 
 
 
 
 
 
 
 
 
 
 
720 $stash._fireStashEvent(/*read the page-load-time stash*/);
721 delete this.init;
722 },
723 /**
724 Regenerates the edit selection list.
@@ -746,15 +753,15 @@
746 D.addClass(this.e.btnClear, 'hidden');
747 D.option(D.disable(this.e.select),"No local edits");
748 return;
749 }
750 D.enable(this.e.select);
751 if(false){
752 /* The problem with this Clear button is that it allows the user
753 to nuke a non-empty newly-added page without the failsafe confirmation
754 we have if they use P.e.btnReload. Not yet sure how best to resolve that,
755 so we'll leave the button hidden for the time being. */
756 D.removeClass(this.e.btnClear, 'hidden');
757 }
758 D.disable(D.option(this.e.select,0,"Select a local edit..."));
759 const currentWinfo = theWinfo || P.winfo || {name:''};
760 ilist.sort(f.compare).forEach(function(winfo,n){
@@ -1127,12 +1134,14 @@
1127 Change the save button depending on whether we have stuff to save
1128 or not.
1129 */
1130 P.updateSaveButton = function(){
1131 /**
1132 // Current disabled, per forum feedback and MSIE compatibility, but
1133 // might be revisited...
 
 
1134 if(!this.winfo || !this.getStashedWinfo(this.winfo)){
1135 D.disable(this.e.btnSave).innerText =
1136 "No changes to save";
1137 D.disable(this.e.btnSaveClose);
1138 }else{
1139
--- src/fossil.page.wikiedit.js
+++ src/fossil.page.wikiedit.js
@@ -277,11 +277,13 @@
277 }
278 };
279
280 /**
281 Internal helper to get an edit status indicator for the given
282 winfo object. Pass it a winfo object or one of the "constants"
283 which are assigned as member properties of this function (see
284 below its definition).
285 */
286 const getEditMarker = function f(winfo, textOnly){
287 const esm = F.config.editStateMarkers;
288 if(f.NEW===winfo){ /* force is-new */
289 return textOnly ? esm.isNew :
@@ -313,15 +315,17 @@
315 getEditMarker.NEW = 1;
316 getEditMarker.MODIFIED = 2;
317 getEditMarker.DELETED = 3;
318
319 /**
320 Returns undefined if winfo is falsy, true if the given winfo
321 object appears to be "new", else returns false.
322 */
323 const winfoIsNew = function(winfo){
324 if(!winfo) return undefined;
325 else if('sandbox' === winfo.type) return false;
326 else return !winfo.version;
327 };
328
329 /**
330 Sets up and maintains the widgets for the list of wiki pages.
331 */
@@ -679,12 +683,11 @@
683 const wrapper = D.addClass(
684 D.attr(D.div(),'id','wikiedit-stash-selector'),
685 'input-with-label'
686 );
687 const sel = this.e.select = D.select();
688 const btnClear = this.e.btnClear = D.button("Discard Edits");
 
689 D.append(wrapper, "Local edits (",
690 D.append(D.code(),
691 F.storage.storageImplName()),
692 "):",
693 sel, btnClear);
@@ -698,27 +701,31 @@
701 P.addEventListener('wiki-page-loaded',(e)=>this.updateList($stash, e.detail));
702 sel.addEventListener('change',function(e){
703 const opt = this.selectedOptions[0];
704 if(opt && opt._winfo) P.loadPage(opt._winfo);
705 });
 
 
 
 
 
 
 
 
 
706 if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/
707 D.append(wrapper, D.append(
708 D.addClass(D.span(),'warning'),
709 "Warning: persistent storage is not available, "+
710 "so uncomitted edits will not survive a page reload."
711 ));
712 }
713 domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint);
714 if(P.config.useConfirmerButtons.discardStash){
715 /* Must come after btnClear is in the DOM AND the button must
716 not be hidden, else pinned sizing won't work. */
717 F.confirmer(btnClear, {
718 pinSize: true,
719 confirmText: "DISCARD all local edits?",
720 onconfirm: ()=>P.clearStash(),
721 ticks: F.config.confirmerButtonTicks
722 });
723 }else{
724 btnClear.addEventListener('click', ()=>P.clearStash(), false);
725 }
726 D.addClass(btnClear,'hidden');
727 $stash._fireStashEvent(/*read the page-load-time stash*/);
728 delete this.init;
729 },
730 /**
731 Regenerates the edit selection list.
@@ -746,15 +753,15 @@
753 D.addClass(this.e.btnClear, 'hidden');
754 D.option(D.disable(this.e.select),"No local edits");
755 return;
756 }
757 D.enable(this.e.select);
758 if(true){
759 /* The problem with this Clear button is that it allows the
760 user to nuke a non-empty newly-added page without the
761 failsafe confirmation we have if they use
762 P.e.btnReload. Not yet sure how best to resolve that. */
763 D.removeClass(this.e.btnClear, 'hidden');
764 }
765 D.disable(D.option(this.e.select,0,"Select a local edit..."));
766 const currentWinfo = theWinfo || P.winfo || {name:''};
767 ilist.sort(f.compare).forEach(function(winfo,n){
@@ -1127,12 +1134,14 @@
1134 Change the save button depending on whether we have stuff to save
1135 or not.
1136 */
1137 P.updateSaveButton = function(){
1138 /**
1139 // Currently disabled, per forum feedback and platform-level
1140 // event-handling compatibility, but might be revisited. We now
1141 // use an is-dirty flag instead to prevent saving when no change
1142 // event has fired for the current doc.
1143 if(!this.winfo || !this.getStashedWinfo(this.winfo)){
1144 D.disable(this.e.btnSave).innerText =
1145 "No changes to save";
1146 D.disable(this.e.btnSaveClose);
1147 }else{
1148

Keyboard Shortcuts

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