Pre-fill the title of checklists (Trello-style)

This commit is contained in:
boeserwolf 2020-04-21 00:58:15 +03:00
parent 3407b0e65b
commit 9f0273aa44

View file

@ -1,4 +1,4 @@
const { calculateIndexData, enableClickOnTouch } = Utils; const { calculateIndexData, enableClickOnTouch, capitalize } = Utils;
function initSorting(items) { function initSorting(items) {
items.sortable({ items.sortable({
@ -177,6 +177,16 @@ BlazeComponent.extendComponent({
} }
}, },
focusChecklistItem(event) {
// If a new checklist is created, pre-fill the title and select it.
const checklist = this.currentData().checklist;
if (!checklist) {
const textarea = event.target;
textarea.value = capitalize(TAPi18n.__('r-checklist'));
textarea.select();
}
},
events() { events() {
const events = { const events = {
'click .toggle-delete-checklist-dialog'(event) { 'click .toggle-delete-checklist-dialog'(event) {
@ -196,6 +206,7 @@ BlazeComponent.extendComponent({
'submit .js-edit-checklist-item': this.editChecklistItem, 'submit .js-edit-checklist-item': this.editChecklistItem,
'click .js-delete-checklist-item': this.deleteItem, 'click .js-delete-checklist-item': this.deleteItem,
'click .confirm-checklist-delete': this.deleteChecklist, 'click .confirm-checklist-delete': this.deleteChecklist,
'focus .js-add-checklist-item': this.focusChecklistItem,
keydown: this.pressKey, keydown: this.pressKey,
}, },
]; ];