From 18e34b7f79022528493701696f6b54a1fc8d05a5 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Fri, 14 Jan 2022 18:05:19 +0100 Subject: [PATCH 1/4] Add checklist item, added newline becomes new checklist item - Related to #1846 --- client/components/cards/checklists.jade | 3 +++ client/components/cards/checklists.js | 19 +++++++++++++------ client/components/cards/checklists.styl | 4 ++++ i18n/en.i18n.json | 3 ++- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index d387de307..779de0876 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -56,6 +56,9 @@ template(name="addChecklistItemForm") .edit-controls.clearfix button.primary.confirm.js-submit-add-checklist-item-form(type="submit") {{_ 'save'}} a.fa.fa-times-thin.js-close-inlined-form + .material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItem'}}") + input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItem") + label.toggle-label(for="toggleNewlineBecomesNewChecklistItem") template(name="editChecklistItemForm") a.fa.fa-copy(title="{{_ 'copy-text-to-clipboard'}}") diff --git a/client/components/cards/checklists.js b/client/components/cards/checklists.js index fcb404b95..0d5589650 100644 --- a/client/components/cards/checklists.js +++ b/client/components/cards/checklists.js @@ -105,16 +105,23 @@ BlazeComponent.extendComponent({ addChecklistItem(event) { event.preventDefault(); const textarea = this.find('textarea.js-add-checklist-item'); + const newlineBecomesNewChecklistItem = this.find('input#toggleNewlineBecomesNewChecklistItem'); const title = textarea.value.trim(); const checklist = this.currentData().checklist; if (title) { - ChecklistItems.insert({ - title, - checklistId: checklist._id, - cardId: checklist.cardId, - sort: Utils.calculateIndexData(checklist.lastItem()).base, - }); + let checklistItems = [title]; + if (newlineBecomesNewChecklistItem.checked) { + checklistItems = title.split('\n').map(_value => _value.trim()); + } + for (let checklistItem of checklistItems) { + ChecklistItems.insert({ + title: checklistItem, + checklistId: checklist._id, + cardId: checklist.cardId, + sort: Utils.calculateIndexData(checklist.lastItem()).base, + }); + } } // We keep the form opened, empty it. textarea.value = ''; diff --git a/client/components/cards/checklists.styl b/client/components/cards/checklists.styl index b9983e32d..d0e70dc24 100644 --- a/client/components/cards/checklists.styl +++ b/client/components/cards/checklists.styl @@ -143,3 +143,7 @@ textarea.js-add-checklist-item, textarea.js-edit-checklist-item .checklist-details-menu float: right padding: 6px 10px 6px 10px + +.edit-controls + label.toggle-label + margin-left: 6px diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index 39dad5c4b..8a8533952 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -1141,5 +1141,6 @@ "copied": "Copied!", "checklistActionsPopup-title": "Checklist Actions", "moveChecklist": "Move Checklist", - "moveChecklistPopup-title": "Move Checklist" + "moveChecklistPopup-title": "Move Checklist", + "newlineBecomesNewChecklistItem": "Newline becomes new checklist item" } From d9a7950fa41a19cdf3aef06c5e203834c46aed2e Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sat, 15 Jan 2022 11:19:01 +0100 Subject: [PATCH 2/4] Center all elements of checklist-item form - before the save button, X and slider element had a strange layout. The save button was at the bottom, the X and slider at the top of the flex layout --- client/components/cards/checklists.styl | 2 +- client/components/forms/forms.styl | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/client/components/cards/checklists.styl b/client/components/cards/checklists.styl index d0e70dc24..c8ca24f06 100644 --- a/client/components/cards/checklists.styl +++ b/client/components/cards/checklists.styl @@ -146,4 +146,4 @@ textarea.js-add-checklist-item, textarea.js-edit-checklist-item .edit-controls label.toggle-label - margin-left: 6px + margin-left: 2px diff --git a/client/components/forms/forms.styl b/client/components/forms/forms.styl index ce1a5adf1..e26a6cd64 100644 --- a/client/components/forms/forms.styl +++ b/client/components/forms/forms.styl @@ -117,7 +117,6 @@ button display: inline-block font-weight: 700 line-height: 22px - margin: 8px 4px 0 0 padding: 7px 20px text-align: center @@ -226,20 +225,18 @@ textarea .edit-controls, .add-controls display: flex - align-items: baseline - margin-top: 0 + align-items: center + margin-top: 0px button[type=submit] input[type=button] float: left height: 32px - margin-top: -2px - padding-top: 5px - padding-bottom: 5px + margin-bottom: 0px .fa-times-thin font-size: 26px - margin: 3px 4px + margin: 3px 10px // Material Design checkboxes [type="checkbox"]:not(:checked), From 879ab282e171ef1b342c3ace0120e7cbebf80ca3 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Mon, 17 Jan 2022 23:37:20 +0100 Subject: [PATCH 3/4] Adding some space between save button and the next div element --- client/components/forms/forms.styl | 1 + 1 file changed, 1 insertion(+) diff --git a/client/components/forms/forms.styl b/client/components/forms/forms.styl index e26a6cd64..69e470109 100644 --- a/client/components/forms/forms.styl +++ b/client/components/forms/forms.styl @@ -227,6 +227,7 @@ textarea display: flex align-items: center margin-top: 0px + margin-bottom: 12px button[type=submit] input[type=button] From dbb9ddd7d37e5b60d30a3b9edc043f0a0cd79496 Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sat, 15 Jan 2022 11:26:09 +0100 Subject: [PATCH 4/4] Show "newlineBecomesNewChecklistItem" element only at new checklist items - before it was shown at new checklists too --- client/components/cards/checklists.jade | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/client/components/cards/checklists.jade b/client/components/cards/checklists.jade index 779de0876..590b5e2eb 100644 --- a/client/components/cards/checklists.jade +++ b/client/components/cards/checklists.jade @@ -18,7 +18,7 @@ template(name="checklists") if canModifyCard +inlinedForm(autoclose=false classNames="js-add-checklist" cardId = cardId) - +addChecklistItemForm + +addChecklistItemForm(checklist=checklist showNewlineBecomesNewChecklistItem=false) else a.add-checklist.js-open-inlined-form(title="{{_ 'add-checklist'}}") i.fa.fa-plus @@ -56,9 +56,10 @@ template(name="addChecklistItemForm") .edit-controls.clearfix button.primary.confirm.js-submit-add-checklist-item-form(type="submit") {{_ 'save'}} a.fa.fa-times-thin.js-close-inlined-form - .material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItem'}}") - input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItem") - label.toggle-label(for="toggleNewlineBecomesNewChecklistItem") + if showNewlineBecomesNewChecklistItem + .material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItem'}}") + input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItem") + label.toggle-label(for="toggleNewlineBecomesNewChecklistItem") template(name="editChecklistItemForm") a.fa.fa-copy(title="{{_ 'copy-text-to-clipboard'}}") @@ -87,7 +88,7 @@ template(name="checklistItems") +checklistItemDetail(item = item checklist = checklist) if canModifyCard +inlinedForm(autoclose=false classNames="js-add-checklist-item" checklist = checklist) - +addChecklistItemForm + +addChecklistItemForm(checklist=checklist showNewlineBecomesNewChecklistItem=true) else a.add-checklist-item.js-open-inlined-form(title="{{_ 'add-checklist-item'}}") i.fa.fa-plus