diff --git a/plugins/view-resources/src/actionImpl.ts b/plugins/view-resources/src/actionImpl.ts index 15e6efda16..0827dc05d7 100644 --- a/plugins/view-resources/src/actionImpl.ts +++ b/plugins/view-resources/src/actionImpl.ts @@ -73,8 +73,8 @@ function Delete (object: Doc): void { ) } -async function Move (object: Doc): Promise { - showPopup(MoveView, { object }) +async function Move (docs: Doc | Doc[]): Promise { + showPopup(MoveView, { selected: docs }) } let $focusStore: FocusSelection diff --git a/plugins/view-resources/src/components/Move.svelte b/plugins/view-resources/src/components/Move.svelte index 0a84968dfc..9f6aee084e 100644 --- a/plugins/view-resources/src/components/Move.svelte +++ b/plugins/view-resources/src/components/Move.svelte @@ -24,7 +24,8 @@ import task, { Task, calcRank } from '@hcengineering/task' 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 currentSpace: Space | undefined @@ -32,9 +33,15 @@ const dispatch = createEventDispatcher() const hierarchy = client.getHierarchy() let label = '' + let space: Ref + $: _class = currentSpace ? hierarchy.getClass(currentSpace._class).label : undefined 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())) async function move (doc: Doc): Promise { @@ -69,22 +76,27 @@ dispatch('close') } + const moveAll = async () => { + docs.forEach(async (doc) => await move(doc)) + } + async function getSpace (): Promise { - 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 ( + doc: Doc, action: Resource<(doc: T, client: Client) => Promise> ): Promise { const impl = await getResource(action) - return await impl(object, client) + return await impl(doc, client) } async function validate (doc: Doc, _class: Ref>): Promise { const clazz = hierarchy.getClass(_class) const validatorMixin = hierarchy.as(clazz, view.mixin.ObjectValidator) if (validatorMixin?.validator != null) { - status = await invokeValidate(validatorMixin.validator) + status = await invokeValidate(doc, validatorMixin.validator) } else if (clazz.extends != null) { await validate(doc, clazz.extends) } else { @@ -92,7 +104,11 @@ } } - $: validate(object, object._class) + $: { + docs.forEach((doc) => { + validate(doc, doc._class) + }) + }
@@ -106,7 +122,7 @@
{#await getSpace() then} {#if currentSpace && _class} - + {/if} {/await}
@@ -114,11 +130,9 @@