mirror of
https://github.com/plankanban/planka.git
synced 2025-12-16 09:13:18 +03:00
ref: Remove board types, refactoring
This commit is contained in:
@@ -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,
|
||||
},
|
||||
board: {
|
||||
@@ -29,15 +31,17 @@ module.exports = {
|
||||
},
|
||||
|
||||
async fn(inputs) {
|
||||
if (!_.isUndefined(inputs.values.position)) {
|
||||
const { values } = inputs;
|
||||
|
||||
if (!_.isUndefined(values.position)) {
|
||||
const tasks = await sails.helpers.cards.getTasks(inputs.record.cardId, inputs.record.id);
|
||||
|
||||
const { position, repositions } = sails.helpers.utils.insertToPositionables(
|
||||
inputs.values.position,
|
||||
values.position,
|
||||
tasks,
|
||||
);
|
||||
|
||||
inputs.values.position = position; // eslint-disable-line no-param-reassign
|
||||
values.position = position;
|
||||
|
||||
repositions.forEach(async ({ id, position: nextPosition }) => {
|
||||
await Task.update({
|
||||
@@ -56,7 +60,7 @@ module.exports = {
|
||||
});
|
||||
}
|
||||
|
||||
const task = await Task.updateOne(inputs.record.id).set(inputs.values);
|
||||
const task = await Task.updateOne(inputs.record.id).set({ ...values });
|
||||
|
||||
if (task) {
|
||||
sails.sockets.broadcast(
|
||||
|
||||
Reference in New Issue
Block a user