mirror of
https://github.com/plankanban/planka.git
synced 2025-12-19 17:23:27 +03:00
feat: Add ability to move lists between boards (#1208)
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user