1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-18 20:59:44 +02:00

feat: Persist closed state per card

This commit is contained in:
Maksim Eltyshev 2025-07-09 17:45:47 +02:00
parent 69c75a03b1
commit 709a0d1758
19 changed files with 163 additions and 71 deletions

View file

@ -67,6 +67,7 @@ module.exports = {
name: trelloCard.name,
description: trelloCard.desc || null,
dueDate: trelloCard.due,
isClosed: trelloCard.dueComplete,
listChangedAt: new Date().toISOString(),
};

View file

@ -67,6 +67,10 @@ module.exports = {
delete values.position;
}
if (values.list.type === List.Types.CLOSED) {
values.isClosed = true;
}
const card = await Card.qm.createOne({
...values,
boardId: values.board.id,

View file

@ -91,6 +91,7 @@ module.exports = {
'description',
'dueDate',
'stopwatch',
'isClosed',
]),
...values,
creatorUserId: values.creatorUser.id,

View file

@ -378,8 +378,6 @@ module.exports = {
}
if (values.list) {
values.listChangedAt = new Date().toISOString();
if (values.board || inputs.list.type === List.Types.TRASH) {
values.prevListId = null;
} else if (sails.helpers.lists.isArchiveOrTrash(values.list)) {
@ -387,6 +385,16 @@ module.exports = {
} else if (inputs.list.type === List.Types.ARCHIVE) {
values.prevListId = null;
}
if (inputs.record.isClosed) {
if (values.list.type === List.Types.ACTIVE) {
values.isClosed = false;
}
} else if (values.list.type === List.Types.CLOSED) {
values.isClosed = true;
}
values.listChangedAt = new Date().toISOString();
}
card = await Card.qm.updateOne(inputs.record.id, values);

View file

@ -33,6 +33,28 @@ module.exports = {
async fn(inputs) {
const { values } = inputs;
if (values.type) {
let isClosed;
if (values.type === List.Types.CLOSED) {
if (inputs.record.type === List.Types.ACTIVE) {
isClosed = true;
}
} else if (inputs.record.type === List.Types.CLOSED) {
isClosed = false;
}
if (!_.isUndefined(isClosed)) {
await Card.qm.update(
{
listId: inputs.record.id,
},
{
isClosed,
},
);
}
}
if (!_.isUndefined(values.position)) {
const lists = await sails.helpers.boards.getFiniteListsById(
inputs.board.id,

View file

@ -48,6 +48,11 @@ module.exports = {
stopwatch: {
type: 'json',
},
isClosed: {
type: 'boolean',
defaultsTo: false,
columnName: 'is_closed',
},
commentsTotal: {
type: 'number',
defaultsTo: 0,

View file

@ -0,0 +1,28 @@
/*!
* Copyright (c) 2024 PLANKA Software GmbH
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
exports.up = async (knex) => {
await knex.schema.alterTable('card', (table) => {
/* Columns */
table.boolean('is_closed').notNullable().default(false);
});
await knex.raw(`
UPDATE card
SET is_closed = TRUE
FROM list
WHERE card.list_id = list.id AND list.type = 'closed';
`);
return knex.schema.alterTable('card', (table) => {
table.boolean('is_closed').notNullable().alter();
});
};
exports.down = (knex) =>
knex.schema.table('card', (table) => {
table.dropColumn('is_closed');
});