feat: Add ability to move lists between boards (#1208)

This commit is contained in:
Symon Baikov
2025-09-04 01:07:10 +03:00
committed by GitHub
parent 5f34a737bb
commit 9683227fbc
58 changed files with 950 additions and 263 deletions

View File

@@ -3,7 +3,13 @@
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
*/
const defaultFind = (criteria) => CustomFieldValue.find(criteria).sort('id');
const defaultFind = (criteria, { customFieldGroupIdOrIds }) => {
if (customFieldGroupIdOrIds) {
criteria.customFieldGroupId = customFieldGroupIdOrIds; // eslint-disable-line no-param-reassign
}
return CustomFieldValue.find(criteria).sort('id');
};
/* Query methods */
@@ -41,22 +47,21 @@ const createOrUpdateOne = async (values) => {
const getByIds = (ids) => defaultFind(ids);
const getByCardId = (cardId, { customFieldGroupIdOrIds } = {}) => {
const criteria = {
cardId,
};
const getByCardId = (cardId, { customFieldGroupIdOrIds } = {}) =>
defaultFind(
{
cardId,
},
{ customFieldGroupIdOrIds },
);
if (customFieldGroupIdOrIds) {
criteria.customFieldGroupId = customFieldGroupIdOrIds;
}
return defaultFind(criteria);
};
const getByCardIds = (cardIds) =>
defaultFind({
cardId: cardIds,
});
const getByCardIds = (cardIds, { customFieldGroupIdOrIds } = {}) =>
defaultFind(
{
cardId: cardIds,
},
{ customFieldGroupIdOrIds },
);
const getByCustomFieldGroupId = (customFieldGroupId) =>
defaultFind({

View File

@@ -52,13 +52,13 @@ const getOneTrashByBoardId = (boardId) =>
});
const updateOne = async (criteria, values) => {
if (values.type) {
if (values.boardId || values.type) {
return sails.getDatastore().transaction(async (db) => {
const [whereQuery, whereQueryValues] = buildWhereQuery(criteria);
const queryResult = await sails
.sendNativeQuery(
`SELECT type FROM list WHERE ${whereQuery} LIMIT 1 FOR UPDATE`,
`SELECT board_id, type FROM list WHERE ${whereQuery} LIMIT 1 FOR UPDATE`,
whereQueryValues,
)
.usingConnection(db);
@@ -68,6 +68,7 @@ const updateOne = async (criteria, values) => {
}
const prev = {
boardId: queryResult.rows[0].board_id,
type: queryResult.rows[0].type,
};
@@ -79,6 +80,17 @@ const updateOne = async (criteria, values) => {
let tasks = [];
if (list) {
if (list.boardId !== prev.boardId) {
await Card.update(
{
listId: list.id,
},
{
boardId: list.boardId,
},
).usingConnection(db);
}
const prevTypeState = List.TYPE_STATE_BY_TYPE[prev.type];
const typeState = List.TYPE_STATE_BY_TYPE[list.type];