add folder data source
This commit is contained in:
@@ -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<DataSourceResponse<PartialViewDetails>> {
|
||||
/**
|
||||
* 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<DataSourceResponse<PartialViewDetails>>}
|
||||
* @memberof UmbPartialViewDetailServerDataSource
|
||||
*/
|
||||
createScaffold(parentId: string | null = null, preset: string): Promise<DataSourceResponse<PartialViewDetails>> {
|
||||
return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewSnippetByName({ name: preset }));
|
||||
}
|
||||
/**
|
||||
* Get possible snippets for partial views
|
||||
*
|
||||
* @param {*} { skip = 0, take = 100 }
|
||||
* @return {*} {Promise<DataSourceResponse<PagedSnippetItemResponseModel>>}
|
||||
* @memberof UmbPartialViewDetailServerDataSource
|
||||
*/
|
||||
getSnippets({ skip = 0, take = 100 }): Promise<DataSourceResponse<PagedSnippetItemResponseModel>> {
|
||||
return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewSnippet({ skip, take }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a partial view with the given path from the server
|
||||
|
||||
@@ -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<DataSourceResponse<FolderReponseModel>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
get(unique: string): Promise<DataSourceResponse<FolderReponseModel>> {
|
||||
return tryExecuteAndNotify(this.#host, PartialViewResource.getPartialViewFolder({ path: unique }));
|
||||
}
|
||||
insert(requestBody: CreateFolderRequestModel): Promise<DataSourceResponse<string>> {
|
||||
return tryExecuteAndNotify(this.#host, PartialViewResource.postPartialViewFolder({ requestBody }));
|
||||
}
|
||||
update(unique: string, data: CreateFolderRequestModel): Promise<DataSourceResponse<FolderModelBaseModel>> {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
delete(path: string): Promise<DataSourceResponse<unknown>> {
|
||||
return tryExecuteAndNotify(this.#host, PartialViewResource.deletePartialViewFolder({ path }));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user