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

@@ -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];