mirror of
https://github.com/plankanban/planka.git
synced 2025-07-19 05:09:43 +02:00
ref: Remove board types, refactoring
This commit is contained in:
parent
d39da61295
commit
5cd025ffb7
182 changed files with 1573 additions and 1239 deletions
|
@ -14,7 +14,9 @@ module.exports = {
|
|||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const project = await Project.create(inputs.values).fetch();
|
||||
const { values } = inputs;
|
||||
|
||||
const project = await Project.create({ ...values }).fetch();
|
||||
|
||||
const projectManager = await ProjectManager.create({
|
||||
projectId: project.id,
|
||||
|
|
|
@ -17,15 +17,15 @@ module.exports = {
|
|||
const project = await Project.archiveOne(inputs.record.id);
|
||||
|
||||
if (project) {
|
||||
const managerUserIds = sails.helpers.utils.mapRecords(projectManagers, 'userId');
|
||||
const projectManagerUserIds = sails.helpers.utils.mapRecords(projectManagers, 'userId');
|
||||
|
||||
const boardIds = await sails.helpers.projects.getBoardIds(project.id);
|
||||
const boardRooms = boardIds.map((boardId) => `board:${boardId}`);
|
||||
|
||||
const memberUserIds = await sails.helpers.boards.getMemberUserIds(boardIds);
|
||||
const userIds = _.union(managerUserIds, memberUserIds);
|
||||
const boardMemberUserIds = await sails.helpers.boards.getMemberUserIds(boardIds);
|
||||
const projectRelatedUserIds = _.union(projectManagerUserIds, boardMemberUserIds);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
projectRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.removeRoomMembersFromRooms(`@user:${userId}`, boardRooms);
|
||||
|
||||
sails.sockets.broadcast(
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
exceptBoardIdOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -1,16 +1,18 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
const managerUserIds = await sails.helpers.projects.getManagerUserIds(inputs.idOrIds);
|
||||
const memberUserIds = await sails.helpers.projects.getBoardMemberUserIds(inputs.idOrIds);
|
||||
const projectManagerUserIds = await sails.helpers.projects.getManagerUserIds(inputs.idOrIds);
|
||||
const boardMemberUserIds = await sails.helpers.projects.getBoardMemberUserIds(inputs.idOrIds);
|
||||
|
||||
return _.union(managerUserIds, memberUserIds);
|
||||
return _.union(projectManagerUserIds, boardMemberUserIds);
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const criteriaValidator = (value) => _.isArray(value) || _.isPlainObject(value);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
criteria: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isArray(value) || _.isPlainObject(value),
|
||||
custom: criteriaValidator,
|
||||
},
|
||||
},
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
const idOrIdsValidator = (value) => _.isString(value) || _.every(value, _.isString);
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
idOrIds: {
|
||||
type: 'json',
|
||||
custom: (value) => _.isString(value) || _.every(value, _.isString),
|
||||
custom: idOrIdsValidator,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,6 +1,22 @@
|
|||
const path = require('path');
|
||||
const rimraf = require('rimraf');
|
||||
|
||||
const valuesValidator = (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.background && !_.isPlainObject(value.background)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.backgroundImage && !_.isPlainObject(value.backgroundImage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
inputs: {
|
||||
record: {
|
||||
|
@ -9,21 +25,7 @@ module.exports = {
|
|||
},
|
||||
values: {
|
||||
type: 'json',
|
||||
custom: (value) => {
|
||||
if (!_.isPlainObject(value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.background && !_.isPlainObject(value.background)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (value.backgroundImage && !_.isPlainObject(value.backgroundImage)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
},
|
||||
custom: valuesValidator,
|
||||
required: true,
|
||||
},
|
||||
request: {
|
||||
|
@ -32,45 +34,46 @@ module.exports = {
|
|||
},
|
||||
|
||||
exits: {
|
||||
backgroundImageMustBeNotNullInValues: {},
|
||||
backgroundImageInValuesMustNotBeNull: {},
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (inputs.values.backgroundImage) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
inputs.values.background = {
|
||||
const { values } = inputs;
|
||||
|
||||
if (values.backgroundImage) {
|
||||
values.background = {
|
||||
type: 'image',
|
||||
};
|
||||
} else if (
|
||||
_.isNull(inputs.values.backgroundImage) &&
|
||||
_.isNull(values.backgroundImage) &&
|
||||
inputs.record.background &&
|
||||
inputs.record.background.type === 'image'
|
||||
) {
|
||||
inputs.values.background = null; // eslint-disable-line no-param-reassign
|
||||
values.background = null;
|
||||
}
|
||||
|
||||
let project;
|
||||
if (inputs.values.background && inputs.values.background.type === 'image') {
|
||||
if (_.isNull(inputs.values.backgroundImage)) {
|
||||
throw 'backgroundImageMustBeNotNullInValues';
|
||||
if (values.background && values.background.type === 'image') {
|
||||
if (_.isNull(values.backgroundImage)) {
|
||||
throw 'backgroundImageInValuesMustNotBeNull';
|
||||
}
|
||||
|
||||
if (_.isUndefined(inputs.values.backgroundImage)) {
|
||||
if (_.isUndefined(values.backgroundImage)) {
|
||||
project = await Project.updateOne({
|
||||
id: inputs.record.id,
|
||||
backgroundImage: {
|
||||
'!=': null,
|
||||
},
|
||||
}).set(inputs.values);
|
||||
}).set({ ...values });
|
||||
|
||||
if (!project) {
|
||||
delete inputs.values.background; // eslint-disable-line no-param-reassign
|
||||
delete values.background;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!project) {
|
||||
project = await Project.updateOne(inputs.record.id).set(inputs.values);
|
||||
project = await Project.updateOne(inputs.record.id).set({ ...values });
|
||||
}
|
||||
|
||||
if (project) {
|
||||
|
@ -91,9 +94,11 @@ module.exports = {
|
|||
}
|
||||
}
|
||||
|
||||
const userIds = await sails.helpers.projects.getManagerAndBoardMemberUserIds(project.id);
|
||||
const projectRelatedUserIds = await sails.helpers.projects.getManagerAndBoardMemberUserIds(
|
||||
project.id,
|
||||
);
|
||||
|
||||
userIds.forEach((userId) => {
|
||||
projectRelatedUserIds.forEach((userId) => {
|
||||
sails.sockets.broadcast(
|
||||
`user:${userId}`,
|
||||
'projectUpdate',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue