mirror of
https://github.com/wekan/wekan.git
synced 2025-04-23 05:27:14 -04:00
Add checklist item, added newline becomes new checklist item
- Related to #1846
This commit is contained in:
parent
4abb26f8bc
commit
18e34b7f79
4 changed files with 22 additions and 7 deletions
|
@ -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'}}")
|
||||
|
|
|
@ -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 = '';
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue