add mock handler for move to recycle bin
This commit is contained in:
@@ -64,8 +64,6 @@ export class UmbEntityData<T extends UmbEntityBase> extends UmbData<T> {
|
||||
const item = this.getById(id);
|
||||
if (!item) return;
|
||||
|
||||
// TODO: how do we handle trashed items?
|
||||
// TODO: remove ignore when we know how to handle trashed items.
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
item.isTrashed = true;
|
||||
|
||||
@@ -4,45 +4,35 @@ import { umbracoPath } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
// TODO: add schema
|
||||
export const handlers = [
|
||||
rest.post<string[]>(umbracoPath('/document/trash'), async (req, res, ctx) => {
|
||||
console.warn('Please move to schema');
|
||||
const ids = await req.json();
|
||||
|
||||
const trashed = umbDocumentData.trash(ids);
|
||||
|
||||
return res(ctx.status(200), ctx.json(trashed));
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath('/document/root/allowed-document-types'), (req, res, ctx) => {
|
||||
const response = umbDocumentData.getAllowedDocumentTypesAtRoot();
|
||||
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.put(umbracoPath('/document/:id/move-to-recycle-bin'), async (req, res, ctx) => {
|
||||
const id = req.params.id as string;
|
||||
umbDocumentData.trash([id]);
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath('/document/:id/allowed-document-types'), (req, res, ctx) => {
|
||||
const id = req.params.id as string;
|
||||
if (!id) return;
|
||||
|
||||
const response = umbDocumentData.getDocumentByIdAllowedDocumentTypes(id);
|
||||
|
||||
return res(ctx.status(200), ctx.json(response));
|
||||
}),
|
||||
|
||||
rest.get(umbracoPath('/document/:id'), (req, res, ctx) => {
|
||||
const id = req.params.id as string;
|
||||
if (!id) return;
|
||||
|
||||
const document = umbDocumentData.getById(id);
|
||||
|
||||
return res(ctx.status(200), ctx.json(document));
|
||||
}),
|
||||
|
||||
rest.delete(umbracoPath('/document/:id'), (req, res, ctx) => {
|
||||
const id = req.params.id as string;
|
||||
if (!id) return;
|
||||
|
||||
const document = umbDocumentData.getById(id);
|
||||
|
||||
return res(ctx.status(200), ctx.json(document));
|
||||
}),
|
||||
|
||||
@@ -51,18 +41,14 @@ export const handlers = [
|
||||
if (!id) return;
|
||||
const data = await req.json();
|
||||
if (!data) return;
|
||||
|
||||
const saved = umbDocumentData.save(id, data);
|
||||
|
||||
return res(ctx.status(200), ctx.json(saved));
|
||||
}),
|
||||
|
||||
rest.post(umbracoPath(`/document`), async (req, res, ctx) => {
|
||||
const data = await req.json();
|
||||
if (!data) return;
|
||||
|
||||
umbDocumentData.insert(data);
|
||||
|
||||
return res(ctx.status(200));
|
||||
}),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user