diff --git a/models/card/src/index.ts b/models/card/src/index.ts index 9c4e6b3d8f..b6ded81bc9 100644 --- a/models/card/src/index.ts +++ b/models/card/src/index.ts @@ -12,12 +12,21 @@ // limitations under the License. import activity from '@hcengineering/activity' -import { cardId, DOMAIN_CARD, type Card, type MasterTag, type ParentInfo, type Tag } from '@hcengineering/card' +import { + cardId, + type CardSpace, + DOMAIN_CARD, + type Card, + type MasterTag, + type ParentInfo, + type Tag +} from '@hcengineering/card' import chunter from '@hcengineering/chunter' import core, { AccountRole, ClassifierKind, DOMAIN_MODEL, + DOMAIN_SPACE, IndexKind, SortingOrder, type Blobs, @@ -38,7 +47,7 @@ import { type Builder } from '@hcengineering/model' import attachment from '@hcengineering/model-attachment' -import { TClass, TDoc, TMixin } from '@hcengineering/model-core' +import { TClass, TDoc, TMixin, TSpace } from '@hcengineering/model-core' import presentation from '@hcengineering/model-presentation' import setting from '@hcengineering/model-setting' import view, { createAction } from '@hcengineering/model-view' @@ -93,6 +102,12 @@ export class TCard extends TDoc implements Card { parentInfo!: ParentInfo[] } +@Model(card.class.CardSpace, core.class.Space, DOMAIN_SPACE) +@UX(core.string.Space) +export class TCardSpace extends TSpace implements CardSpace { + types!: Ref[] +} + @Model(card.class.MasterTagEditorSection, core.class.Doc, DOMAIN_MODEL) export class MasterTagEditorSection extends TDoc implements MasterTagEditorSection { id!: string @@ -176,11 +191,56 @@ export function createSystemType ( } export function createModel (builder: Builder): void { - builder.createModel(TMasterTag, TTag, TCard, MasterTagEditorSection) + builder.createModel(TMasterTag, TTag, TCard, MasterTagEditorSection, TCardSpace) createSystemType(builder, card.types.File, card.icon.File, attachment.string.File, attachment.string.Files) createSystemType(builder, card.types.Document, card.icon.Document, card.string.Document, card.string.Documents) + builder.createDoc(view.class.Viewlet, core.space.Model, { + attachTo: card.class.CardSpace, + descriptor: view.viewlet.Table, + configOptions: { + hiddenKeys: ['name', 'description'] + }, + config: ['', 'members', 'private', 'archived'], + viewOptions: { + groupBy: [], + orderBy: [], + other: [ + { + key: 'hideArchived', + type: 'toggle', + defaultValue: true, + actionTarget: 'options', + action: view.function.HideArchived, + label: view.string.HideArchived + } + ] + } + }) + + createAction(builder, { + action: card.actionImpl.EditSpace, + label: presentation.string.Edit, + icon: view.icon.Edit, + input: 'focus', + category: view.category.General, + target: card.class.CardSpace, + visibilityTester: view.function.CanEditSpace, + query: {}, + context: { + mode: ['context', 'browser'], + group: 'edit' + } + }) + + builder.mixin(card.class.CardSpace, core.class.Class, workbench.mixin.SpaceView, { + view: { + class: card.class.Card, + component: card.component.Main + } + }) + builder.createDoc( workbench.class.Application, core.space.Model, @@ -192,11 +252,43 @@ export function createModel (builder: Builder): void { hidden: false, locationResolver: card.resolver.Location, locationDataResolver: card.resolver.LocationData, - component: card.component.Main + navigatorModel: { + specials: [ + { + id: 'browser', + accessLevel: AccountRole.User, + label: core.string.Spaces, + icon: view.icon.List, + component: workbench.component.SpecialView, + componentProps: { + _class: card.class.CardSpace, + icon: view.icon.List, + label: core.string.Spaces + }, + position: 'top' + } + ], + spaces: [ + { + id: 'spaces', + label: core.string.Spaces, + spaceClass: card.class.CardSpace, + addSpaceLabel: core.string.Space, + icon: card.icon.Card, + // intentionally left empty in order to make space presenter working + specials: [] + } + ] + }, + navHeaderComponent: card.component.NewCardHeader }, card.app.Card ) + builder.mixin(card.class.CardSpace, core.class.Class, view.mixin.SpacePresenter, { + presenter: card.component.SpacePresenter + }) + createAction( builder, { diff --git a/models/card/src/migration.ts b/models/card/src/migration.ts index 7d111617c3..36fb941601 100644 --- a/models/card/src/migration.ts +++ b/models/card/src/migration.ts @@ -32,6 +32,11 @@ export const cardOperation: MigrateOperation = { state: 'set-parent-info', mode: 'upgrade', func: setParentInfo + }, + { + state: 'migrate-spaces', + mode: 'upgrade', + func: migrateSpaces } ]) }, @@ -44,6 +49,13 @@ export const cardOperation: MigrateOperation = { { state: 'removeVariantViewlets', func: removeVariantViewlets + }, + { + state: 'create-defaults', + func: async (client) => { + const tx = new TxOperations(client, core.account.System) + await createDefaultProject(tx) + } } ]) } @@ -125,3 +137,38 @@ async function migrateViewlets (client: Client): Promise { } } } + +async function createDefaultProject (tx: TxOperations): Promise { + const current = await tx.findOne(card.class.CardSpace, { + _id: card.space.Default + }) + + const currentDeleted = await tx.findOne(core.class.TxRemoveDoc, { + objectId: card.space.Default + }) + + // Create new if not deleted by customers. + if (current === undefined && currentDeleted === undefined) { + const topLevelTypes = await tx.findAll(card.class.MasterTag, { + extends: card.class.Card + }) + await tx.createDoc( + card.class.CardSpace, + core.space.Space, + { + name: 'Default', + description: 'Default', + private: false, + members: [], + archived: false, + autoJoin: true, + types: topLevelTypes.map((it) => it._id) + }, + card.space.Default + ) + } +} + +async function migrateSpaces (client: MigrationClient): Promise { + await client.update(DOMAIN_CARD, { space: core.space.Workspace }, { space: card.space.Default }) +} diff --git a/models/card/src/plugin.ts b/models/card/src/plugin.ts index 6cd690a280..15f41b6706 100644 --- a/models/card/src/plugin.ts +++ b/models/card/src/plugin.ts @@ -27,7 +27,8 @@ export default mergeIds(cardId, card, { Card: '' as Ref }, actionImpl: { - DeleteMasterTag: '' as ViewAction + DeleteMasterTag: '' as ViewAction, + EditSpace: '' as ViewAction }, action: { DeleteMasterTag: '' as Ref, diff --git a/plugins/card-assets/lang/cs.json b/plugins/card-assets/lang/cs.json index 93b87b6c9a..eeaa09e130 100644 --- a/plugins/card-assets/lang/cs.json +++ b/plugins/card-assets/lang/cs.json @@ -33,6 +33,8 @@ "ChangeType": "Změnit typ", "ChangeTypeWarning": "Varování: Změna typu karty odstraní všechna data pro jakýkoliv atribut, který v cílovém typu neexistuje. Předchozí data atributu mohou být obnoveny změnou karty zpět na předchozí typ. Obsah karty nebude ovlivněn.", "MasterDetailViews": "Zobrazení master-detail", - "SelectType": "Vybrat typ" + "SelectType": "Vybrat typ", + "CreateSpace": "Vytvořit prostor", + "NumberTypes": "{count, plural, one {# typ} few {# typy} other {# typů}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/de.json b/plugins/card-assets/lang/de.json index 68a68c74a7..bfcdf660d4 100644 --- a/plugins/card-assets/lang/de.json +++ b/plugins/card-assets/lang/de.json @@ -33,6 +33,8 @@ "ChangeType": "Typ ändern", "ChangeTypeWarning": "Warnung: Das Ändern des Typs einer Karte wird alle Daten für alle Attribute entfernen, die nicht auf dem Zieltyp vorhanden sind. Vorherige Attributdaten können wiederhergestellt werden, indem Sie die Karte auf einen früheren Typ zurücksetzen. Karteninhalt wird nicht betroffen.", "MasterDetailViews": "Master-Detail-Ansichten", - "SelectType": "Typ auswählen" + "SelectType": "Typ auswählen", + "CreateSpace": "Raum erstellen", + "NumberTypes": "{count, plural, one {# typ} other {# typen}}" } } diff --git a/plugins/card-assets/lang/en.json b/plugins/card-assets/lang/en.json index 12d9dbfbd0..2b2c5eccfe 100644 --- a/plugins/card-assets/lang/en.json +++ b/plugins/card-assets/lang/en.json @@ -33,6 +33,8 @@ "ChangeType": "Change type", "ChangeTypeWarning": "Warning: Changing the Type of a Card will remove all data for any attributes that do not exist on the target Type. Previous attribute data can be restored by changing the Card back to a previous Type. Card content will not be affected.", "MasterDetailViews": "Master Detail Views", - "SelectType": "Select Type" + "SelectType": "Select Type", + "CreateSpace": "Create space", + "NumberTypes": "{count, plural, one {# type} other {# types}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/es.json b/plugins/card-assets/lang/es.json index cfbcc82d95..2d50fb22dc 100644 --- a/plugins/card-assets/lang/es.json +++ b/plugins/card-assets/lang/es.json @@ -33,6 +33,8 @@ "ChangeType": "Cambiar tipo", "ChangeTypeWarning": "Advertencia: Cambiar el tipo de una tarjeta eliminará todos los datos para cualquier atributo que no exista en el tipo de destino. Los datos previos del atributo pueden ser restaurados cambiando la tarjeta de nuevo a un tipo anterior. El contenido de la tarjeta no será afectado.", "MasterDetailViews": "Vistas Maestro-Detalle", - "SelectType": "Seleccionar tipo" + "SelectType": "Seleccionar tipo", + "CreateSpace": "Crear espacio", + "NumberTypes": "{count, plural, one {# tipo} other {# tipos}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/fr.json b/plugins/card-assets/lang/fr.json index f18584920b..28e0750c98 100644 --- a/plugins/card-assets/lang/fr.json +++ b/plugins/card-assets/lang/fr.json @@ -33,6 +33,8 @@ "ChangeType": "Changer de type", "ChangeTypeWarning": "Avertissement : Changer le type d'une carte supprimera toutes les données pour tous les attributs qui ne sont pas dans le type cible. Les données précédentes de l'attribut peuvent être restaurées en changeant la carte en arrière. Le contenu de la carte ne sera pas affecté.", "MasterDetailViews": "Vues maître-détail", - "SelectType": "Sélectionner le type" + "SelectType": "Sélectionner le type", + "CreateSpace": "Créer un espace", + "NumberTypes": "{count, plural, one {# type} other {# types}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/it.json b/plugins/card-assets/lang/it.json index 1c4f795612..a7188903da 100644 --- a/plugins/card-assets/lang/it.json +++ b/plugins/card-assets/lang/it.json @@ -33,6 +33,7 @@ "ChangeType": "Cambia tipo", "ChangeTypeWarning": "Avviso: Cambiare il tipo di un'scheda rimuoverà tutti i dati per qualsiasi attributo che non esistono nel tipo di destinazione. I dati precedenti dell'attributo possono essere ripristinati modificando nuovamente il carta in un tipo precedente. Il contenuto della scheda non sarà influenzato.", "MasterDetailViews": "Viste Master-Detail", - "SelectType": "Seleziona il tipo" + "SelectType": "Seleziona il tipo", + "CreateSpace": "Crea spazio" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/pt.json b/plugins/card-assets/lang/pt.json index 3f9a479c77..9e760c4ec3 100644 --- a/plugins/card-assets/lang/pt.json +++ b/plugins/card-assets/lang/pt.json @@ -33,6 +33,8 @@ "ChangeType": "Alterar tipo", "ChangeTypeWarning": "Aviso: Alterar o tipo de um cartão irá remover todos os dados para quaisquer atributos que não existem no tipo de destino. Dados anteriores do atributo podem ser restaurados alterando o cartão de volta para um tipo anterior. O conteúdo do cartão não será afetado.", "MasterDetailViews": "Visualizações Master-Detail", - "SelectType": "Selecionar tipo" + "SelectType": "Selecionar tipo", + "CreateSpace": "Criar espaço", + "NumberTypes": "{count, plural, one {# tipo} other {# tipos}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/ru.json b/plugins/card-assets/lang/ru.json index aa8b4ed0ad..92ada63c7e 100644 --- a/plugins/card-assets/lang/ru.json +++ b/plugins/card-assets/lang/ru.json @@ -33,6 +33,8 @@ "ChangeType": "Изменить тип", "ChangeTypeWarning": "Внимание: Изменение типа удалит все данные для любых атрибутов, которые не существуют в целевом типе. Предыдущие данные атрибутов могут быть восстановлены, изменением на предыдущий тип. Содержимое не будет затронуто.", "MasterDetailViews": "Представления мастер-деталь", - "SelectType": "Выбрать тип" + "SelectType": "Выбрать тип", + "CreateSpace": "Создать пространство", + "NumberTypes": "{count, plural, one {# тип} few {# типа} other {# типов}}" } } \ No newline at end of file diff --git a/plugins/card-assets/lang/zh.json b/plugins/card-assets/lang/zh.json index 22cd90418b..6036cc1edf 100644 --- a/plugins/card-assets/lang/zh.json +++ b/plugins/card-assets/lang/zh.json @@ -33,6 +33,8 @@ "ChangeType": "更改类型", "ChangeTypeWarning": "警告:更改卡片类型将删除任何不存在于目标类型中的任何属性的所有数据。之前的属性数据可以通过将卡片回到以前的类型来恢复。卡片内容将不会受到影响。", "MasterDetailViews": "主细节视图", - "SelectType": "选择类型" + "SelectType": "选择类型", + "CreateSpace": "创建空间", + "NumberTypes": "{count, plural, one {# 类型} other {# 类型}}" } } \ No newline at end of file diff --git a/plugins/card-resources/package.json b/plugins/card-resources/package.json index 540357d9d7..7290ce4cb4 100644 --- a/plugins/card-resources/package.json +++ b/plugins/card-resources/package.json @@ -45,6 +45,7 @@ "@hcengineering/setting": "^0.6.17", "@hcengineering/attachment": "^0.6.14", "@hcengineering/attachment-resources": "^0.6.0", + "@hcengineering/contact-resources": "^0.6.0", "@hcengineering/setting-resources": "^0.6.0", "@hcengineering/analytics": "^0.6.0", "@hcengineering/uploader": "^0.6.0", diff --git a/plugins/card-resources/src/components/CardSelector.svelte b/plugins/card-resources/src/components/CardSelector.svelte index 95f00f91a7..01586b6a68 100644 --- a/plugins/card-resources/src/components/CardSelector.svelte +++ b/plugins/card-resources/src/components/CardSelector.svelte @@ -64,6 +64,7 @@ value = val._id dispatch('change', value) + dispatch('value', val) } let doc: Card | undefined diff --git a/plugins/card-resources/src/components/Main.svelte b/plugins/card-resources/src/components/Main.svelte index c17748bc81..418ea46bf0 100644 --- a/plugins/card-resources/src/components/Main.svelte +++ b/plugins/card-resources/src/components/Main.svelte @@ -14,60 +14,46 @@ --> -
- {#if $deviceInfo.navigator.visible} - - - {/if} - -
- {#if clazz !== undefined && label !== undefined} - - {/if} -
-
+{#if clazz !== undefined && label !== undefined} + +{/if} diff --git a/plugins/card-resources/src/components/Navigator.svelte b/plugins/card-resources/src/components/Navigator.svelte deleted file mode 100644 index 34b7d5df56..0000000000 --- a/plugins/card-resources/src/components/Navigator.svelte +++ /dev/null @@ -1,102 +0,0 @@ - - - -
-
- - -
-
- - (menuSelection = res.detail)} /> - - {#if classes.length > 0} -
- - - - {/if} - -
- - -
-
diff --git a/plugins/card-resources/src/components/navigator/CreateSpace.svelte b/plugins/card-resources/src/components/navigator/CreateSpace.svelte new file mode 100644 index 0000000000..6689d26d0d --- /dev/null +++ b/plugins/card-resources/src/components/navigator/CreateSpace.svelte @@ -0,0 +1,178 @@ + + + + +
+
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
diff --git a/plugins/card-resources/src/components/navigator/NewCardHeader.svelte b/plugins/card-resources/src/components/navigator/NewCardHeader.svelte new file mode 100644 index 0000000000..fc8b44af5a --- /dev/null +++ b/plugins/card-resources/src/components/navigator/NewCardHeader.svelte @@ -0,0 +1,157 @@ + + + +{#if loading} + +{:else if hasAccountRole(getCurrentAccount(), AccountRole.User) || hasSpace} +
+ {#if hasAccountRole(getCurrentAccount(), AccountRole.User)} + {#if hasSpace} + { + void dropdownItemSelected(ev.detail) + }} + /> + {:else} +
+{/if} diff --git a/plugins/card-resources/src/components/navigator/SpacePresenter.svelte b/plugins/card-resources/src/components/navigator/SpacePresenter.svelte new file mode 100644 index 0000000000..92fd8946b8 --- /dev/null +++ b/plugins/card-resources/src/components/navigator/SpacePresenter.svelte @@ -0,0 +1,70 @@ + + + +
+ { + evt.preventDefault() + }} + > + + +
diff --git a/plugins/card-resources/src/components/TagHierarchy.svelte b/plugins/card-resources/src/components/navigator/TagHierarchy.svelte similarity index 58% rename from plugins/card-resources/src/components/TagHierarchy.svelte rename to plugins/card-resources/src/components/navigator/TagHierarchy.svelte index 641bc7862c..64a0371a35 100644 --- a/plugins/card-resources/src/components/TagHierarchy.svelte +++ b/plugins/card-resources/src/components/navigator/TagHierarchy.svelte @@ -14,22 +14,20 @@ --> {#each classes as clazz} - - { - dispatch('select', clazz._id) - }} - /> - - {#if (descendants.get(clazz._id)?.length ?? 0) > 0} - - {/if} + { + select(clazz._id, space) + }} + > + + {#if (descendants.get(clazz._id)?.length ?? 0) > 0} + + {/if} + + {/each} diff --git a/plugins/card-resources/src/components/navigator/TypesSelector.svelte b/plugins/card-resources/src/components/navigator/TypesSelector.svelte new file mode 100644 index 0000000000..f3232ad094 --- /dev/null +++ b/plugins/card-resources/src/components/navigator/TypesSelector.svelte @@ -0,0 +1,56 @@ + + + + diff --git a/plugins/card-resources/src/index.ts b/plugins/card-resources/src/index.ts index e6a070a752..c60b6e803e 100644 --- a/plugins/card-resources/src/index.ts +++ b/plugins/card-resources/src/index.ts @@ -24,7 +24,8 @@ import { resolveLocationData, getCardLink, queryCard, - deleteMasterTag + deleteMasterTag, + editSpace } from './utils' import ManageMasterTagsContent from './components/settings/ManageMasterTagsContent.svelte' import ManageMasterTagsTools from './components/settings/ManageMasterTagsTools.svelte' @@ -43,6 +44,8 @@ import CardRefPresenter from './components/CardRefPresenter.svelte' import ChangeType from './components/ChangeType.svelte' import CreateCardButton from './components/CreateCardButton.svelte' import CardArrayEditor from './components/CardArrayEditor.svelte' +import NewCardHeader from './components/navigator/NewCardHeader.svelte' +import SpacePresenter from './components/navigator/SpacePresenter.svelte' export { default as CardSelector } from './components/CardSelector.svelte' @@ -69,7 +72,9 @@ export default async (): Promise => ({ CardRefPresenter, ChangeType, CreateCardButton, - CardArrayEditor + CardArrayEditor, + NewCardHeader, + SpacePresenter }, completion: { CardQuery: queryCard @@ -79,7 +84,8 @@ export default async (): Promise => ({ LocationData: resolveLocationData }, actionImpl: { - DeleteMasterTag: deleteMasterTag + DeleteMasterTag: deleteMasterTag, + EditSpace: editSpace }, function: { CardTitleProvider: getCardTitle, diff --git a/plugins/card-resources/src/plugin.ts b/plugins/card-resources/src/plugin.ts index b836151dfc..de01ee7f3e 100644 --- a/plugins/card-resources/src/plugin.ts +++ b/plugins/card-resources/src/plugin.ts @@ -43,7 +43,9 @@ export default mergeIds(cardId, card, { CardRefPresenter: '' as AnyComponent, ChangeType: '' as AnyComponent, CreateCardButton: '' as AnyComponent, - CardArrayEditor: '' as AnyComponent + CardArrayEditor: '' as AnyComponent, + NewCardHeader: '' as AnyComponent, + SpacePresenter: '' as AnyComponent }, completion: { CardQuery: '' as Resource, @@ -82,6 +84,8 @@ export default mergeIds(cardId, card, { ChangeType: '' as IntlString, ChangeTypeWarning: '' as IntlString, MasterDetailViews: '' as IntlString, - SelectType: '' as IntlString + SelectType: '' as IntlString, + CreateSpace: '' as IntlString, + NumberTypes: '' as IntlString } }) diff --git a/plugins/card-resources/src/utils.ts b/plugins/card-resources/src/utils.ts index b46cca4aab..3349f82df4 100644 --- a/plugins/card-resources/src/utils.ts +++ b/plugins/card-resources/src/utils.ts @@ -11,7 +11,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -import { type Card, cardId, type MasterTag } from '@hcengineering/card' +import { type Card, cardId, type CardSpace, type MasterTag } from '@hcengineering/card' import { type Class, type Client, @@ -35,6 +35,7 @@ import { accessDeniedStore } from '@hcengineering/view-resources' import { type LocationData } from '@hcengineering/workbench' import CardSearchItem from './components/CardSearchItem.svelte' import card from './plugin' +import CreateSpace from './components/navigator/CreateSpace.svelte' export async function deleteMasterTag (tag: MasterTag | undefined, onDelete?: () => void): Promise { if (tag !== undefined) { @@ -67,11 +68,17 @@ export async function resolveLocation (loc: Location): Promise { + if (value !== undefined) { + showPopup(CreateSpace, { space: value }) + } +} + async function generateLocation (loc: Location, id: string): Promise { const client = getClient() const doc = await client.findOne(card.class.Card, { _id: id as Ref }) @@ -81,6 +88,7 @@ async function generateLocation (loc: Location, id: string): Promise>, view.mixin.ObjectPanel) @@ -92,7 +100,7 @@ async function generateLocation (loc: Location, id: string): Promise[] +} + export interface ParentInfo { _id: Ref _class: Ref @@ -64,7 +68,11 @@ const cardPlugin = plugin(cardId, { Card: '' as Ref>, MasterTag: '' as Ref>, Tag: '' as Ref>, - MasterTagEditorSection: '' as Ref> + MasterTagEditorSection: '' as Ref>, + CardSpace: '' as Ref> + }, + space: { + Default: '' as Ref }, types: { File: '' as Ref, diff --git a/plugins/chat-resources/src/components/ChatWidget.svelte b/plugins/chat-resources/src/components/ChatWidget.svelte index bf91e6eca6..dd2371d872 100644 --- a/plugins/chat-resources/src/components/ChatWidget.svelte +++ b/plugins/chat-resources/src/components/ChatWidget.svelte @@ -121,7 +121,7 @@ }, chat.masterTag.Thread ) - threadId = (await client.createDoc(chat.masterTag.Thread, core.space.Workspace, data)) as CardID + threadId = (await client.createDoc(chat.masterTag.Thread, cardPlugin.space.Default, data)) as CardID await communicationClient.createThread(card, message.id, threadId) } diff --git a/plugins/process-resources/src/components/RunProcessCardPopup.svelte b/plugins/process-resources/src/components/RunProcessCardPopup.svelte index 1d2bf9fad2..3e059c5e0b 100644 --- a/plugins/process-resources/src/components/RunProcessCardPopup.svelte +++ b/plugins/process-resources/src/components/RunProcessCardPopup.svelte @@ -28,7 +28,7 @@ const client = getClient() let process: Ref | undefined = value - let card: Ref | undefined + let card: Card | undefined const processes = client.getModel().findAllSync(plugin.class.Process, {}) @@ -38,7 +38,7 @@ async function runProcess (): Promise { if (process === undefined || card === undefined) return - await createExecution(card, process) + await createExecution(card._id, process, card.space) dispatch('close') } @@ -94,7 +94,10 @@ { + card = e.detail + }} {ignoreObjects} _class={selectedProcess.masterTag} /> diff --git a/plugins/process-resources/src/components/RunProcessPopup.svelte b/plugins/process-resources/src/components/RunProcessPopup.svelte index d127697f10..f5191598ee 100644 --- a/plugins/process-resources/src/components/RunProcessPopup.svelte +++ b/plugins/process-resources/src/components/RunProcessPopup.svelte @@ -62,7 +62,7 @@ const dispatch = createEventDispatcher() async function runProcess (_id: Ref): Promise { - await createExecution(value._id, _id) + await createExecution(value._id, _id, value.space) dispatch('close') } diff --git a/plugins/process-resources/src/middleware.ts b/plugins/process-resources/src/middleware.ts index 37adac6a67..8b5f0ff2a4 100644 --- a/plugins/process-resources/src/middleware.ts +++ b/plugins/process-resources/src/middleware.ts @@ -79,7 +79,7 @@ export class ProcessMiddleware extends BasePresentationMiddleware implements Pre autoStart: true }) for (const proc of processes) { - await createExecution(createTx.objectId, proc._id) + await createExecution(createTx.objectId, proc._id, createTx.objectSpace) } } } @@ -95,7 +95,7 @@ export class ProcessMiddleware extends BasePresentationMiddleware implements Pre .getModel() .findAllSync(process.class.Process, { masterTag: mixinTx.mixin, autoStart: true }) for (const proc of processes) { - await createExecution(mixinTx.objectId, proc._id) + await createExecution(mixinTx.objectId, proc._id, mixinTx.objectSpace) } } diff --git a/plugins/process-resources/src/utils.ts b/plugins/process-resources/src/utils.ts index 2c1892a00f..10d2939ea7 100644 --- a/plugins/process-resources/src/utils.ts +++ b/plugins/process-resources/src/utils.ts @@ -13,6 +13,7 @@ import { type Card } from '@hcengineering/card' import core, { + type Space, type AnyAttribute, type ArrOf, type Association, @@ -278,11 +279,11 @@ export async function getNextStateUserInput ( return await requestUserInput(nextState, userContext) } -export async function createExecution (card: Ref, _id: Ref): Promise { +export async function createExecution (card: Ref, _id: Ref, space: Ref): Promise { const client = getClient() const context = await newExecutionUserInput(_id, {}) - await client.createDoc(process.class.Execution, core.space.Workspace, { + await client.createDoc(process.class.Execution, space, { process: _id, currentState: null, card, diff --git a/plugins/workbench-resources/src/components/Workbench.svelte b/plugins/workbench-resources/src/components/Workbench.svelte index 6d88c90a20..38dbcd6cd0 100644 --- a/plugins/workbench-resources/src/components/Workbench.svelte +++ b/plugins/workbench-resources/src/components/Workbench.svelte @@ -1019,7 +1019,7 @@ {:else if currentView?.component !== undefined} {:else if $accessDeniedStore}
diff --git a/ws-tests/api-tests/src/__tests__/rest.test.ts b/ws-tests/api-tests/src/__tests__/rest.test.ts index 5d85677f29..e1bdf8c4ab 100644 --- a/ws-tests/api-tests/src/__tests__/rest.test.ts +++ b/ws-tests/api-tests/src/__tests__/rest.test.ts @@ -202,7 +202,7 @@ describe('rest-api-server', () => { const { hierarchy, model } = await conn.getModel() const dsc = hierarchy.getDescendants(core.class.Space) - expect(dsc.length).toBe(32) + expect(dsc.length).toBe(33) // todo fix this stupid test expect(model.getObject(core.class.Space)).not.toBeNull() })