1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-22 22:59:44 +02:00

ref: Remove board types, refactoring

This commit is contained in:
Maksim Eltyshev 2022-12-26 21:10:50 +01:00
parent 2b131f76c1
commit 6ffa817b53
182 changed files with 1573 additions and 1239 deletions

View file

@ -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,15 +27,17 @@ module.exports = {
},
async fn(inputs) {
if (!_.isUndefined(inputs.values.position)) {
const { values } = inputs;
if (!_.isUndefined(values.position)) {
const lists = await sails.helpers.boards.getLists(inputs.record.boardId, inputs.record.id);
const { position, repositions } = sails.helpers.utils.insertToPositionables(
inputs.values.position,
values.position,
lists,
);
inputs.values.position = position; // eslint-disable-line no-param-reassign
values.position = position;
repositions.forEach(async ({ id, position: nextPosition }) => {
await List.update({
@ -52,7 +56,7 @@ module.exports = {
});
}
const list = await List.updateOne(inputs.record.id).set(inputs.values);
const list = await List.updateOne(inputs.record.id).set({ ...values });
if (list) {
sails.sockets.broadcast(