Custom done states (#1238)

This commit is contained in:
Denis Bykhov
2022-03-30 12:35:09 +07:00
committed by GitHub
parent 5f4edc43c0
commit 944cfafcba
11 changed files with 269 additions and 168 deletions
@@ -1,51 +1,47 @@
<!--
// Copyright © 2020, 2021 Anticrm Platform Contributors.
// Copyright © 2021 Hardcore Engineering Inc.
//
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
// import type { Ref, Space, Doc, Class } from '@anticrm/core'
import { getClient, MessageBox } from '@anticrm/presentation'
import { Label, Icon, showPopup, Component } from '@anticrm/ui'
import type { KanbanTemplate, KanbanTemplateSpace, StateTemplate } from '@anticrm/task'
import type { DoneStateTemplate, KanbanTemplate, KanbanTemplateSpace, StateTemplate } from '@anticrm/task'
import setting from '../../plugin'
import task from '@anticrm/task'
import Folders from './Folders.svelte'
import Templates from './Templates.svelte'
// export let objectId: Ref<Doc>
// export let space: Ref<Space>
// export let _class: Ref<Class<Doc>>
let folder: KanbanTemplateSpace | undefined
let template: KanbanTemplate | undefined
const client = getClient()
function deleteState ({ state }: { state: StateTemplate }) {
function deleteState ({ state }: { state: StateTemplate | DoneStateTemplate }) {
if (template === undefined) {
return
}
const hierarchy = client.getHierarchy()
showPopup(MessageBox, {
label: setting.string.DeleteStatus,
message: setting.string.DeleteStatusConfirm
}, undefined, async (result) => {
if (result && template !== undefined) {
await client.updateDoc(template._class, template.space, template._id, { $pull: { states: state._id } })
await client.removeCollection(state._class, template.space, state._id, template._id, template._class, 'statesC')
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)
}
})
}