Fossil SCM
Only show the forum editor's Stash button when saving of drafts is enabled (it currently always is).
Commit
b45242d8fd1e327c23d1b046a40909a6cbc4294040b3332372ec71d15d05f452
Parent
157f5a4c69171c7…
1 file changed
+16
-10
+16
-10
| --- src/fossil.page.forumpost.js | ||
| +++ src/fossil.page.forumpost.js | ||
| @@ -174,19 +174,21 @@ | ||
| 174 | 174 | e.button.submit = D.attr( |
| 175 | 175 | D.button("Submit"), |
| 176 | 176 | 'title', |
| 177 | 177 | 'Save any edits to the server. Not permitted until Preview has been used.' |
| 178 | 178 | ); |
| 179 | - e.button.stash = D.attr( | |
| 180 | - D.button( | |
| 181 | - "Stash", e=>this.close() | |
| 182 | - /* This could be called Close, but that would semantically | |
| 183 | - collide with the Close [this post] button. All "Stash" | |
| 184 | - does is close the widget. */ | |
| 185 | - ), | |
| 186 | - 'title', "Close this editor and stash any edits locally." | |
| 187 | - ); | |
| 179 | + if( this.#draft ){ | |
| 180 | + e.button.stash = D.attr( | |
| 181 | + D.button( | |
| 182 | + "Stash", e=>this.close() | |
| 183 | + /* This could be called Close, but that would semantically | |
| 184 | + collide with the Close [this post] button. All "Stash" | |
| 185 | + does is close the widget. */ | |
| 186 | + ), | |
| 187 | + 'title', "Close this editor and stash any edits locally." | |
| 188 | + ); | |
| 189 | + } | |
| 188 | 190 | if( opt.ondiscard instanceof Function ){ |
| 189 | 191 | e.button.discard = D.attr( |
| 190 | 192 | D.button('Discard'), |
| 191 | 193 | 'title', |
| 192 | 194 | 'Close the editor and discard all local edits.' |
| @@ -325,11 +327,15 @@ | ||
| 325 | 327 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 326 | 328 | this.#tabs.addTab(e.tabAttach); |
| 327 | 329 | /* Reminder: we don't currently have a way to disable/enable |
| 328 | 330 | an Attacher's controls during ajax traffic. */ |
| 329 | 331 | } |
| 330 | - e.buttons.append(e.button.preview, e.button.submit, e.button.stash); | |
| 332 | + e.buttons.append(e.button.preview, e.button.submit); | |
| 333 | + if( e.button.stash ){ | |
| 334 | + e.buttons.append(e.button.stash); | |
| 335 | + this.#toDisable.push(e.button.stash); | |
| 336 | + } | |
| 331 | 337 | if( e.button.discard ){ |
| 332 | 338 | e.buttons.append(e.button.discard); |
| 333 | 339 | this.#toDisable.push(e.button.discard); |
| 334 | 340 | } |
| 335 | 341 | |
| 336 | 342 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -174,19 +174,21 @@ | |
| 174 | e.button.submit = D.attr( |
| 175 | D.button("Submit"), |
| 176 | 'title', |
| 177 | 'Save any edits to the server. Not permitted until Preview has been used.' |
| 178 | ); |
| 179 | e.button.stash = D.attr( |
| 180 | D.button( |
| 181 | "Stash", e=>this.close() |
| 182 | /* This could be called Close, but that would semantically |
| 183 | collide with the Close [this post] button. All "Stash" |
| 184 | does is close the widget. */ |
| 185 | ), |
| 186 | 'title', "Close this editor and stash any edits locally." |
| 187 | ); |
| 188 | if( opt.ondiscard instanceof Function ){ |
| 189 | e.button.discard = D.attr( |
| 190 | D.button('Discard'), |
| 191 | 'title', |
| 192 | 'Close the editor and discard all local edits.' |
| @@ -325,11 +327,15 @@ | |
| 325 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 326 | this.#tabs.addTab(e.tabAttach); |
| 327 | /* Reminder: we don't currently have a way to disable/enable |
| 328 | an Attacher's controls during ajax traffic. */ |
| 329 | } |
| 330 | e.buttons.append(e.button.preview, e.button.submit, e.button.stash); |
| 331 | if( e.button.discard ){ |
| 332 | e.buttons.append(e.button.discard); |
| 333 | this.#toDisable.push(e.button.discard); |
| 334 | } |
| 335 | |
| 336 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -174,19 +174,21 @@ | |
| 174 | e.button.submit = D.attr( |
| 175 | D.button("Submit"), |
| 176 | 'title', |
| 177 | 'Save any edits to the server. Not permitted until Preview has been used.' |
| 178 | ); |
| 179 | if( this.#draft ){ |
| 180 | e.button.stash = D.attr( |
| 181 | D.button( |
| 182 | "Stash", e=>this.close() |
| 183 | /* This could be called Close, but that would semantically |
| 184 | collide with the Close [this post] button. All "Stash" |
| 185 | does is close the widget. */ |
| 186 | ), |
| 187 | 'title', "Close this editor and stash any edits locally." |
| 188 | ); |
| 189 | } |
| 190 | if( opt.ondiscard instanceof Function ){ |
| 191 | e.button.discard = D.attr( |
| 192 | D.button('Discard'), |
| 193 | 'title', |
| 194 | 'Close the editor and discard all local edits.' |
| @@ -325,11 +327,15 @@ | |
| 327 | e.tabAttach.dataset.tabLabel = 'Attachments'; |
| 328 | this.#tabs.addTab(e.tabAttach); |
| 329 | /* Reminder: we don't currently have a way to disable/enable |
| 330 | an Attacher's controls during ajax traffic. */ |
| 331 | } |
| 332 | e.buttons.append(e.button.preview, e.button.submit); |
| 333 | if( e.button.stash ){ |
| 334 | e.buttons.append(e.button.stash); |
| 335 | this.#toDisable.push(e.button.stash); |
| 336 | } |
| 337 | if( e.button.discard ){ |
| 338 | e.buttons.append(e.button.discard); |
| 339 | this.#toDisable.push(e.button.discard); |
| 340 | } |
| 341 | |
| 342 |