Bläddra i källkod

Merge branch 'nztqa-fix-checklistitem-empty' into devel

Fix: Possible to add empty item to checklist.
Thanks to nztqa ! Closes #1103
Lauri Ojansivu 8 år sedan
förälder
incheckning
4159aa0929
3 ändrade filer med 20 tillägg och 9 borttagningar
  1. 4 0
      CHANGELOG.md
  2. 1 1
      client/components/cards/checklists.jade
  3. 15 8
      client/components/cards/checklists.js

+ 4 - 0
CHANGELOG.md

@@ -7,6 +7,10 @@ This release adds the following new features:
 * [When finished input of checklist item, open new checklist
   item](https://github.com/wekan/wekan/pull/1099).
 
+and fixes the following bugs:
+
+* [Possible to add empty item to checklist](https://github.com/wekan/wekan/pull/1107).
+
 Thanks to GitHub users nztqa and zarnifoulette for their contributions!
 
 # v0.27 2017-06-28 Wekan release

+ 1 - 1
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

+ 15 - 8
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();