diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index 83fc54508..7dbadf5e6 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -62,6 +62,10 @@ template(name="checklistDeletePopup") p {{_ 'confirm-checklist-delete-popup'}} button.js-confirm.negate.full(type="submit") {{_ 'delete'}} +template(name="checklistItemDeletePopup") + p {{_ 'confirm-checklist-delete-popup'}} + button.js-confirm.negate.full(type="submit") {{_ 'delete'}} + template(name="addChecklistItemForm") a(title="{{_ 'copy-text-to-clipboard'}}") span.copied-tooltip {{_ 'copied'}} @@ -95,10 +99,13 @@ template(name="editChecklistItemForm") | ❌ span(title=createdAt) {{ moment createdAt }} if canModifyCard - a.js-delete-checklist-item {{_ "delete"}}... - a.js-convert-checklist-item-to-card - | 📋 - | {{_ 'convertChecklistItemToCardPopup-title'}} + if $eq type 'item' + a.js-delete-checklist-item {{_ "delete"}}... + a.js-convert-checklist-item-to-card + | 📋 + | {{_ 'convertChecklistItemToCardPopup-title'}} + else + a.js-delete-checklist {{_ "delete"}}... template(name="checklistItems") if checklist.items.length diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index 31c913940..1447a0886 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -157,14 +157,6 @@ BlazeComponent.extendComponent({ textarea.focus(); }, - deleteItem() { - const checklist = this.currentData().checklist; - const item = this.currentData().item; - if (checklist && item && item._id) { - ChecklistItems.remove(item._id); - } - }, - editChecklist(event) { event.preventDefault(); const textarea = this.find('textarea.js-edit-checklist-item'); @@ -216,7 +208,25 @@ BlazeComponent.extendComponent({ 'submit .js-add-checklist-item': this.addChecklistItem, 'submit .js-edit-checklist-item': this.editChecklistItem, 'click .js-convert-checklist-item-to-card': Popup.open('convertChecklistItemToCard'), - 'click .js-delete-checklist-item': this.deleteItem, + 'click .js-delete-checklist-item'(event) { + const item = this.currentData().item; + const confirmFunc = Popup.afterConfirm('checklistItemDelete', function () { + if (item && item._id) { + ChecklistItems.remove(item._id); + } + }); + confirmFunc.call(this, event); + }, + 'click .js-delete-checklist'(event) { + const checklist = this.currentData().checklist; + const confirmFunc = Popup.afterConfirm('checklistDelete', function () { + Popup.back(2); + if (checklist && checklist._id) { + Checklists.remove(checklist._id); + } + }); + confirmFunc.call(this, event); + }, 'focus .js-add-checklist-item': this.focusChecklistItem, // add and delete checklist / checklist-item 'click .js-open-inlined-form': this.closeAllInlinedForms, @@ -303,13 +313,16 @@ BlazeComponent.extendComponent({ events() { return [ { - 'click .js-delete-checklist': Popup.afterConfirm('checklistDelete', function () { - Popup.back(2); + 'click .js-delete-checklist'(event) { const checklist = this.data().checklist; - if (checklist && checklist._id) { - Checklists.remove(checklist._id); - } - }), + const confirmFunc = Popup.afterConfirm('checklistDelete', function () { + Popup.back(2); + if (checklist && checklist._id) { + Checklists.remove(checklist._id); + } + }); + confirmFunc.call(this, event); + }, 'click .js-move-checklist': Popup.open('moveChecklist'), 'click .js-copy-checklist': Popup.open('copyChecklist'), 'click .js-hide-checked-checklist-items'(event) { diff --git a/imports/i18n/data/en.i18n.json b/imports/i18n/data/en.i18n.json index 1bd9d162c..550c2fcb4 100644 --- a/imports/i18n/data/en.i18n.json +++ b/imports/i18n/data/en.i18n.json @@ -345,6 +345,7 @@ "confirm-checklist-delete-popup": "Are you sure you want to delete the checklist?", "subtaskDeletePopup-title": "Delete Subtask?", "checklistDeletePopup-title": "Delete Checklist?", + "checklistItemDeletePopup-title": "Delete Checklist Item?", "copy-card-link-to-clipboard": "Copy card link to clipboard", "copy-text-to-clipboard": "Copy text to clipboard", "linkCardPopup-title": "Link Card",