mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Can add cards as subtasks
This commit is contained in:
parent
adb7f5b2ca
commit
5a023e4315
4 changed files with 92 additions and 5 deletions
|
|
@ -12,13 +12,31 @@ BlazeComponent.extendComponent({
|
||||||
const title = textarea.value.trim();
|
const title = textarea.value.trim();
|
||||||
const cardId = this.currentData().cardId;
|
const cardId = this.currentData().cardId;
|
||||||
const card = Cards.findOne(cardId);
|
const card = Cards.findOne(cardId);
|
||||||
|
const sortIndex = -1;
|
||||||
|
const crtBoard = Boards.findOne(card.boardId);
|
||||||
|
const targetBoard = crtBoard.getDefaultSubtasksBoard();
|
||||||
|
const listId = targetBoard.getDefaultSubtasksListId();
|
||||||
|
const swimlaneId = Swimlanes.findOne({boardId: targetBoard._id})._id;
|
||||||
|
|
||||||
if (title) {
|
if (title) {
|
||||||
Subtasks.insert({
|
const _id = Cards.insert({
|
||||||
cardId,
|
|
||||||
title,
|
title,
|
||||||
sort: card.subtasks().count(),
|
parentId: cardId,
|
||||||
|
members: [],
|
||||||
|
labelIds: [],
|
||||||
|
customFields: [],
|
||||||
|
listId,
|
||||||
|
boardId: targetBoard._id,
|
||||||
|
sort: sortIndex,
|
||||||
|
swimlaneId,
|
||||||
});
|
});
|
||||||
|
// In case the filter is active we need to add the newly inserted card in
|
||||||
|
// the list of exceptions -- cards that are not filtered. Otherwise the
|
||||||
|
// card will disappear instantly.
|
||||||
|
// See https://github.com/wekan/wekan/issues/80
|
||||||
|
Filter.addException(_id);
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.$('.add-subtask-item').last().click();
|
this.$('.add-subtask-item').last().click();
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
@ -34,7 +52,7 @@ BlazeComponent.extendComponent({
|
||||||
deleteSubtask() {
|
deleteSubtask() {
|
||||||
const subtask = this.currentData().subtask;
|
const subtask = this.currentData().subtask;
|
||||||
if (subtask && subtask._id) {
|
if (subtask && subtask._id) {
|
||||||
Subtasks.remove(subtask._id);
|
Cards.remove(subtask._id);
|
||||||
this.toggleDeleteDialog.set(false);
|
this.toggleDeleteDialog.set(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -479,5 +479,7 @@
|
||||||
"board-delete-notice": "Deleting is permanent. You will lose all lists, cards and actions associated with this board.",
|
"board-delete-notice": "Deleting is permanent. You will lose all lists, cards and actions associated with this board.",
|
||||||
"delete-board-confirm-popup": "All lists, cards, labels, and activities will be deleted and you won't be able to recover the board contents. There is no undo.",
|
"delete-board-confirm-popup": "All lists, cards, labels, and activities will be deleted and you won't be able to recover the board contents. There is no undo.",
|
||||||
"boardDeletePopup-title": "Delete Board?",
|
"boardDeletePopup-title": "Delete Board?",
|
||||||
"delete-board": "Delete Board"
|
"delete-board": "Delete Board",
|
||||||
|
"default-subtasks-board": "Subtasks for __board__ board",
|
||||||
|
"default": "Default"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -151,6 +151,16 @@ Boards.attachSchema(new SimpleSchema({
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
subtasksDefaultBoardId: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
defaultValue: null,
|
||||||
|
},
|
||||||
|
subtasksDefaultListId: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
defaultValue: null,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -284,8 +294,52 @@ Boards.helpers({
|
||||||
|
|
||||||
return Cards.find(query, projection);
|
return Cards.find(query, projection);
|
||||||
},
|
},
|
||||||
|
// A board alwasy has another board where it deposits subtasks of thasks
|
||||||
|
// that belong to itself.
|
||||||
|
getDefaultSubtasksBoardId() {
|
||||||
|
if (this.subtasksDefaultBoardId === null) {
|
||||||
|
this.subtasksDefaultBoardId = Boards.insert({
|
||||||
|
title: `^${this.title}^`,
|
||||||
|
permission: this.permission,
|
||||||
|
members: this.members,
|
||||||
|
color: this.color,
|
||||||
|
description: TAPi18n.__('default-subtasks-board', {board: this.title}),
|
||||||
|
});
|
||||||
|
|
||||||
|
Swimlanes.insert({
|
||||||
|
title: TAPi18n.__('default'),
|
||||||
|
boardId: this.subtasksDefaultBoardId,
|
||||||
|
});
|
||||||
|
Boards.update(this._id, {$set: {
|
||||||
|
subtasksDefaultBoardId: this.subtasksDefaultBoardId,
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
return this.subtasksDefaultBoardId;
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultSubtasksBoard() {
|
||||||
|
return Boards.findOne(this.getDefaultSubtasksBoardId());
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultSubtasksListId() {
|
||||||
|
if (this.subtasksDefaultListId === null) {
|
||||||
|
this.subtasksDefaultListId = Lists.insert({
|
||||||
|
title: TAPi18n.__('new'),
|
||||||
|
boardId: this._id,
|
||||||
|
});
|
||||||
|
Boards.update(this._id, {$set: {
|
||||||
|
subtasksDefaultListId: this.subtasksDefaultListId,
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
return this.subtasksDefaultListId;
|
||||||
|
},
|
||||||
|
|
||||||
|
getDefaultSubtasksList() {
|
||||||
|
return Lists.findOne(this.getDefaultSubtasksListId());
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
Boards.mutations({
|
Boards.mutations({
|
||||||
archive() {
|
archive() {
|
||||||
return { $set: { archived: true } };
|
return { $set: { archived: true } };
|
||||||
|
|
|
||||||
|
|
@ -269,3 +269,16 @@ Migrations.add('add-parent-field-to-cards', () => {
|
||||||
},
|
},
|
||||||
}, noValidateMulti);
|
}, noValidateMulti);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Migrations.add('add-subtasks-boards', () => {
|
||||||
|
Boards.update({
|
||||||
|
subtasksDefaultBoardId: {
|
||||||
|
$exists: false,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
subtasksDefaultBoardId: null,
|
||||||
|
subtasksDefaultListId: null,
|
||||||
|
},
|
||||||
|
}, noValidateMulti);
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue