diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/repository/document-type.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/repository/document-type.repository.ts index 512eed6d57..4e30ddd64f 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/repository/document-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/document-types/repository/document-type.repository.ts @@ -14,11 +14,12 @@ import { } from '@umbraco-cms/backoffice/backend-api'; import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification'; -type ItemType = DocumentTypeResponseModel & {$type: string}; +type ItemType = DocumentTypeResponseModel & { $type: string }; export class UmbDocumentTypeRepository - implements UmbTreeRepository, - UmbDetailRepository + implements + UmbTreeRepository, + UmbDetailRepository { #init!: Promise; @@ -148,7 +149,7 @@ export class UmbDocumentTypeRepository this.#detailStore?.append(data); } - return { data, error }; + return { data, error, asObservable: () => this.#detailStore!.byId(id) }; } async byId(id: string) { @@ -167,25 +168,22 @@ export class UmbDocumentTypeRepository // Could potentially be general methods: async create(documentType: ItemType) { - if (!documentType || !documentType.id) throw new Error('Template is missing'); await this.#init; const { error, data } = await this.#detailDataSource.insert(documentType); if (!error && data) { - // TODO: The parts here is a hack, when we can trust the IDs we send, then this should be removed/changed: - const splitResultUrl = data.split("/"); + const splitResultUrl = data.split('/'); const newId = splitResultUrl[splitResultUrl.length - 1]; // Temporary hack while we are not in control of IDs: - const newDocument = {...(await this.requestById(newId)).data, $type: ''}; - - if(newDocument) { + const newDocument = { ...(await this.requestById(newId)).data, $type: '' }; + if (newDocument) { const notification = { data: { message: `Document Type created` } }; this.#notificationContext?.peek('positive', notification); diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/document.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/document.repository.ts index 9ccd7feb2c..130e7b633d 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/document.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/repository/document.repository.ts @@ -14,8 +14,9 @@ import { import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification'; export class UmbDocumentRepository - implements UmbTreeRepository, - UmbDetailRepository + implements + UmbTreeRepository, + UmbDetailRepository { #init!: Promise; @@ -144,7 +145,7 @@ export class UmbDocumentRepository this.#store?.append(data); } - return { data, error }; + return { data, error, asObservable: () => this.#store!.byId(id) }; } async byId(id: string) { @@ -176,7 +177,6 @@ export class UmbDocumentRepository this.#notificationContext?.peek('positive', notification); } - return { error }; } diff --git a/src/Umbraco.Web.UI.Client/src/packages/settings/data-types/repository/data-type.repository.ts b/src/Umbraco.Web.UI.Client/src/packages/settings/data-types/repository/data-type.repository.ts index 51eb0d84a6..9fcad97e91 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/settings/data-types/repository/data-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/settings/data-types/repository/data-type.repository.ts @@ -179,7 +179,7 @@ export class UmbDataTypeRepository this.#detailStore?.append(data); } - return { data, error }; + return { data, error, asObservable: () => this.#detailStore!.byId(id) }; } async byId(id: string) {