mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 04:55:03 +02:00
ATS-9: update states once template updates (#3496)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
@@ -32,7 +32,6 @@
|
||||
if (template === undefined) {
|
||||
return
|
||||
}
|
||||
const hierarchy = client.getHierarchy()
|
||||
|
||||
showPopup(
|
||||
MessageBox,
|
||||
@@ -43,15 +42,7 @@
|
||||
undefined,
|
||||
async (result) => {
|
||||
if (result && template !== undefined) {
|
||||
const collection = hierarchy.isDerived(state._class, task.class.DoneStateTemplate) ? 'doneStatesC' : 'statesC'
|
||||
await client.removeCollection(
|
||||
state._class,
|
||||
template.space,
|
||||
state._id,
|
||||
template._id,
|
||||
template._class,
|
||||
collection
|
||||
)
|
||||
await client.removeDoc(state._class, template.space, state._id)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -57,19 +57,13 @@
|
||||
title: 'New Template'
|
||||
})
|
||||
|
||||
await client.addCollection(
|
||||
task.class.StateTemplate,
|
||||
space as Ref<Doc> as Ref<Space>,
|
||||
template,
|
||||
task.class.KanbanTemplate,
|
||||
'statesC',
|
||||
{
|
||||
ofAttribute: task.attribute.State,
|
||||
name: 'New State',
|
||||
color: 9,
|
||||
rank: [...genRanks(1)][0]
|
||||
}
|
||||
)
|
||||
await client.createDoc(task.class.StateTemplate, space as Ref<Doc> as Ref<Space>, {
|
||||
attachedTo: template,
|
||||
ofAttribute: task.attribute.State,
|
||||
name: 'New State',
|
||||
color: 9,
|
||||
rank: [...genRanks(1)][0]
|
||||
})
|
||||
|
||||
const ranks = [...genRanks(2)]
|
||||
const doneStates = [
|
||||
@@ -87,18 +81,12 @@
|
||||
|
||||
await Promise.all(
|
||||
doneStates.map(async (ds) => {
|
||||
await client.addCollection(
|
||||
ds.class,
|
||||
space as Ref<Doc> as Ref<Space>,
|
||||
template,
|
||||
task.class.KanbanTemplate,
|
||||
'doneStatesC',
|
||||
{
|
||||
ofAttribute: task.attribute.DoneState,
|
||||
name: ds.name,
|
||||
rank: ds.rank
|
||||
}
|
||||
)
|
||||
await client.createDoc(ds.class, space as Ref<Doc> as Ref<Space>, {
|
||||
attachedTo: template,
|
||||
ofAttribute: task.attribute.DoneState,
|
||||
name: ds.name,
|
||||
rank: ds.rank
|
||||
})
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user