From 94bf7082362ccbef5ff96616dd6d5bf91c5ae0aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 10 Mar 2023 21:28:25 +1300 Subject: [PATCH] data works --- .../src/core/mocks/data/relation-type.data.ts | 69 +++++++++++++++---- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/mocks/data/relation-type.data.ts b/src/Umbraco.Web.UI.Client/src/core/mocks/data/relation-type.data.ts index 4f2694086a..b9781cdc84 100644 --- a/src/Umbraco.Web.UI.Client/src/core/mocks/data/relation-type.data.ts +++ b/src/Umbraco.Web.UI.Client/src/core/mocks/data/relation-type.data.ts @@ -1,9 +1,9 @@ import { UmbEntityData } from './entity.data'; -import { createEntityTreeItem } from './utils'; -import type { FolderTreeItemModel, RelationTypeResponseModel } from '@umbraco-cms/backend-api'; +import { createEntityTreeItem, createFolderTreeItem } from './utils'; +import type { EntityTreeItemModel, FolderTreeItemModel, RelationTypeResponseModel } from '@umbraco-cms/backend-api'; // TODO: investigate why we don't get an entity type as part of the RelationTypeResponseModel -export const data: Array = [ +export const data: Array = [ { key: 'e0d39ff5-71d8-453f-b682-9d8d31ee5e06', alias: 'relateDocumentOnCopy', @@ -16,8 +16,6 @@ export const data: Array childObjectType: 'Document', parentObjectTypeName: 'Document', childObjectTypeName: 'Document', - type: 'relation-type', - parentKey: null, }, { key: 'ac68cde6-763f-4231-a751-1101b57defd2', @@ -31,8 +29,6 @@ export const data: Array childObjectType: 'Document', parentObjectTypeName: 'Document', childObjectTypeName: 'Document', - type: 'relation-type', - parentKey: null, }, { key: '6f9b800c-762c-42d4-85d9-bf40a77d689e', @@ -46,8 +42,6 @@ export const data: Array childObjectType: 'Document', parentObjectTypeName: 'Document', childObjectTypeName: 'Document', - type: 'relation-type', - parentKey: null, }, { key: 'd421727d-43de-4205-b4c6-037404f309ad', @@ -61,8 +55,6 @@ export const data: Array childObjectType: 'Document', parentObjectTypeName: 'Document', childObjectTypeName: 'Document', - type: 'relation-type', - parentKey: null, }, { key: 'e9a0a28e-2d5b-4229-ac00-66f2df230513', @@ -76,8 +68,54 @@ export const data: Array childObjectType: 'Document', parentObjectTypeName: 'Document', childObjectTypeName: 'Document', - type: 'relation-type', + }, +]; + +export const treeData: Array = [ + { + key: 'e0d39ff5-71d8-453f-b682-9d8d31ee5e06', + $type: 'EntityTreeItemViewModel', + isContainer: false, parentKey: null, + name: 'Relate Document On Copy', + icon: 'umb:trafic', + type: 'relation-type', + }, + { + key: 'ac68cde6-763f-4231-a751-1101b57defd2', + $type: 'EntityTreeItemViewModel', + isContainer: false, + parentKey: null, + name: 'Relate Parent Document On Delete', + icon: 'umb:trafic', + type: 'relation-type', + }, + { + key: '6f9b800c-762c-42d4-85d9-bf40a77d689e', + $type: 'EntityTreeItemViewModel', + isContainer: false, + parentKey: null, + name: 'Relate Parent Media Folder On Delete', + icon: 'umb:trafic', + type: 'relation-type', + }, + { + key: 'd421727d-43de-4205-b4c6-037404f309ad', + $type: 'EntityTreeItemViewModel', + isContainer: false, + parentKey: null, + name: 'Related Media', + icon: 'umb:trafic', + type: 'relation-type', + }, + { + key: 'e9a0a28e-2d5b-4229-ac00-66f2df230513', + $type: 'EntityTreeItemViewModel', + isContainer: false, + parentKey: null, + name: 'Related Document', + icon: 'umb:trafic', + type: 'relation-type', }, ]; @@ -86,24 +124,25 @@ export const data: Array // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore class UmbRelationTypeData extends UmbEntityData { + private treeData = treeData; constructor() { super(data); } //TODO Can relation types have children? getTreeRoot(): Array { - const rootItems = this.data; + const rootItems = this.treeData; return rootItems.map((item) => createEntityTreeItem(item)); } //TODO Can relation types have children? getTreeItemChildren(): Array { - const childItems = this.data; + const childItems = this.treeData; return childItems.map((item) => createEntityTreeItem(item)); } getTreeItem(keys: Array): Array { - const items = this.data.filter((item) => keys.includes(item.key ?? '')); + const items = this.treeData.filter((item) => keys.includes(item.key ?? '')); return items.map((item) => createEntityTreeItem(item)); } }