From 29f65be1e008e7106253f3c8cb8d751079696e45 Mon Sep 17 00:00:00 2001 From: nztqa Date: Sat, 1 Jul 2017 23:03:54 +0900 Subject: Add check to see if input is empty --- client/components/cards/checklists.jade | 2 +- client/components/cards/checklists.js | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index c59b6307..d04a9b60 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -4,7 +4,7 @@ template(name="checklists") each checklist in currentCard.checklists +checklistDetail(checklist = checklist) if canModifyCard - +inlinedForm(classNames="js-add-checklist" cardId = cardId) + +inlinedForm(autoclose=false classNames="js-add-checklist" cardId = cardId) +addChecklistItemForm else a.js-open-inlined-form diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index 93bf0c19..24a78035 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -4,13 +4,18 @@ BlazeComponent.extendComponent({ const textarea = this.find('textarea.js-add-checklist-item'); const title = textarea.value.trim(); const cardId = this.currentData().cardId; - Checklists.insert({ - cardId, - title, - }); - setTimeout(() => { - this.$('.add-checklist-item').last().click(); - }, 100); + + if (title) { + Checklists.insert({ + cardId, + title, + }); + setTimeout(() => { + this.$('.add-checklist-item').last().click(); + }, 100); + } + textarea.value = ''; + textarea.focus(); }, addChecklistItem(event) { @@ -18,8 +23,10 @@ BlazeComponent.extendComponent({ const textarea = this.find('textarea.js-add-checklist-item'); const title = textarea.value.trim(); const checklist = this.currentData().checklist; - checklist.addItem(title); + if (title) { + checklist.addItem(title); + } // We keep the form opened, empty it. textarea.value = ''; textarea.focus(); -- cgit v1.2.3-1-g7c22