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:
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,
|
||||
},
|
||||
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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue