From 1905f6c83ab2177a2740639e3473c5daf9975990 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Fri, 24 Nov 2023 10:01:24 +0100 Subject: [PATCH] use unique --- .../repository/copy/data-type-copy.repository.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/data-type/repository/copy/data-type-copy.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/core/data-type/repository/copy/data-type-copy.repository.ts index 14abf76745..15fcb02dd1 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/data-type/repository/copy/data-type-copy.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/data-type/repository/copy/data-type-copy.repository.ts @@ -14,26 +14,22 @@ export class UmbCopyDataTypeRepository extends UmbDataTypeRepositoryBase impleme this.#detailRepository = new UmbDataTypeDetailRepository(this); } - async copy(id: string, targetId: string | null) { + async copy(unique: string, targetUnique: string | null) { await this._init; - const { data: dataTypeCopyId, error } = await this.#copySource.copy(id, targetId); + const { data: dataTypeCopyUnique, error } = await this.#copySource.copy(unique, targetUnique); if (error) return { error }; - if (dataTypeCopyId) { - const { data: dataTypeCopy } = await this.#detailRepository.requestByUnique(dataTypeCopyId); + if (dataTypeCopyUnique) { + const { data: dataTypeCopy } = await this.#detailRepository.requestByUnique(dataTypeCopyUnique); if (!dataTypeCopy) throw new Error('Could not find copied data type'); // TODO: Be aware about this responsibility. - this._treeStore!.appendItems([dataTypeCopy]); - // only update the target if its not the root - if (targetId) { - this._treeStore!.updateItem(targetId, { hasChildren: true }); - } + this._treeStore!.append(dataTypeCopy); const notification = { data: { message: `Data type copied` } }; this._notificationContext!.peek('positive', notification); } - return { data: dataTypeCopyId }; + return { data: dataTypeCopyUnique }; } }