ATS-9: update states once template updates (#3496)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov
2023-07-13 10:01:28 +06:00
committed by GitHub
parent f21750a20d
commit 9a7f75c1ed
14 changed files with 203 additions and 67 deletions
@@ -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
})
})
)
}