From b00169d24f4033b2a4d532c521010135ae958e88 Mon Sep 17 00:00:00 2001 From: viehlieb Date: Mon, 11 Jul 2022 16:15:40 +0200 Subject: [PATCH] wipon card description - prevention of unintentional exit deletesunsaved description --- client/components/cards/cardDescription.js | 2 -- client/components/cards/cardDetails.js | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/components/cards/cardDescription.js b/client/components/cards/cardDescription.js index cfc366684..34b4a2836 100644 --- a/client/components/cards/cardDescription.js +++ b/client/components/cards/cardDescription.js @@ -26,8 +26,6 @@ BlazeComponent.extendComponent({ // was keydown // extraevent for saving input. buffer of keydown vs buffer time 'keyup form textarea'(evt) { - const description = this.getInput()[0].value; - this.data().setDescription(description); if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) { const submitButton = this.find('button[type=submit]'); if (submitButton) { diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index 322e23a27..dca15c1f5 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -1714,10 +1714,20 @@ BlazeComponent.extendComponent({ EscapeActions.register( 'detailsPane', () => { + currentDescription = document.getElementsByClassName("editor js-new-description-input").item(0) //save description editing on EscapeAction - if (document.getElementsByClassName("editor js-new-description-input").item(0)) + if (currentDescription?.value && !(currentDescription.value === Utils.getCurrentCard().getDescription())) { - Utils.getCurrentCard().setDescription(document.getElementsByClassName("editor js-new-description-input").item(0).value); + console.log("equal?",!(currentDescription === Utils.getCurrentCard().getDescription())); + if (confirm('Are you sure you want to save this thing into the database?')) { + Utils.getCurrentCard().setDescription(document.getElementsByClassName("editor js-new-description-input").item(0).value); + // Save it! + console.log(document.getElementsByClassName("editor js-new-description-input").item(0).value); + console.log("current description",Utils.getCurrentCard().getDescription()); + } else { + // Do nothing! + console.log('Thing was not saved to the database.'); + } } if (Session.get('cardDetailsIsDragging')) { // Reset dragging status as the mouse landed outside the cardDetails template area and this will prevent a mousedown event from firing