mirror of
https://github.com/wekan/wekan.git
synced 2026-02-14 04:04:21 +01:00
Merge pull request #5568 from mfilser/checklist_multiline_insert
Checklist multiline insert (many checklist items at once)
This commit is contained in:
commit
7623c8dcb7
3 changed files with 24 additions and 8 deletions
|
|
@ -73,6 +73,12 @@ template(name="addChecklistItemForm")
|
||||||
.material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItem'}}")
|
.material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItem'}}")
|
||||||
input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItem")
|
input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItem")
|
||||||
label.toggle-label(for="toggleNewlineBecomesNewChecklistItem")
|
label.toggle-label(for="toggleNewlineBecomesNewChecklistItem")
|
||||||
|
| {{_ 'newLineNewItem'}}
|
||||||
|
if $eq position 'top'
|
||||||
|
.material-toggle-switch(title="{{_ 'newlineBecomesNewChecklistItemOriginOrder'}}")
|
||||||
|
input.toggle-switch(type="checkbox" id="toggleNewlineBecomesNewChecklistItemOriginOrder")
|
||||||
|
label.toggle-label(for="toggleNewlineBecomesNewChecklistItemOriginOrder")
|
||||||
|
| {{_ 'originOrder'}}
|
||||||
|
|
||||||
template(name="editChecklistItemForm")
|
template(name="editChecklistItemForm")
|
||||||
a.fa.fa-copy(title="{{_ 'copy-text-to-clipboard'}}")
|
a.fa.fa-copy(title="{{_ 'copy-text-to-clipboard'}}")
|
||||||
|
|
@ -96,7 +102,7 @@ template(name="checklistItems")
|
||||||
if checklist.items.length
|
if checklist.items.length
|
||||||
if canModifyCard
|
if canModifyCard
|
||||||
+inlinedForm(autoclose=false classNames="js-add-checklist-item" checklist = checklist position="top")
|
+inlinedForm(autoclose=false classNames="js-add-checklist-item" checklist = checklist position="top")
|
||||||
+addChecklistItemForm(checklist=checklist showNewlineBecomesNewChecklistItem=true)
|
+addChecklistItemForm(checklist=checklist showNewlineBecomesNewChecklistItem=true position="top")
|
||||||
else
|
else
|
||||||
a.add-checklist-item.js-open-inlined-form(title="{{_ 'add-checklist-item'}}")
|
a.add-checklist-item.js-open-inlined-form(title="{{_ 'add-checklist-item'}}")
|
||||||
i.fa.fa-plus
|
i.fa.fa-plus
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,7 @@ BlazeComponent.extendComponent({
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const textarea = this.find('textarea.js-add-checklist-item');
|
const textarea = this.find('textarea.js-add-checklist-item');
|
||||||
const newlineBecomesNewChecklistItem = this.find('input#toggleNewlineBecomesNewChecklistItem');
|
const newlineBecomesNewChecklistItem = this.find('input#toggleNewlineBecomesNewChecklistItem');
|
||||||
|
const newlineBecomesNewChecklistItemOriginOrder = this.find('input#toggleNewlineBecomesNewChecklistItemOriginOrder');
|
||||||
const title = textarea.value.trim();
|
const title = textarea.value.trim();
|
||||||
const checklist = this.currentData().checklist;
|
const checklist = this.currentData().checklist;
|
||||||
|
|
||||||
|
|
@ -127,22 +128,28 @@ BlazeComponent.extendComponent({
|
||||||
if (newlineBecomesNewChecklistItem.checked) {
|
if (newlineBecomesNewChecklistItem.checked) {
|
||||||
checklistItems = title.split('\n').map(_value => _value.trim());
|
checklistItems = title.split('\n').map(_value => _value.trim());
|
||||||
if (this.currentData().position === 'top') {
|
if (this.currentData().position === 'top') {
|
||||||
checklistItems = checklistItems.reverse();
|
if (newlineBecomesNewChecklistItemOriginOrder.checked === false) {
|
||||||
|
checklistItems = checklistItems.reverse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let addIndex;
|
||||||
|
let sortIndex;
|
||||||
|
if (this.currentData().position === 'top') {
|
||||||
|
sortIndex = Utils.calculateIndexData(null, checklist.firstItem()).base;
|
||||||
|
addIndex = -1;
|
||||||
|
} else {
|
||||||
|
sortIndex = Utils.calculateIndexData(checklist.lastItem(), null).base;
|
||||||
|
addIndex = 1;
|
||||||
|
}
|
||||||
for (let checklistItem of checklistItems) {
|
for (let checklistItem of checklistItems) {
|
||||||
let sortIndex;
|
|
||||||
if (this.currentData().position === 'top') {
|
|
||||||
sortIndex = Utils.calculateIndexData(null, checklist.firstItem()).base;
|
|
||||||
} else {
|
|
||||||
sortIndex = Utils.calculateIndexData(checklist.lastItem(), null).base;
|
|
||||||
}
|
|
||||||
ChecklistItems.insert({
|
ChecklistItems.insert({
|
||||||
title: checklistItem,
|
title: checklistItem,
|
||||||
checklistId: checklist._id,
|
checklistId: checklist._id,
|
||||||
cardId: checklist.cardId,
|
cardId: checklist.cardId,
|
||||||
sort: sortIndex,
|
sort: sortIndex,
|
||||||
});
|
});
|
||||||
|
sortIndex += addIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We keep the form opened, empty it.
|
// We keep the form opened, empty it.
|
||||||
|
|
|
||||||
|
|
@ -1196,6 +1196,9 @@
|
||||||
"moveChecklist": "Move Checklist",
|
"moveChecklist": "Move Checklist",
|
||||||
"moveChecklistPopup-title": "Move Checklist",
|
"moveChecklistPopup-title": "Move Checklist",
|
||||||
"newlineBecomesNewChecklistItem": "Newline becomes new checklist item",
|
"newlineBecomesNewChecklistItem": "Newline becomes new checklist item",
|
||||||
|
"newLineNewItem": "newline = new item",
|
||||||
|
"newlineBecomesNewChecklistItemOriginOrder": "Newline becomes new checklist item, origin order",
|
||||||
|
"originOrder": "origin order",
|
||||||
"copyChecklist": "Copy Checklist",
|
"copyChecklist": "Copy Checklist",
|
||||||
"copyChecklistPopup-title": "Copy Checklist",
|
"copyChecklistPopup-title": "Copy Checklist",
|
||||||
"card-show-lists": "Card Show Lists",
|
"card-show-lists": "Card Show Lists",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue