mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
Get rid of old implementation for substacks
This commit is contained in:
parent
cd36194477
commit
4ac6a507cd
7 changed files with 29 additions and 177 deletions
|
|
@ -136,7 +136,7 @@ BlazeComponent.extendComponent({
|
||||||
|
|
||||||
Subtasks.update(subtask._id, {
|
Subtasks.update(subtask._id, {
|
||||||
$set: {
|
$set: {
|
||||||
sort: sortIndex.base,
|
subtaskSort: sortIndex.base,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -449,13 +449,13 @@ Template.copyCardPopup.events({
|
||||||
});
|
});
|
||||||
|
|
||||||
// copy subtasks
|
// copy subtasks
|
||||||
cursor = Subtasks.find({cardId: oldId});
|
cursor = Cards.find({parentId: oldId});
|
||||||
cursor.forEach(function() {
|
cursor.forEach(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
const subtask = arguments[0];
|
const subtask = arguments[0];
|
||||||
subtask.cardId = _id;
|
subtask.parentId = _id;
|
||||||
subtask._id = null;
|
subtask._id = null;
|
||||||
/* const newSubtaskId = */ Subtasks.insert(subtask);
|
/* const newSubtaskId = */ Cards.insert(subtask);
|
||||||
});
|
});
|
||||||
|
|
||||||
// copy card comments
|
// copy card comments
|
||||||
|
|
@ -509,13 +509,13 @@ Template.copyChecklistToManyCardsPopup.events({
|
||||||
});
|
});
|
||||||
|
|
||||||
// copy subtasks
|
// copy subtasks
|
||||||
cursor = Subtasks.find({cardId: oldId});
|
cursor = Cards.find({parentId: oldId});
|
||||||
cursor.forEach(function() {
|
cursor.forEach(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
const subtask = arguments[0];
|
const subtask = arguments[0];
|
||||||
subtask.cardId = _id;
|
subtask.parentId = _id;
|
||||||
subtask._id = null;
|
subtask._id = null;
|
||||||
/* const newSubtaskId = */ Subtasks.insert(subtask);
|
/* const newSubtaskId = */ Cards.insert(subtask);
|
||||||
});
|
});
|
||||||
|
|
||||||
// copy card comments
|
// copy card comments
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ Activities.helpers({
|
||||||
return ChecklistItems.findOne(this.checklistItemId);
|
return ChecklistItems.findOne(this.checklistItemId);
|
||||||
},
|
},
|
||||||
subtasks() {
|
subtasks() {
|
||||||
return Subtasks.findOne(this.subtaskId);
|
return Cards.findOne(this.subtaskId);
|
||||||
},
|
},
|
||||||
customField() {
|
customField() {
|
||||||
return CustomFields.findOne(this.customFieldId);
|
return CustomFields.findOne(this.customFieldId);
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,12 @@ Cards.attachSchema(new SimpleSchema({
|
||||||
type: Number,
|
type: Number,
|
||||||
decimal: true,
|
decimal: true,
|
||||||
},
|
},
|
||||||
|
subtaskSort: {
|
||||||
|
type: Number,
|
||||||
|
decimal: true,
|
||||||
|
defaultValue: -1,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Cards.allow({
|
Cards.allow({
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ class Exporter {
|
||||||
result.cards.forEach((card) => {
|
result.cards.forEach((card) => {
|
||||||
result.checklists.push(...Checklists.find({ cardId: card._id }).fetch());
|
result.checklists.push(...Checklists.find({ cardId: card._id }).fetch());
|
||||||
result.checklistItems.push(...ChecklistItems.find({ cardId: card._id }).fetch());
|
result.checklistItems.push(...ChecklistItems.find({ cardId: card._id }).fetch());
|
||||||
result.subtaskItems.push(...Subtasks.find({ cardId: card._id }).fetch());
|
result.subtaskItems.push(...Cards.find({ parentid: card._id }).fetch());
|
||||||
});
|
});
|
||||||
|
|
||||||
// [Old] for attachments we only export IDs and absolute url to original doc
|
// [Old] for attachments we only export IDs and absolute url to original doc
|
||||||
|
|
|
||||||
|
|
@ -1,167 +0,0 @@
|
||||||
Subtasks = new Mongo.Collection('subtasks');
|
|
||||||
|
|
||||||
Subtasks.attachSchema(new SimpleSchema({
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
startAt: { // this is a predicted time
|
|
||||||
type: Date,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
endAt: { // this is a predicted time
|
|
||||||
type: Date,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
finishedAt: { // The date & time when it is marked as being done
|
|
||||||
type: Date,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
createdAt: {
|
|
||||||
type: Date,
|
|
||||||
denyUpdate: false,
|
|
||||||
autoValue() { // eslint-disable-line consistent-return
|
|
||||||
if (this.isInsert) {
|
|
||||||
return new Date();
|
|
||||||
} else {
|
|
||||||
this.unset();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
sort: {
|
|
||||||
type: Number,
|
|
||||||
decimal: true,
|
|
||||||
},
|
|
||||||
isFinished: {
|
|
||||||
type: Boolean,
|
|
||||||
defaultValue: false,
|
|
||||||
},
|
|
||||||
cardId: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
Subtasks.helpers({
|
|
||||||
// ...
|
|
||||||
});
|
|
||||||
|
|
||||||
Subtasks.allow({
|
|
||||||
insert(userId, doc) {
|
|
||||||
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId));
|
|
||||||
},
|
|
||||||
update(userId, doc) {
|
|
||||||
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId));
|
|
||||||
},
|
|
||||||
remove(userId, doc) {
|
|
||||||
return allowIsBoardMemberByCard(userId, Cards.findOne(doc.cardId));
|
|
||||||
},
|
|
||||||
fetch: ['userId', 'cardId'],
|
|
||||||
});
|
|
||||||
|
|
||||||
Subtasks.before.insert((userId, doc) => {
|
|
||||||
doc.createdAt = new Date();
|
|
||||||
if (!doc.userId) {
|
|
||||||
doc.userId = userId;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mutations
|
|
||||||
Subtasks.mutations({
|
|
||||||
setTitle(title) {
|
|
||||||
return { $set: { title } };
|
|
||||||
},
|
|
||||||
toggleItem() {
|
|
||||||
return { $set: { isFinished: !this.isFinished } };
|
|
||||||
},
|
|
||||||
move(sortIndex) {
|
|
||||||
const mutatedFields = {
|
|
||||||
sort: sortIndex,
|
|
||||||
};
|
|
||||||
|
|
||||||
return {$set: mutatedFields};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Activities helper
|
|
||||||
function itemCreation(userId, doc) {
|
|
||||||
const card = Cards.findOne(doc.cardId);
|
|
||||||
const boardId = card.boardId;
|
|
||||||
Activities.insert({
|
|
||||||
userId,
|
|
||||||
activityType: 'addSubtaskItem',
|
|
||||||
cardId: doc.cardId,
|
|
||||||
boardId,
|
|
||||||
subtaskItemId: doc._id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function itemRemover(userId, doc) {
|
|
||||||
Activities.remove({
|
|
||||||
subtaskItemId: doc._id,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Activities
|
|
||||||
if (Meteor.isServer) {
|
|
||||||
Meteor.startup(() => {
|
|
||||||
Subtasks._collection._ensureIndex({ cardId: 1 });
|
|
||||||
});
|
|
||||||
|
|
||||||
Subtasks.after.insert((userId, doc) => {
|
|
||||||
itemCreation(userId, doc);
|
|
||||||
});
|
|
||||||
|
|
||||||
Subtasks.after.remove((userId, doc) => {
|
|
||||||
itemRemover(userId, doc);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// APIs
|
|
||||||
if (Meteor.isServer) {
|
|
||||||
JsonRoutes.add('GET', '/api/boards/:boardId/cards/:cardId/subtasks/:itemId', function (req, res) {
|
|
||||||
Authentication.checkUserId( req.userId);
|
|
||||||
const paramItemId = req.params.itemId;
|
|
||||||
const subtaskItem = Subtasks.findOne({ _id: paramItemId });
|
|
||||||
if (subtaskItem) {
|
|
||||||
JsonRoutes.sendResult(res, {
|
|
||||||
code: 200,
|
|
||||||
data: subtaskItem,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
JsonRoutes.sendResult(res, {
|
|
||||||
code: 500,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JsonRoutes.add('PUT', '/api/boards/:boardId/cards/:cardId/subtasks/:itemId', function (req, res) {
|
|
||||||
Authentication.checkUserId( req.userId);
|
|
||||||
|
|
||||||
const paramItemId = req.params.itemId;
|
|
||||||
|
|
||||||
if (req.body.hasOwnProperty('isFinished')) {
|
|
||||||
Subtasks.direct.update({_id: paramItemId}, {$set: {isFinished: req.body.isFinished}});
|
|
||||||
}
|
|
||||||
if (req.body.hasOwnProperty('title')) {
|
|
||||||
Subtasks.direct.update({_id: paramItemId}, {$set: {title: req.body.title}});
|
|
||||||
}
|
|
||||||
|
|
||||||
JsonRoutes.sendResult(res, {
|
|
||||||
code: 200,
|
|
||||||
data: {
|
|
||||||
_id: paramItemId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
JsonRoutes.add('DELETE', '/api/boards/:boardId/cards/:cardId/subtasks/:itemId', function (req, res) {
|
|
||||||
Authentication.checkUserId( req.userId);
|
|
||||||
const paramItemId = req.params.itemId;
|
|
||||||
Subtasks.direct.remove({ _id: paramItemId });
|
|
||||||
JsonRoutes.sendResult(res, {
|
|
||||||
code: 200,
|
|
||||||
data: {
|
|
||||||
_id: paramItemId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -282,3 +282,16 @@ Migrations.add('add-subtasks-boards', () => {
|
||||||
},
|
},
|
||||||
}, noValidateMulti);
|
}, noValidateMulti);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Migrations.add('add-subtasks-sort', () => {
|
||||||
|
Boards.update({
|
||||||
|
subtaskSort: {
|
||||||
|
$exists: false,
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
$set: {
|
||||||
|
subtaskSort: -1,
|
||||||
|
},
|
||||||
|
}, noValidateMulti);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ Meteor.publishRelations('board', function(boardId) {
|
||||||
this.cursor(Attachments.find({ cardId }));
|
this.cursor(Attachments.find({ cardId }));
|
||||||
this.cursor(Checklists.find({ cardId }));
|
this.cursor(Checklists.find({ cardId }));
|
||||||
this.cursor(ChecklistItems.find({ cardId }));
|
this.cursor(ChecklistItems.find({ cardId }));
|
||||||
this.cursor(Subtasks.find({ cardId }));
|
this.cursor(Cards.find({ parentId: cardId }));
|
||||||
});
|
});
|
||||||
|
|
||||||
if (board.members) {
|
if (board.members) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue