mirror of
https://github.com/hcengineering/platform.git
synced 2024-12-23 11:31:57 +03:00
delete status
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
33356bfc61
commit
9ef7399bd6
@ -15,7 +15,7 @@
|
||||
-->
|
||||
|
||||
<script lang="ts">
|
||||
import type { Ref, SpaceWithStates, State } from '@anticrm/core'
|
||||
import type { Ref, SpaceWithStates, State, Class, Obj } from '@anticrm/core'
|
||||
import { CircleButton, IconAdd, Label, IconMoreH, ActionIcon, showPopup, ScrollBox } from '@anticrm/ui'
|
||||
import { createQuery, getClient, AttributeEditor } from '@anticrm/presentation'
|
||||
import type { Kanban } from '@anticrm/view'
|
||||
@ -30,6 +30,7 @@
|
||||
import view from '@anticrm/view'
|
||||
|
||||
export let _id: Ref<SpaceWithStates>
|
||||
export let spaceClass: Ref<Class<Obj>>
|
||||
|
||||
let kanban: Kanban | undefined
|
||||
|
||||
@ -147,7 +148,7 @@
|
||||
<div class="flex-grow caption-color"><AttributeEditor maxWidth="20rem" _class={core.class.State} object={state} key="title"/></div>
|
||||
<div class="tool hover-trans"
|
||||
on:click={(ev) => {
|
||||
showPopup(StatusesPopup, {}, ev.target, (result) => { if (result) console.log('StatusesPopup:', result) })
|
||||
showPopup(StatusesPopup, { state, spaceClass }, ev.target, (result) => { if (result) console.log('StatusesPopup:', result) })
|
||||
}}
|
||||
>
|
||||
<IconMoreH size={'medium'} />
|
||||
|
@ -15,15 +15,48 @@
|
||||
|
||||
<script lang="ts">
|
||||
// import type { IntlString, Asset, Resource } from '@anticrm/platform'
|
||||
import type { Ref, State, Class, Obj } from '@anticrm/core'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Label } from '@anticrm/ui'
|
||||
import { Label, showPopup } from '@anticrm/ui'
|
||||
import { getClient, MessageBox } from '@anticrm/presentation'
|
||||
import Delete from './icons/Delete.svelte'
|
||||
|
||||
import workbench from '@anticrm/workbench'
|
||||
|
||||
export let state: State
|
||||
export let spaceClass: Ref<Class<Obj>>
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
const client = getClient()
|
||||
|
||||
async function deleteState() {
|
||||
const spaceClassInstance = client.getHierarchy().getClass(spaceClass)
|
||||
const view = client.getHierarchy().as(spaceClassInstance, workbench.mixin.SpaceView)
|
||||
const containingClass = view.view.class
|
||||
|
||||
const objectsInThisState = await client.findAll(containingClass, { state: state._id })
|
||||
|
||||
if (objectsInThisState.length > 0) {
|
||||
showPopup(MessageBox, {
|
||||
label: 'Can\'t delete status',
|
||||
message: `There are ${objectsInThisState.length} objects in the given state. Move or delete them first.`
|
||||
})
|
||||
} else {
|
||||
showPopup(MessageBox, {
|
||||
label: 'Delete status',
|
||||
message: 'Do you want to delete this status?'
|
||||
}, undefined, (result) => {
|
||||
if (result) {
|
||||
client.removeDoc(state._class, state.space, state._id)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex-col popup">
|
||||
<div class="flex-row-center red-color menu-item" on:click={() => { dispatch('close', 'delete') }}>
|
||||
<div class="flex-row-center red-color menu-item" on:click={() => { dispatch('close'); deleteState() }}>
|
||||
<div class="icon">
|
||||
<Delete size={'medium'} />
|
||||
</div>
|
||||
|
@ -52,7 +52,7 @@
|
||||
label: 'Edit Statuses' as IntlString,
|
||||
icon: IconAdd,
|
||||
action: async (_id: Ref<Doc>): Promise<void> => {
|
||||
showPopup(EditStatuses, { _id }, 'right')
|
||||
showPopup(EditStatuses, { _id, spaceClass: model.spaceClass }, 'right')
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user