Fossil SCM
Fix editing of a thread title in the new editor.
Commit
14abbc4d469c18eb2908bc1465789c33947b13f34144de89a4a94f4f32a28095
Parent
344c64e271a752b…
1 file changed
+28
-17
+28
-17
| --- src/fossil.page.forumpost.js | ||
| +++ src/fossil.page.forumpost.js | ||
| @@ -98,11 +98,11 @@ | ||
| 98 | 98 | if( this.#draft ){ |
| 99 | 99 | e.title.addEventListener('blur', ()=>{ |
| 100 | 100 | this.#draft.title = e.title.value; |
| 101 | 101 | this.#storeDraft(); |
| 102 | 102 | }); |
| 103 | - e.title.value = opt.edit?.H || this.#draft.title || ''; | |
| 103 | + e.title.value = this.#draft.title || opt.edit?.H || ''; | |
| 104 | 104 | }else if( opt.edit?.H ){ |
| 105 | 105 | e.title.value = opt.edit.H; |
| 106 | 106 | } |
| 107 | 107 | wrapper.append(e.titleBar); |
| 108 | 108 | } |
| @@ -492,11 +492,11 @@ | ||
| 492 | 492 | fd.append(f.name, f.value); |
| 493 | 493 | } |
| 494 | 494 | let v; |
| 495 | 495 | if( this.#opt.inReplyTo ){ |
| 496 | 496 | fd.append( 'firt', this.#opt.inReplyTo ); |
| 497 | - }else if( (v = this.#e.title?.trim?.() ?? this.#opt.edit?.H) ){ | |
| 497 | + }else if( (v = (this.#e.title?.value?.trim?.() || this.#opt.edit?.H)) ){ | |
| 498 | 498 | fd.append('title', v); |
| 499 | 499 | } |
| 500 | 500 | fd.append('mimetype', this.mimetype); |
| 501 | 501 | fd.append('content', addThisContent || this.editorContent.trim()); |
| 502 | 502 | if( this.#e.captcha ){ |
| @@ -958,31 +958,43 @@ | ||
| 958 | 958 | a Cancel button. |
| 959 | 959 | |
| 960 | 960 | - When cancelled or submitted, restore the reply button and |
| 961 | 961 | ePost position. |
| 962 | 962 | */ |
| 963 | - restoreEditReplyElement(ePost, eBtnReply, eToDisable); | |
| 963 | + fetchPost(fpid) | |
| 964 | + .then(artifact=>{ | |
| 965 | + const ondone = (fpe)=>{ | |
| 966 | + restoreEditReplyElement(ePost, eBtnReply, eToDisable); | |
| 967 | + //console.debug("ondiscard/onsubmit", fpe, eToDisable); | |
| 968 | + if( fpe/*onsubmit*/ ){ | |
| 969 | + if( fpe.widget.parentNode ){ | |
| 970 | + fpe.widget.remove(); | |
| 971 | + } | |
| 972 | + } | |
| 973 | + }; | |
| 974 | + const fpe = new F.ForumPostEditor({ | |
| 975 | + hiddenFields: form.querySelectorAll('input[type=hidden]'), | |
| 976 | + ondiscard: ondone, | |
| 977 | + onsubmit: ondone, | |
| 978 | + draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), | |
| 979 | + hideTitle: true/*fixme: only show if this is the root post*/, | |
| 980 | + edit: artifact, | |
| 981 | + inReplyTo: firt | |
| 982 | + }); | |
| 983 | + const w = fpe.widget; | |
| 984 | + w.style.borderTop = '2px dotted'; | |
| 985 | + /* Adding an "Editing..." <h3> here adds way too much space */ | |
| 986 | + ePost.append(w); | |
| 987 | + w.scrollIntoView(); | |
| 988 | + }); | |
| 964 | 989 | }/*replyClicked()*/; |
| 965 | 990 | |
| 966 | 991 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 967 | 992 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 968 | 993 | const firt = ePost.dataset.firt; |
| 969 | 994 | const fEditHead = ePost.dataset.fedithead; |
| 970 | 995 | eBtnEdit.innerText = "Editing..."; |
| 971 | - /* | |
| 972 | - TODOs include: | |
| 973 | - | |
| 974 | - - Disable editButton. | |
| 975 | - | |
| 976 | - - Shift ePost to the left edge. | |
| 977 | - | |
| 978 | - - Pop up a ForumPostEditor immediately under ePost. It needs | |
| 979 | - a Cancel button. | |
| 980 | - | |
| 981 | - - When cancelled or submitted, restore the edit button and | |
| 982 | - ePost position. | |
| 983 | - */ | |
| 984 | 996 | fetchPost(fpid) |
| 985 | 997 | .then(artifact=>{ |
| 986 | 998 | const ondone = (fpe)=>{ |
| 987 | 999 | restoreEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 988 | 1000 | //console.debug("ondiscard/onsubmit", fpe, eToDisable); |
| @@ -999,11 +1011,10 @@ | ||
| 999 | 1011 | const fpe = new F.ForumPostEditor({ |
| 1000 | 1012 | hiddenFields: form.querySelectorAll('input[type=hidden]'), |
| 1001 | 1013 | ondiscard: ondone, |
| 1002 | 1014 | onsubmit: ondone, |
| 1003 | 1015 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1004 | - hideTitle: true/*fixme: only show if this is the root post*/, | |
| 1005 | 1016 | edit: artifact, |
| 1006 | 1017 | status: eStatusSelect?.value, |
| 1007 | 1018 | inReplyTo: firt |
| 1008 | 1019 | }); |
| 1009 | 1020 | const w = fpe.widget; |
| 1010 | 1021 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -98,11 +98,11 @@ | |
| 98 | if( this.#draft ){ |
| 99 | e.title.addEventListener('blur', ()=>{ |
| 100 | this.#draft.title = e.title.value; |
| 101 | this.#storeDraft(); |
| 102 | }); |
| 103 | e.title.value = opt.edit?.H || this.#draft.title || ''; |
| 104 | }else if( opt.edit?.H ){ |
| 105 | e.title.value = opt.edit.H; |
| 106 | } |
| 107 | wrapper.append(e.titleBar); |
| 108 | } |
| @@ -492,11 +492,11 @@ | |
| 492 | fd.append(f.name, f.value); |
| 493 | } |
| 494 | let v; |
| 495 | if( this.#opt.inReplyTo ){ |
| 496 | fd.append( 'firt', this.#opt.inReplyTo ); |
| 497 | }else if( (v = this.#e.title?.trim?.() ?? this.#opt.edit?.H) ){ |
| 498 | fd.append('title', v); |
| 499 | } |
| 500 | fd.append('mimetype', this.mimetype); |
| 501 | fd.append('content', addThisContent || this.editorContent.trim()); |
| 502 | if( this.#e.captcha ){ |
| @@ -958,31 +958,43 @@ | |
| 958 | a Cancel button. |
| 959 | |
| 960 | - When cancelled or submitted, restore the reply button and |
| 961 | ePost position. |
| 962 | */ |
| 963 | restoreEditReplyElement(ePost, eBtnReply, eToDisable); |
| 964 | }/*replyClicked()*/; |
| 965 | |
| 966 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 967 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 968 | const firt = ePost.dataset.firt; |
| 969 | const fEditHead = ePost.dataset.fedithead; |
| 970 | eBtnEdit.innerText = "Editing..."; |
| 971 | /* |
| 972 | TODOs include: |
| 973 | |
| 974 | - Disable editButton. |
| 975 | |
| 976 | - Shift ePost to the left edge. |
| 977 | |
| 978 | - Pop up a ForumPostEditor immediately under ePost. It needs |
| 979 | a Cancel button. |
| 980 | |
| 981 | - When cancelled or submitted, restore the edit button and |
| 982 | ePost position. |
| 983 | */ |
| 984 | fetchPost(fpid) |
| 985 | .then(artifact=>{ |
| 986 | const ondone = (fpe)=>{ |
| 987 | restoreEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 988 | //console.debug("ondiscard/onsubmit", fpe, eToDisable); |
| @@ -999,11 +1011,10 @@ | |
| 999 | const fpe = new F.ForumPostEditor({ |
| 1000 | hiddenFields: form.querySelectorAll('input[type=hidden]'), |
| 1001 | ondiscard: ondone, |
| 1002 | onsubmit: ondone, |
| 1003 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1004 | hideTitle: true/*fixme: only show if this is the root post*/, |
| 1005 | edit: artifact, |
| 1006 | status: eStatusSelect?.value, |
| 1007 | inReplyTo: firt |
| 1008 | }); |
| 1009 | const w = fpe.widget; |
| 1010 |
| --- src/fossil.page.forumpost.js | |
| +++ src/fossil.page.forumpost.js | |
| @@ -98,11 +98,11 @@ | |
| 98 | if( this.#draft ){ |
| 99 | e.title.addEventListener('blur', ()=>{ |
| 100 | this.#draft.title = e.title.value; |
| 101 | this.#storeDraft(); |
| 102 | }); |
| 103 | e.title.value = this.#draft.title || opt.edit?.H || ''; |
| 104 | }else if( opt.edit?.H ){ |
| 105 | e.title.value = opt.edit.H; |
| 106 | } |
| 107 | wrapper.append(e.titleBar); |
| 108 | } |
| @@ -492,11 +492,11 @@ | |
| 492 | fd.append(f.name, f.value); |
| 493 | } |
| 494 | let v; |
| 495 | if( this.#opt.inReplyTo ){ |
| 496 | fd.append( 'firt', this.#opt.inReplyTo ); |
| 497 | }else if( (v = (this.#e.title?.value?.trim?.() || this.#opt.edit?.H)) ){ |
| 498 | fd.append('title', v); |
| 499 | } |
| 500 | fd.append('mimetype', this.mimetype); |
| 501 | fd.append('content', addThisContent || this.editorContent.trim()); |
| 502 | if( this.#e.captcha ){ |
| @@ -958,31 +958,43 @@ | |
| 958 | a Cancel button. |
| 959 | |
| 960 | - When cancelled or submitted, restore the reply button and |
| 961 | ePost position. |
| 962 | */ |
| 963 | fetchPost(fpid) |
| 964 | .then(artifact=>{ |
| 965 | const ondone = (fpe)=>{ |
| 966 | restoreEditReplyElement(ePost, eBtnReply, eToDisable); |
| 967 | //console.debug("ondiscard/onsubmit", fpe, eToDisable); |
| 968 | if( fpe/*onsubmit*/ ){ |
| 969 | if( fpe.widget.parentNode ){ |
| 970 | fpe.widget.remove(); |
| 971 | } |
| 972 | } |
| 973 | }; |
| 974 | const fpe = new F.ForumPostEditor({ |
| 975 | hiddenFields: form.querySelectorAll('input[type=hidden]'), |
| 976 | ondiscard: ondone, |
| 977 | onsubmit: ondone, |
| 978 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 979 | hideTitle: true/*fixme: only show if this is the root post*/, |
| 980 | edit: artifact, |
| 981 | inReplyTo: firt |
| 982 | }); |
| 983 | const w = fpe.widget; |
| 984 | w.style.borderTop = '2px dotted'; |
| 985 | /* Adding an "Editing..." <h3> here adds way too much space */ |
| 986 | ePost.append(w); |
| 987 | w.scrollIntoView(); |
| 988 | }); |
| 989 | }/*replyClicked()*/; |
| 990 | |
| 991 | const editClicked = (form, ePost, eBtnEdit, eToDisable)=>{ |
| 992 | const fpid = setupEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 993 | const firt = ePost.dataset.firt; |
| 994 | const fEditHead = ePost.dataset.fedithead; |
| 995 | eBtnEdit.innerText = "Editing..."; |
| 996 | fetchPost(fpid) |
| 997 | .then(artifact=>{ |
| 998 | const ondone = (fpe)=>{ |
| 999 | restoreEditReplyElement(ePost, eBtnEdit, eToDisable); |
| 1000 | //console.debug("ondiscard/onsubmit", fpe, eToDisable); |
| @@ -999,11 +1011,10 @@ | |
| 1011 | const fpe = new F.ForumPostEditor({ |
| 1012 | hiddenFields: form.querySelectorAll('input[type=hidden]'), |
| 1013 | ondiscard: ondone, |
| 1014 | onsubmit: ondone, |
| 1015 | draftKey: 'draft-forumedit-'+(fEditHead || fpid).substr(0,12), |
| 1016 | edit: artifact, |
| 1017 | status: eStatusSelect?.value, |
| 1018 | inReplyTo: firt |
| 1019 | }); |
| 1020 | const w = fpe.widget; |
| 1021 |