Fossil SCM
fileedit confirmer buttons now use the new pinSize confirmer option. Minor style consistency tweak. fileedit no longer complains when discarding stashed edits when no file is loaded, and reloads the current file only if it was in the now-discarded local edits.
Commit
83a95dbff1be67438d447b44b07e6a2fbaf5fa3d3d4e024fb909897e1cffc5e3
Parent
33610b04de8fdf5…
2 files changed
+2
-1
+18
-6
+2
-1
| --- src/fileedit.c | ||
| +++ src/fileedit.c | ||
| @@ -1803,11 +1803,12 @@ | ||
| 1803 | 1803 | "data-tab-parent='fileedit-tabs' " |
| 1804 | 1804 | "data-tab-label='Diff' " |
| 1805 | 1805 | "class='hidden'" |
| 1806 | 1806 | ">"); |
| 1807 | 1807 | |
| 1808 | - CX("<div class='fileedit-options flex-container flex-row' " | |
| 1808 | + CX("<div class='fileedit-options flex-container " | |
| 1809 | + "flex-row child-gap-small' " | |
| 1809 | 1810 | "id='fileedit-tab-diff-buttons'>"); |
| 1810 | 1811 | CX("<button class='sbs'>Side-by-side</button>" |
| 1811 | 1812 | "<button class='unified'>Unified</button>"); |
| 1812 | 1813 | if(0){ |
| 1813 | 1814 | /* For the time being let's just ignore all whitespace |
| 1814 | 1815 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1803,11 +1803,12 @@ | |
| 1803 | "data-tab-parent='fileedit-tabs' " |
| 1804 | "data-tab-label='Diff' " |
| 1805 | "class='hidden'" |
| 1806 | ">"); |
| 1807 | |
| 1808 | CX("<div class='fileedit-options flex-container flex-row' " |
| 1809 | "id='fileedit-tab-diff-buttons'>"); |
| 1810 | CX("<button class='sbs'>Side-by-side</button>" |
| 1811 | "<button class='unified'>Unified</button>"); |
| 1812 | if(0){ |
| 1813 | /* For the time being let's just ignore all whitespace |
| 1814 |
| --- src/fileedit.c | |
| +++ src/fileedit.c | |
| @@ -1803,11 +1803,12 @@ | |
| 1803 | "data-tab-parent='fileedit-tabs' " |
| 1804 | "data-tab-label='Diff' " |
| 1805 | "class='hidden'" |
| 1806 | ">"); |
| 1807 | |
| 1808 | CX("<div class='fileedit-options flex-container " |
| 1809 | "flex-row child-gap-small' " |
| 1810 | "id='fileedit-tab-diff-buttons'>"); |
| 1811 | CX("<button class='sbs'>Side-by-side</button>" |
| 1812 | "<button class='unified'>Unified</button>"); |
| 1813 | if(0){ |
| 1814 | /* For the time being let's just ignore all whitespace |
| 1815 |
+18
-6
| --- src/fossil.page.fileedit.js | ||
| +++ src/fossil.page.fileedit.js | ||
| @@ -464,11 +464,11 @@ | ||
| 464 | 464 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 465 | 465 | 'input-with-label' |
| 466 | 466 | ); |
| 467 | 467 | const sel = this.e.select = D.select(); |
| 468 | 468 | const btnClear = this.e.btnClear |
| 469 | - = D.addClass(D.button("Clear"),'hidden'); | |
| 469 | + = D.button("Clear"); | |
| 470 | 470 | D.append(wrapper, "Local edits (", |
| 471 | 471 | D.append(D.code(), |
| 472 | 472 | F.storage.storageImplName()), |
| 473 | 473 | "):", |
| 474 | 474 | sel, btnClear); |
| @@ -483,23 +483,34 @@ | ||
| 483 | 483 | F.page.addEventListener('fileedit-file-loaded',(e)=>this.updateList($stash, e.detail)); |
| 484 | 484 | sel.addEventListener('change',function(e){ |
| 485 | 485 | const opt = this.selectedOptions[0]; |
| 486 | 486 | if(opt && opt._finfo) P.loadFile(opt._finfo); |
| 487 | 487 | }); |
| 488 | - F.confirmer(btnClear, { | |
| 489 | - confirmText: "REALLY delete ALL local edits?", | |
| 490 | - onconfirm: (e)=>P.clearStash().loadFile(/*in case P.finfo was in the stash*/), | |
| 491 | - ticks: F.config.confirmerButtonTicks | |
| 492 | - }); | |
| 493 | 488 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 494 | 489 | D.append(wrapper, D.append( |
| 495 | 490 | D.addClass(D.span(),'warning'), |
| 496 | 491 | "Warning: persistent storage is not available, "+ |
| 497 | 492 | "so uncomitted edits will not survive a page reload." |
| 498 | 493 | )); |
| 499 | 494 | } |
| 500 | 495 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 496 | + F.confirmer(btnClear, { | |
| 497 | + /* must come after insertion into the DOM for the pinSize option to work. */ | |
| 498 | + pinSize: true, | |
| 499 | + confirmText: "DELETE all local edits?", | |
| 500 | + onconfirm: function(e){ | |
| 501 | + if(P.finfo){ | |
| 502 | + const stashed = P.getStashedFinfo(P.finfo); | |
| 503 | + P.clearStash(); | |
| 504 | + if(stashed) P.loadFile(/*reload after discarding edits*/); | |
| 505 | + }else{ | |
| 506 | + P.clearStash(); | |
| 507 | + } | |
| 508 | + }, | |
| 509 | + ticks: F.config.confirmerButtonTicks | |
| 510 | + }); | |
| 511 | + D.addClass(this.e.btnClear,'hidden' /* must not be set until after confirmer is set up!*/); | |
| 501 | 512 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 502 | 513 | delete this.init; |
| 503 | 514 | }, |
| 504 | 515 | /** |
| 505 | 516 | Regenerates the edit selection list. |
| @@ -726,10 +737,11 @@ | ||
| 726 | 737 | ); |
| 727 | 738 | P.e.btnCommit.addEventListener( |
| 728 | 739 | "click",(e)=>P.commit(), false |
| 729 | 740 | ); |
| 730 | 741 | F.confirmer(P.e.btnReload, { |
| 742 | + pinSize: true, | |
| 731 | 743 | confirmText: "Really reload, losing edits?", |
| 732 | 744 | onconfirm: (e)=>P.unstashContent().loadFile(), |
| 733 | 745 | ticks: F.config.confirmerButtonTicks |
| 734 | 746 | }); |
| 735 | 747 | E('#comment-toggle').addEventListener( |
| 736 | 748 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -464,11 +464,11 @@ | |
| 464 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 465 | 'input-with-label' |
| 466 | ); |
| 467 | const sel = this.e.select = D.select(); |
| 468 | const btnClear = this.e.btnClear |
| 469 | = D.addClass(D.button("Clear"),'hidden'); |
| 470 | D.append(wrapper, "Local edits (", |
| 471 | D.append(D.code(), |
| 472 | F.storage.storageImplName()), |
| 473 | "):", |
| 474 | sel, btnClear); |
| @@ -483,23 +483,34 @@ | |
| 483 | F.page.addEventListener('fileedit-file-loaded',(e)=>this.updateList($stash, e.detail)); |
| 484 | sel.addEventListener('change',function(e){ |
| 485 | const opt = this.selectedOptions[0]; |
| 486 | if(opt && opt._finfo) P.loadFile(opt._finfo); |
| 487 | }); |
| 488 | F.confirmer(btnClear, { |
| 489 | confirmText: "REALLY delete ALL local edits?", |
| 490 | onconfirm: (e)=>P.clearStash().loadFile(/*in case P.finfo was in the stash*/), |
| 491 | ticks: F.config.confirmerButtonTicks |
| 492 | }); |
| 493 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 494 | D.append(wrapper, D.append( |
| 495 | D.addClass(D.span(),'warning'), |
| 496 | "Warning: persistent storage is not available, "+ |
| 497 | "so uncomitted edits will not survive a page reload." |
| 498 | )); |
| 499 | } |
| 500 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 501 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 502 | delete this.init; |
| 503 | }, |
| 504 | /** |
| 505 | Regenerates the edit selection list. |
| @@ -726,10 +737,11 @@ | |
| 726 | ); |
| 727 | P.e.btnCommit.addEventListener( |
| 728 | "click",(e)=>P.commit(), false |
| 729 | ); |
| 730 | F.confirmer(P.e.btnReload, { |
| 731 | confirmText: "Really reload, losing edits?", |
| 732 | onconfirm: (e)=>P.unstashContent().loadFile(), |
| 733 | ticks: F.config.confirmerButtonTicks |
| 734 | }); |
| 735 | E('#comment-toggle').addEventListener( |
| 736 |
| --- src/fossil.page.fileedit.js | |
| +++ src/fossil.page.fileedit.js | |
| @@ -464,11 +464,11 @@ | |
| 464 | D.attr(D.div(),'id','fileedit-stash-selector'), |
| 465 | 'input-with-label' |
| 466 | ); |
| 467 | const sel = this.e.select = D.select(); |
| 468 | const btnClear = this.e.btnClear |
| 469 | = D.button("Clear"); |
| 470 | D.append(wrapper, "Local edits (", |
| 471 | D.append(D.code(), |
| 472 | F.storage.storageImplName()), |
| 473 | "):", |
| 474 | sel, btnClear); |
| @@ -483,23 +483,34 @@ | |
| 483 | F.page.addEventListener('fileedit-file-loaded',(e)=>this.updateList($stash, e.detail)); |
| 484 | sel.addEventListener('change',function(e){ |
| 485 | const opt = this.selectedOptions[0]; |
| 486 | if(opt && opt._finfo) P.loadFile(opt._finfo); |
| 487 | }); |
| 488 | if(F.storage.isTransient()){/*Warn if our storage is particularly transient...*/ |
| 489 | D.append(wrapper, D.append( |
| 490 | D.addClass(D.span(),'warning'), |
| 491 | "Warning: persistent storage is not available, "+ |
| 492 | "so uncomitted edits will not survive a page reload." |
| 493 | )); |
| 494 | } |
| 495 | domInsertPoint.parentNode.insertBefore(wrapper, domInsertPoint); |
| 496 | F.confirmer(btnClear, { |
| 497 | /* must come after insertion into the DOM for the pinSize option to work. */ |
| 498 | pinSize: true, |
| 499 | confirmText: "DELETE all local edits?", |
| 500 | onconfirm: function(e){ |
| 501 | if(P.finfo){ |
| 502 | const stashed = P.getStashedFinfo(P.finfo); |
| 503 | P.clearStash(); |
| 504 | if(stashed) P.loadFile(/*reload after discarding edits*/); |
| 505 | }else{ |
| 506 | P.clearStash(); |
| 507 | } |
| 508 | }, |
| 509 | ticks: F.config.confirmerButtonTicks |
| 510 | }); |
| 511 | D.addClass(this.e.btnClear,'hidden' /* must not be set until after confirmer is set up!*/); |
| 512 | $stash._fireStashEvent(/*read the page-load-time stash*/); |
| 513 | delete this.init; |
| 514 | }, |
| 515 | /** |
| 516 | Regenerates the edit selection list. |
| @@ -726,10 +737,11 @@ | |
| 737 | ); |
| 738 | P.e.btnCommit.addEventListener( |
| 739 | "click",(e)=>P.commit(), false |
| 740 | ); |
| 741 | F.confirmer(P.e.btnReload, { |
| 742 | pinSize: true, |
| 743 | confirmText: "Really reload, losing edits?", |
| 744 | onconfirm: (e)=>P.unstashContent().loadFile(), |
| 745 | ticks: F.config.confirmerButtonTicks |
| 746 | }); |
| 747 | E('#comment-toggle').addEventListener( |
| 748 |