mirror of
https://github.com/plankanban/planka.git
synced 2025-07-18 20:59:44 +02:00
Merge ffb9693184
into fdac299fc7
This commit is contained in:
commit
4596b5fbd4
2 changed files with 34 additions and 0 deletions
|
@ -53,6 +53,9 @@ module.exports = {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
custom: isStopwatch,
|
custom: isStopwatch,
|
||||||
},
|
},
|
||||||
|
customFields: {
|
||||||
|
type: 'ref',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
exits: {
|
exits: {
|
||||||
|
@ -96,6 +99,10 @@ module.exports = {
|
||||||
'stopwatch',
|
'stopwatch',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
if (inputs.customFields) {
|
||||||
|
values.customFields = inputs.customFields;
|
||||||
|
}
|
||||||
|
|
||||||
const card = await sails.helpers.cards.createOne
|
const card = await sails.helpers.cards.createOne
|
||||||
.with({
|
.with({
|
||||||
project,
|
project,
|
||||||
|
|
|
@ -79,6 +79,33 @@ module.exports = {
|
||||||
listChangedAt: new Date().toISOString(),
|
listChangedAt: new Date().toISOString(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (values.customFields) {
|
||||||
|
const customFieldGroups = await CustomFieldGroup.qm.getByBoardId(values.board.id);
|
||||||
|
const customFieldGroupMap = _.keyBy(customFieldGroups, 'name');
|
||||||
|
const customFieldGroupIds = customFieldGroups.map((g) => g.id);
|
||||||
|
const customFields = await CustomField.qm.getByCustomFieldGroupIds(customFieldGroupIds);
|
||||||
|
const customFieldMap = _.keyBy(customFields, (f) => `${f.customFieldGroupId}:${f.name}`);
|
||||||
|
|
||||||
|
const createValuePromises = [];
|
||||||
|
Object.entries(values.customFields).forEach(([groupName, fields]) => {
|
||||||
|
const group = customFieldGroupMap[groupName];
|
||||||
|
if (!group) return;
|
||||||
|
Object.entries(fields).forEach(([fieldName, content]) => {
|
||||||
|
const field = customFieldMap[`${group.id}:${fieldName}`];
|
||||||
|
if (!field) return;
|
||||||
|
createValuePromises.push(
|
||||||
|
CustomFieldValue.create({
|
||||||
|
cardId: card.id,
|
||||||
|
customFieldGroupId: group.id,
|
||||||
|
customFieldId: field.id,
|
||||||
|
content: String(content),
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
await Promise.all(createValuePromises);
|
||||||
|
}
|
||||||
|
|
||||||
sails.sockets.broadcast(
|
sails.sockets.broadcast(
|
||||||
`board:${card.boardId}`,
|
`board:${card.boardId}`,
|
||||||
'cardCreate',
|
'cardCreate',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue