mirror of
https://github.com/plankanban/planka.git
synced 2025-07-23 15:19:44 +02:00
parent
ad7fb51cfa
commit
2ee1166747
1557 changed files with 76832 additions and 47042 deletions
104
server/api/helpers/custom-field-groups/create-one-in-board.js
Normal file
104
server/api/helpers/custom-field-groups/create-one-in-board.js
Normal file
|
@ -0,0 +1,104 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
boardMustBeInValues: {},
|
||||
baseCustomFieldGroupOrNameMustBeInValues: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
if (!values.board) {
|
||||
throw 'boardMustBeInValues';
|
||||
}
|
||||
|
||||
if (values.baseCustomFieldGroup) {
|
||||
values.baseCustomFieldGroupId = values.baseCustomFieldGroup.id;
|
||||
} else if (!values.name) {
|
||||
throw 'baseCustomFieldGroupOrNameMustBeInValues';
|
||||
}
|
||||
|
||||
const customFieldGroups = await CustomFieldGroup.qm.getByBoardId(values.board.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
customFieldGroups,
|
||||
);
|
||||
|
||||
if (repositions.length > 0) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await CustomFieldGroup.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
boardId: reposition.record.boardId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
sails.sockets.broadcast(`board:${values.board.id}`, 'customFieldGroupUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.createOne({
|
||||
...values,
|
||||
position,
|
||||
boardId: values.board.id,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`board:${customFieldGroup.boardId}`,
|
||||
'customFieldGroupCreate',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupCreate',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [values.board],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
114
server/api/helpers/custom-field-groups/create-one-in-card.js
Normal file
114
server/api/helpers/custom-field-groups/create-one-in-card.js
Normal file
|
@ -0,0 +1,114 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
values: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
cardMustBeInValues: {},
|
||||
baseCustomFieldGroupOrNameMustBeInValues: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
if (!values.card) {
|
||||
throw 'cardMustBeInValues';
|
||||
}
|
||||
|
||||
if (values.baseCustomFieldGroup) {
|
||||
values.baseCustomFieldGroupId = values.baseCustomFieldGroup.id;
|
||||
} else if (!values.name) {
|
||||
throw 'baseCustomFieldGroupOrNameMustBeInValues';
|
||||
}
|
||||
|
||||
const customFieldGroups = await CustomFieldGroup.qm.getByCardId(values.card.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
customFieldGroups,
|
||||
);
|
||||
|
||||
if (repositions.length > 0) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await CustomFieldGroup.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
cardId: reposition.record.cardId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
sails.sockets.broadcast(`board:${inputs.board.id}`, 'customFieldGroupUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.createOne({
|
||||
...values,
|
||||
position,
|
||||
cardId: values.card.id,
|
||||
});
|
||||
|
||||
sails.sockets.broadcast(
|
||||
`board:${inputs.board.id}`,
|
||||
'customFieldGroupCreate',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupCreate',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [values.card],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
|
@ -0,0 +1,59 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
await sails.helpers.customFieldGroups.deleteRelated(inputs.record);
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.deleteOne(inputs.record.id);
|
||||
|
||||
if (customFieldGroup) {
|
||||
sails.sockets.broadcast(
|
||||
`board:${customFieldGroup.boardId}`,
|
||||
'customFieldGroupDelete',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupDelete',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
69
server/api/helpers/custom-field-groups/delete-one-in-card.js
Normal file
69
server/api/helpers/custom-field-groups/delete-one-in-card.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
await sails.helpers.customFieldGroups.deleteRelated(inputs.record);
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.deleteOne(inputs.record.id);
|
||||
|
||||
if (customFieldGroup) {
|
||||
sails.sockets.broadcast(
|
||||
`board:${inputs.board.id}`,
|
||||
'customFieldGroupDelete',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupDelete',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
32
server/api/helpers/custom-field-groups/delete-related.js
Normal file
32
server/api/helpers/custom-field-groups/delete-related.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
recordOrRecords: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
let customFieldGroupIdOrIds;
|
||||
if (_.isPlainObject(inputs.recordOrRecords)) {
|
||||
({
|
||||
recordOrRecords: { id: customFieldGroupIdOrIds },
|
||||
} = inputs);
|
||||
} else if (_.every(inputs.recordOrRecords, _.isPlainObject)) {
|
||||
customFieldGroupIdOrIds = sails.helpers.utils.mapRecords(inputs.recordOrRecords);
|
||||
}
|
||||
|
||||
await CustomFieldValue.qm.delete({
|
||||
customFieldGroupId: customFieldGroupIdOrIds,
|
||||
});
|
||||
|
||||
await CustomField.qm.delete({
|
||||
customFieldGroupId: customFieldGroupIdOrIds,
|
||||
});
|
||||
},
|
||||
};
|
|
@ -0,0 +1,51 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
id: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
pathNotFound: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const customFieldGroup = await CustomFieldGroup.qm.getOneById(inputs.id);
|
||||
|
||||
if (!customFieldGroup) {
|
||||
throw 'pathNotFound';
|
||||
}
|
||||
|
||||
let pathToProject;
|
||||
if (customFieldGroup.boardId) {
|
||||
pathToProject = await sails.helpers.boards
|
||||
.getPathToProjectById(customFieldGroup.boardId)
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
customFieldGroup,
|
||||
...nodes,
|
||||
},
|
||||
}));
|
||||
} else if (customFieldGroup.cardId) {
|
||||
pathToProject = await sails.helpers.cards
|
||||
.getPathToProjectById(customFieldGroup.cardId)
|
||||
.intercept('pathNotFound', (nodes) => ({
|
||||
pathNotFound: {
|
||||
customFieldGroup,
|
||||
...nodes,
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
return {
|
||||
customFieldGroup,
|
||||
...pathToProject,
|
||||
};
|
||||
},
|
||||
};
|
112
server/api/helpers/custom-field-groups/update-one-in-board.js
Normal file
112
server/api/helpers/custom-field-groups/update-one-in-board.js
Normal file
|
@ -0,0 +1,112 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
nameInValuesMustNotBeNull: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
if (!inputs.record.baseCustomFieldGroupId && _.isNull(values.name)) {
|
||||
throw 'nameInValuesMustNotBeNull';
|
||||
}
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const customFieldGroups = await CustomFieldGroup.qm.getByBoardId(inputs.record.boardId, {
|
||||
exceptIdOrIds: inputs.record.id,
|
||||
});
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
customFieldGroups,
|
||||
);
|
||||
|
||||
values.position = position;
|
||||
|
||||
if (repositions.length > 0) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await CustomFieldGroup.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
boardId: reposition.record.boardId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
sails.sockets.broadcast(`board:${inputs.record.boardId}`, 'customFieldGroupUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.updateOne(inputs.record.id, values);
|
||||
|
||||
if (customFieldGroup) {
|
||||
sails.sockets.broadcast(
|
||||
`board:${customFieldGroup.boardId}`,
|
||||
'customFieldGroupUpdate',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupUpdate',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
},
|
||||
}),
|
||||
buildPrevData: () => ({
|
||||
item: inputs.record,
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
122
server/api/helpers/custom-field-groups/update-one-in-card.js
Normal file
122
server/api/helpers/custom-field-groups/update-one-in-card.js
Normal file
|
@ -0,0 +1,122 @@
|
|||
/*!
|
||||
* Copyright (c) 2024 PLANKA Software GmbH
|
||||
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
required: true,
|
||||
},
|
||||
project: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
board: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
list: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
card: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
actorUser: {
|
||||
type: 'ref',
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
type: 'ref',
|
||||
},
|
||||
},
|
||||
|
||||
exits: {
|
||||
nameInValuesMustNotBeNull: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const { values } = inputs;
|
||||
|
||||
if (!inputs.record.baseCustomFieldGroupId && _.isNull(values.name)) {
|
||||
throw 'nameInValuesMustNotBeNull';
|
||||
}
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const customFieldGroups = await CustomFieldGroup.qm.getByCardId(inputs.record.cardId, {
|
||||
exceptIdOrIds: inputs.record.id,
|
||||
});
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
values.position,
|
||||
customFieldGroups,
|
||||
);
|
||||
|
||||
values.position = position;
|
||||
|
||||
if (repositions.length > 0) {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const reposition of repositions) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
await CustomFieldGroup.qm.updateOne(
|
||||
{
|
||||
id: reposition.record.id,
|
||||
cardId: reposition.record.cardId,
|
||||
},
|
||||
{
|
||||
position: reposition.position,
|
||||
},
|
||||
);
|
||||
|
||||
sails.sockets.broadcast(`board:${inputs.board.id}`, 'customFieldGroupUpdate', {
|
||||
item: {
|
||||
id: reposition.record.id,
|
||||
position: reposition.position,
|
||||
},
|
||||
});
|
||||
|
||||
// TODO: send webhooks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const customFieldGroup = await CustomFieldGroup.qm.updateOne(inputs.record.id, values);
|
||||
|
||||
if (customFieldGroup) {
|
||||
sails.sockets.broadcast(
|
||||
`board:${inputs.board.id}`,
|
||||
'customFieldGroupUpdate',
|
||||
{
|
||||
item: customFieldGroup,
|
||||
},
|
||||
inputs.request,
|
||||
);
|
||||
|
||||
sails.helpers.utils.sendWebhooks.with({
|
||||
event: 'customFieldGroupUpdate',
|
||||
buildData: () => ({
|
||||
item: customFieldGroup,
|
||||
included: {
|
||||
projects: [inputs.project],
|
||||
boards: [inputs.board],
|
||||
lists: [inputs.list],
|
||||
cards: [inputs.card],
|
||||
},
|
||||
}),
|
||||
buildPrevData: () => ({
|
||||
item: inputs.record,
|
||||
}),
|
||||
user: inputs.actorUser,
|
||||
});
|
||||
}
|
||||
|
||||
return customFieldGroup;
|
||||
},
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue