mirror of
https://github.com/plankanban/planka.git
synced 2025-07-23 15:19:44 +02:00
ref: Remove board types, refactoring
This commit is contained in:
parent
2b131f76c1
commit
6ffa817b53
182 changed files with 1573 additions and 1239 deletions
|
@ -1,3 +1,15 @@
|
|||
const valuesValidator = (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.position) && !_.isFinite(value.position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
|
@ -6,17 +18,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_.isUndefined(value.position) && !_.isFinite(value.position)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -25,23 +27,27 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const managerUserIds = await sails.helpers.projects.getManagerUserIds(inputs.record.projectId);
|
||||
const memberUserIds = await sails.helpers.boards.getMemberUserIds(inputs.record.id);
|
||||
const { values } = inputs;
|
||||
|
||||
const userIds = _.union(managerUserIds, memberUserIds);
|
||||
const projectManagerUserIds = await sails.helpers.projects.getManagerUserIds(
|
||||
inputs.record.projectId,
|
||||
);
|
||||
|
||||
if (!_.isUndefined(inputs.values.position)) {
|
||||
const boardMemberUserIds = await sails.helpers.boards.getMemberUserIds(inputs.record.id);
|
||||
const boardRelatedUserIds = _.union(projectManagerUserIds, boardMemberUserIds);
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const boards = await sails.helpers.projects.getBoards(
|
||||
inputs.record.projectId,
|
||||
inputs.record.id,
|
||||
);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
inputs.values.position,
|
||||
values.position,
|
||||
boards,
|
||||
);
|
||||
|
||||
inputs.values.position = position; // eslint-disable-line no-param-reassign
|
||||
values.position = position;
|
||||
|
||||
repositions.forEach(async ({ id, position: nextPosition }) => {
|
||||
await Board.update({
|
||||
|
@ -51,7 +57,7 @@ module.exports = {
|
|||
position: nextPosition,
|
||||
});
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(`user:${userId}`, 'boardUpdate', {
|
||||
item: {
|
||||
id,
|
||||
|
@ -62,10 +68,10 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
const board = await Board.updateOne(inputs.record.id).set(inputs.values);
|
||||
const board = await Board.updateOne(inputs.record.id).set({ ...values });
|
||||
|
||||
if (board) {
|
||||
userIds.forEach((userId) => {
|
||||
boardRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'boardUpdate',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue