wipon card description - prevention of unintentional exit deletesunsaved description

This commit is contained in:
viehlieb 2022-07-11 16:15:40 +02:00
parent aa067b777a
commit b00169d24f
2 changed files with 12 additions and 4 deletions

View file

@ -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) {

View file

@ -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