return correct response from stylesheet items end point
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
InterpolateRichTextStylesheetRequestModel,
|
||||
PagedFileSystemTreeItemPresentationModel,
|
||||
PagedStylesheetOverviewResponseModel,
|
||||
StylesheetItemResponseModel,
|
||||
StylesheetResponseModel,
|
||||
UpdateStylesheetRequestModel,
|
||||
} from '@umbraco-cms/backoffice/backend-api';
|
||||
@@ -138,8 +139,9 @@ class UmbStylesheetData extends UmbData<StylesheetDBItem> {
|
||||
return items.map((item) => createFileSystemTreeItem(item));
|
||||
}
|
||||
|
||||
getStylesheetItem(path: string): StylesheetDBItem | undefined {
|
||||
return createFileItemResponseModelBaseModel(this.data.find((item) => item.path === path));
|
||||
getItems(paths: Array<string>): Array<StylesheetItemResponseModel> {
|
||||
const items = this.data.filter((item) => paths.includes(item.path ?? ''));
|
||||
return items.map((item) => createFileItemResponseModelBaseModel(item));
|
||||
}
|
||||
|
||||
getStylesheet(path: string): StylesheetResponseModel | undefined {
|
||||
|
||||
@@ -39,6 +39,7 @@ const detailHandlers = [
|
||||
const response = umbStylesheetData.getStylesheet(path);
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.post(umbracoPath('/stylesheet'), async (req, res, ctx) => {
|
||||
const requestBody = (await req.json()) as CreateTextFileViewModelBaseModel;
|
||||
if (!requestBody) return res(ctx.status(400, 'no body found'));
|
||||
@@ -52,6 +53,7 @@ const detailHandlers = [
|
||||
const response = umbStylesheetData.delete([path]);
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.put(umbracoPath('/stylesheet'), async (req, res, ctx) => {
|
||||
const requestBody = (await req.json()) as UpdateStylesheetRequestModel;
|
||||
if (!requestBody) return res(ctx.status(400, 'no body found'));
|
||||
@@ -66,11 +68,12 @@ const detailHandlers = [
|
||||
const response = umbStylesheetData.getAllStylesheets();
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath('/v1/stylesheet/item'), (req, res, ctx) => {
|
||||
const paths = req.url.searchParams.getAll('path');
|
||||
if (!paths) return;
|
||||
|
||||
const items = umbStylesheetData.getStylesheetItem(paths[0]);
|
||||
const items = umbStylesheetData.getItems(paths);
|
||||
return res(ctx.status(200), ctx.json(items));
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user