diff --git a/models/view/src/index.ts b/models/view/src/index.ts index f70ffc1074..f03dd0b7d3 100644 --- a/models/view/src/index.ts +++ b/models/view/src/index.ts @@ -693,6 +693,25 @@ export function createModel (builder: Builder): void { view.action.Delete ) + createAction( + builder, + { + action: view.actionImpl.Delete, + actionProps: { + confirmation: view.string.RemoveRelationConfirmation + }, + label: view.string.RemoveRelation, + icon: view.icon.Delete, + keyBinding: ['Meta + Backspace'], + category: view.category.General, + override: [view.action.Delete], + input: 'any', + target: core.class.Relation, + context: { mode: ['context', 'browser'], group: 'remove' } + }, + view.action.RemoveRelation + ) + createAction( builder, { diff --git a/plugins/card-resources/src/components/Navigator.svelte b/plugins/card-resources/src/components/Navigator.svelte index 68b66b8acd..474faa58e1 100644 --- a/plugins/card-resources/src/components/Navigator.svelte +++ b/plugins/card-resources/src/components/Navigator.svelte @@ -40,7 +40,7 @@ let allClasses: MasterTag[] = [] function fillClasses (tags: MasterTag[]): void { - classes = tags.filter((it) => it.extends === card.class.Card) + classes = tags.filter((it) => it.extends === card.class.Card).sort((a, b) => a.label.localeCompare(b.label)) } const query = createQuery() diff --git a/plugins/card-resources/src/components/TagHierarchy.svelte b/plugins/card-resources/src/components/TagHierarchy.svelte index bae832d1d9..5efa01169f 100644 --- a/plugins/card-resources/src/components/TagHierarchy.svelte +++ b/plugins/card-resources/src/components/TagHierarchy.svelte @@ -41,7 +41,7 @@ result.push(cls) } } - return result + return result.sort((a, b) => a.label.localeCompare(b.label)) } function fillDescendants (classes: MasterTag[]): void { diff --git a/plugins/card-resources/src/components/settings/ManageMasterTags.svelte b/plugins/card-resources/src/components/settings/ManageMasterTags.svelte index 918e62671d..7f03819caa 100644 --- a/plugins/card-resources/src/components/settings/ManageMasterTags.svelte +++ b/plugins/card-resources/src/components/settings/ManageMasterTags.svelte @@ -47,7 +47,7 @@ _class: card.class.MasterTag }, (result) => { - tags = result + tags = result.sort((a, b) => a.label.localeCompare(b.label)) } ) diff --git a/plugins/card-resources/src/components/settings/RelationsSection.svelte b/plugins/card-resources/src/components/settings/RelationsSection.svelte index 7f3eae3c60..a9544ddead 100644 --- a/plugins/card-resources/src/components/settings/RelationsSection.svelte +++ b/plugins/card-resources/src/components/settings/RelationsSection.svelte @@ -50,6 +50,7 @@ function addRelation (): void { showPopup(setting.component.CreateRelation, { + aClass: masterTag._id, exclude: [], _classes: [card.class.Card, contact.class.Contact] }) diff --git a/plugins/contact-resources/src/components/DeleteConfirmationPopup.svelte b/plugins/contact-resources/src/components/DeleteConfirmationPopup.svelte index d2081495cc..0b03741a55 100644 --- a/plugins/contact-resources/src/components/DeleteConfirmationPopup.svelte +++ b/plugins/contact-resources/src/components/DeleteConfirmationPopup.svelte @@ -22,11 +22,14 @@ import { createEventDispatcher } from 'svelte' import { personRefByPersonIdStore } from '../utils' import { PersonRefPresenter } from '..' + import { IntlString } from '@hcengineering/platform' export let object: Doc | Doc[] export let deleteAction: () => void | Promise export let skipCheck: boolean = false export let canDeleteExtra: boolean = true + export let confirmation: IntlString | undefined = undefined + const me = getCurrentEmployee() const objectArray = Array.isArray(object) ? object : [object] const dispatch = createEventDispatcher() @@ -57,7 +60,7 @@
{#if canDelete}
-
diff --git a/plugins/view-assets/lang/cs.json b/plugins/view-assets/lang/cs.json index 9a2c4b64d5..8f05f796b9 100644 --- a/plugins/view-assets/lang/cs.json +++ b/plugins/view-assets/lang/cs.json @@ -127,6 +127,8 @@ "Join": "Připojit se", "Copied": "Zkopírováno", "Title": "Název", - "HideArchived": "Skrýt archivované" + "HideArchived": "Skrýt archivované", + "RemoveRelation": "Odstranit vztah", + "RemoveRelationConfirmation": "Chcete odstranit vztah?" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/de.json b/plugins/view-assets/lang/de.json index e4bf616a43..78ef01ba63 100644 --- a/plugins/view-assets/lang/de.json +++ b/plugins/view-assets/lang/de.json @@ -127,6 +127,8 @@ "Join": "Beitreten", "Copied": "Kopiert", "Title": "Titel", - "HideArchived": "Archivierte ausblenden" + "HideArchived": "Archivierte ausblenden", + "RemoveRelation": "Beziehung entfernen", + "RemoveRelationConfirmation": "Möchten Sie die Beziehung entfernen?" } } diff --git a/plugins/view-assets/lang/en.json b/plugins/view-assets/lang/en.json index d858d3ee73..45c0f75dc3 100644 --- a/plugins/view-assets/lang/en.json +++ b/plugins/view-assets/lang/en.json @@ -127,6 +127,8 @@ "Join": "Join", "Copied": "Copied", "Title": "Title", - "HideArchived": "Hide archived" + "HideArchived": "Hide archived", + "RemoveRelation": "Remove relation", + "RemoveRelationConfirmation": "Do you want to remove relation?" } } diff --git a/plugins/view-assets/lang/es.json b/plugins/view-assets/lang/es.json index 1ceff62448..66809a123a 100644 --- a/plugins/view-assets/lang/es.json +++ b/plugins/view-assets/lang/es.json @@ -122,6 +122,8 @@ "Join": "Unirse", "Copied": "Copiado", "Title": "Título", - "HideArchived": "Ocultar archivadas" + "HideArchived": "Ocultar archivadas", + "RemoveRelation": "Eliminar relación", + "RemoveRelationConfirmation": "¿Quieres eliminar la relación?" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/fr.json b/plugins/view-assets/lang/fr.json index 5e06dadca3..28eff698db 100644 --- a/plugins/view-assets/lang/fr.json +++ b/plugins/view-assets/lang/fr.json @@ -122,6 +122,8 @@ "Join": "Rejoindre", "Copied": "Copié", "Title": "Titre", - "HideArchived": "Masquer les archives" + "HideArchived": "Masquer les archives", + "RemoveRelation": "Supprimer la relation", + "RemoveRelationConfirmation": "Voulez-vous supprimer la relation ?" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/it.json b/plugins/view-assets/lang/it.json index 6751f3cbd3..f1c2517dd6 100644 --- a/plugins/view-assets/lang/it.json +++ b/plugins/view-assets/lang/it.json @@ -122,6 +122,8 @@ "Join": "Unisciti", "Copied": "Copiato", "Title": "Titolo", - "HideArchived": "Nascondi archiviato" + "HideArchived": "Nascondi archiviato", + "RemoveRelation": "Rimuovere relazione", + "RemoveRelationConfirmation": "Vuoi rimuovere la relazione?" } } diff --git a/plugins/view-assets/lang/pt.json b/plugins/view-assets/lang/pt.json index 5c1cd6aa48..9215075d48 100644 --- a/plugins/view-assets/lang/pt.json +++ b/plugins/view-assets/lang/pt.json @@ -122,6 +122,8 @@ "Join": "Ingressar", "Copied": "Copiado", "Title": "Título", - "HideArchived": "Ocultar arquivado" + "HideArchived": "Ocultar arquivado", + "RemoveRelation": "Remover relação", + "RemoveRelationConfirmation": "Deseja remover a relação?" } } \ No newline at end of file diff --git a/plugins/view-assets/lang/ru.json b/plugins/view-assets/lang/ru.json index b71f832892..7f1b64a147 100644 --- a/plugins/view-assets/lang/ru.json +++ b/plugins/view-assets/lang/ru.json @@ -124,6 +124,8 @@ "Join": "Присоединиться", "Copied": "Скопировано", "Title": "Заголовок", - "HideArchived": "Скрыть архивные" + "HideArchived": "Скрыть архивные", + "RemoveRelation": "Удалить связь", + "RemoveRelationConfirmation": "Вы хотите удалить связь?" } } diff --git a/plugins/view-assets/lang/zh.json b/plugins/view-assets/lang/zh.json index 2311b4d31b..f8b803ce10 100644 --- a/plugins/view-assets/lang/zh.json +++ b/plugins/view-assets/lang/zh.json @@ -127,6 +127,8 @@ "Join": "加入", "Copied": "已复制", "Title": "标题", - "HideArchived": "隱藏已存檔" + "HideArchived": "隱藏已存檔", + "RemoveRelation": "移除关系", + "RemoveRelationConfirmation": "您要移除关系吗?" } } diff --git a/plugins/view-resources/src/actionImpl.ts b/plugins/view-resources/src/actionImpl.ts index 8c7a99eab0..e716091948 100644 --- a/plugins/view-resources/src/actionImpl.ts +++ b/plugins/view-resources/src/actionImpl.ts @@ -92,6 +92,7 @@ function Delete ( props?: { skipCheck?: boolean afterDelete?: () => Promise + confirmation?: IntlString } ): void { const skipCheck = props?.skipCheck ?? false @@ -100,6 +101,7 @@ function Delete ( { object, skipCheck, + confirmation: props?.confirmation, deleteAction: async () => { try { const objs = Array.isArray(object) ? object : [object] diff --git a/plugins/view-resources/src/components/RelationEditor.svelte b/plugins/view-resources/src/components/RelationEditor.svelte index c6c7e8027f..ff2146593d 100644 --- a/plugins/view-resources/src/components/RelationEditor.svelte +++ b/plugins/view-resources/src/components/RelationEditor.svelte @@ -93,7 +93,7 @@ : { docA: doc._id, docB: object._id, association: association._id } const relation = await client.findOne(core.class.Relation, q) if (relation !== undefined) { - showMenu(ev, { object: relation, includedActions: [view.action.Delete] }) + showMenu(ev, { object: relation, includedActions: [view.action.RemoveRelation] }) } } diff --git a/plugins/view/src/index.ts b/plugins/view/src/index.ts index 2183061499..e602092e80 100644 --- a/plugins/view/src/index.ts +++ b/plugins/view/src/index.ts @@ -150,7 +150,8 @@ const view = plugin(viewId, { // Edit document Open: '' as Ref, - OpenInNewTab: '' as Ref + OpenInNewTab: '' as Ref, + RemoveRelation: '' as Ref }, viewlet: { Table: '' as Ref, @@ -219,7 +220,9 @@ const view = plugin(viewId, { And: '' as IntlString, Title: '' as IntlString, DeleteObject: '' as IntlString, - DeleteObjectConfirm: '' as IntlString + DeleteObjectConfirm: '' as IntlString, + RemoveRelationConfirmation: '' as IntlString, + RemoveRelation: '' as IntlString }, icon: { Table: '' as Asset, diff --git a/server/postgres/src/schemas.ts b/server/postgres/src/schemas.ts index fc16a10b3f..1405af15c1 100644 --- a/server/postgres/src/schemas.ts +++ b/server/postgres/src/schemas.ts @@ -101,6 +101,11 @@ const relationSchema: Schema = { type: 'text', notNull: true, index: true + }, + association: { + type: 'text', + notNull: true, + index: true } } diff --git a/server/postgres/src/storage.ts b/server/postgres/src/storage.ts index ce4f71be38..32effa722b 100644 --- a/server/postgres/src/storage.ts +++ b/server/postgres/src/storage.ts @@ -1449,6 +1449,7 @@ abstract class PostgresAdapterBase implements DbAdapter { ON relation."${keyB}" = assoc."_id" AND relation."workspaceId" = ${wsId} WHERE relation."${keyA}" = ${translateDomain(baseDomain)}."_id" + AND relation.association = '${_id}' AND assoc."workspaceId" = ${wsId}) AS assoc_${tagetDomain}_${association[0]}` ) }