diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.ts index 07f47ec28b..5661ab262a 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.detail.server.data.ts @@ -1,6 +1,7 @@ import { PartialViewDetails } from '../../config.js'; import { CreatePartialViewRequestModel, + PagedSnippetItemResponseModel, PartialViewResource, PartialViewResponseModel, UpdatePartialViewRequestModel, @@ -25,10 +26,27 @@ export class UmbPartialViewDetailServerDataSource this.#host = host; } - //TODO check if this is correct - createScaffold(parentid: string | null = null, preset: string): Promise> { + /** + * Creates a new partial view scaffold + * + * @param {(string | null)} [parentId=null] You can leave this empty + * @param {string} preset Name of the snippet to use as a preset + * @return {*} {Promise>} + * @memberof UmbPartialViewDetailServerDataSource + */ + createScaffold(parentId: string | null = null, preset: string): Promise> { return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewSnippetByName({ name: preset })); } + /** + * Get possible snippets for partial views + * + * @param {*} { skip = 0, take = 100 } + * @return {*} {Promise>} + * @memberof UmbPartialViewDetailServerDataSource + */ + getSnippets({ skip = 0, take = 100 }): Promise> { + return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewSnippet({ skip, take })); + } /** * Fetches a partial view with the given path from the server diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.folder.server.data.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.folder.server.data.ts new file mode 100644 index 0000000000..b10a3c473a --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/repository/sources/partial-views.folder.server.data.ts @@ -0,0 +1,32 @@ +import { + CreateFolderRequestModel, + FolderModelBaseModel, + FolderReponseModel, + PartialViewResource, +} from '@umbraco-cms/backoffice/backend-api'; +import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { DataSourceResponse, UmbFolderDataSource } from '@umbraco-cms/backoffice/repository'; +import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; + +export class UmbPartialViewsTreeServerDataSource implements UmbFolderDataSource { + #host: UmbControllerHostElement; + + constructor(host: UmbControllerHostElement) { + this.#host = host; + } + createScaffold(parentId: string | null): Promise> { + throw new Error('Method not implemented.'); + } + get(unique: string): Promise> { + return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewFolder({ path: unique })); + } + insert(requestBody: CreateFolderRequestModel): Promise> { + return tryExecuteAndNotify(this.#host, PartialViewResource.postPartialViewFolder({ requestBody })); + } + update(unique: string, data: CreateFolderRequestModel): Promise> { + throw new Error('Method not implemented.'); + } + delete(path: string): Promise> { + return tryExecuteAndNotify(this.#host, PartialViewResource.deletePartialViewFolder({ path })); + } +}