mirror of
https://github.com/hcengineering/platform.git
synced 2025-06-02 13:52:40 +00:00
Fix moving selected issues to team (#2348)
Signed-off-by: Ruslan Bayandinov <wazsone@ya.ru>
This commit is contained in:
parent
81f31c2b54
commit
d52f7ab18b
@ -73,8 +73,8 @@ function Delete (object: Doc): void {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function Move (object: Doc): Promise<void> {
|
async function Move (docs: Doc | Doc[]): Promise<void> {
|
||||||
showPopup(MoveView, { object })
|
showPopup(MoveView, { selected: docs })
|
||||||
}
|
}
|
||||||
|
|
||||||
let $focusStore: FocusSelection
|
let $focusStore: FocusSelection
|
||||||
|
@ -24,7 +24,8 @@
|
|||||||
import task, { Task, calcRank } from '@hcengineering/task'
|
import task, { Task, calcRank } from '@hcengineering/task'
|
||||||
import { getResource, OK, Resource, Status, translate } from '@hcengineering/platform'
|
import { getResource, OK, Resource, Status, translate } from '@hcengineering/platform'
|
||||||
|
|
||||||
export let object: Doc
|
export let selected: Doc | Doc[]
|
||||||
|
$: docs = Array.isArray(selected) ? selected : [selected]
|
||||||
|
|
||||||
let status: Status = OK
|
let status: Status = OK
|
||||||
let currentSpace: Space | undefined
|
let currentSpace: Space | undefined
|
||||||
@ -32,9 +33,15 @@
|
|||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const hierarchy = client.getHierarchy()
|
const hierarchy = client.getHierarchy()
|
||||||
let label = ''
|
let label = ''
|
||||||
|
let space: Ref<Space>
|
||||||
|
|
||||||
$: _class = currentSpace ? hierarchy.getClass(currentSpace._class).label : undefined
|
$: _class = currentSpace ? hierarchy.getClass(currentSpace._class).label : undefined
|
||||||
let classLabel = ''
|
let classLabel = ''
|
||||||
$: translate(hierarchy.getClass(object._class).label, {}).then((res) => (label = res.toLocaleLowerCase()))
|
$: {
|
||||||
|
const doc = docs[0]
|
||||||
|
space = doc.space
|
||||||
|
translate(hierarchy.getClass(doc._class).label, {}).then((res) => (label = res.toLocaleLowerCase()))
|
||||||
|
}
|
||||||
$: _class && translate(_class, {}).then((res) => (classLabel = res.toLocaleLowerCase()))
|
$: _class && translate(_class, {}).then((res) => (classLabel = res.toLocaleLowerCase()))
|
||||||
|
|
||||||
async function move (doc: Doc): Promise<void> {
|
async function move (doc: Doc): Promise<void> {
|
||||||
@ -69,22 +76,27 @@
|
|||||||
dispatch('close')
|
dispatch('close')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const moveAll = async () => {
|
||||||
|
docs.forEach(async (doc) => await move(doc))
|
||||||
|
}
|
||||||
|
|
||||||
async function getSpace (): Promise<void> {
|
async function getSpace (): Promise<void> {
|
||||||
client.findOne(core.class.Space, { _id: object.space }).then((res) => (currentSpace = res))
|
client.findOne(core.class.Space, { _id: space }).then((res) => (currentSpace = res))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function invokeValidate (
|
async function invokeValidate (
|
||||||
|
doc: Doc,
|
||||||
action: Resource<<T extends Doc>(doc: T, client: Client) => Promise<Status>>
|
action: Resource<<T extends Doc>(doc: T, client: Client) => Promise<Status>>
|
||||||
): Promise<Status> {
|
): Promise<Status> {
|
||||||
const impl = await getResource(action)
|
const impl = await getResource(action)
|
||||||
return await impl(object, client)
|
return await impl(doc, client)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validate (doc: Doc, _class: Ref<Class<Doc>>): Promise<void> {
|
async function validate (doc: Doc, _class: Ref<Class<Doc>>): Promise<void> {
|
||||||
const clazz = hierarchy.getClass(_class)
|
const clazz = hierarchy.getClass(_class)
|
||||||
const validatorMixin = hierarchy.as(clazz, view.mixin.ObjectValidator)
|
const validatorMixin = hierarchy.as(clazz, view.mixin.ObjectValidator)
|
||||||
if (validatorMixin?.validator != null) {
|
if (validatorMixin?.validator != null) {
|
||||||
status = await invokeValidate(validatorMixin.validator)
|
status = await invokeValidate(doc, validatorMixin.validator)
|
||||||
} else if (clazz.extends != null) {
|
} else if (clazz.extends != null) {
|
||||||
await validate(doc, clazz.extends)
|
await validate(doc, clazz.extends)
|
||||||
} else {
|
} else {
|
||||||
@ -92,7 +104,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: validate(object, object._class)
|
$: {
|
||||||
|
docs.forEach((doc) => {
|
||||||
|
validate(doc, doc._class)
|
||||||
|
})
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@ -106,7 +122,7 @@
|
|||||||
<div class="spaceSelect">
|
<div class="spaceSelect">
|
||||||
{#await getSpace() then}
|
{#await getSpace() then}
|
||||||
{#if currentSpace && _class}
|
{#if currentSpace && _class}
|
||||||
<SpaceSelect _class={currentSpace._class} label={_class} bind:value={object.space} />
|
<SpaceSelect _class={currentSpace._class} label={_class} bind:value={space} />
|
||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
@ -114,11 +130,9 @@
|
|||||||
<Button
|
<Button
|
||||||
label={view.string.Move}
|
label={view.string.Move}
|
||||||
size={'small'}
|
size={'small'}
|
||||||
disabled={object.space === currentSpace?._id || status !== OK}
|
disabled={space === currentSpace?._id || status !== OK}
|
||||||
kind={'primary'}
|
kind={'primary'}
|
||||||
on:click={() => {
|
on:click={moveAll}
|
||||||
move(object)
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
size={'small'}
|
size={'small'}
|
||||||
|
Loading…
Reference in New Issue
Block a user