update common entity actions

This commit is contained in:
Mads Rasmussen
2024-03-02 23:10:37 +01:00
parent 38ab9a9f71
commit 2b385e7be5
4 changed files with 27 additions and 29 deletions

View File

@@ -1,13 +1,12 @@
import { UmbEntityActionBase } from '../../entity-action.js';
import { UmbEntityActionBase } from '../../entity-action-base.js';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
export class UmbCopyEntityAction<T extends { copy(): Promise<void> }> extends UmbEntityActionBase<T> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
export class UmbCopyEntityAction extends UmbEntityActionBase<any> {
constructor(host: UmbControllerHostElement, args: any) {
super(host, args);
}
async execute() {
console.log(`execute for: ${this.unique}`);
await this.repository?.copy();
console.log(`execute copy for: ${this.args.unique}`);
}
}

View File

@@ -1,15 +1,12 @@
import { UmbEntityActionBase } from '../../entity-action.js';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UmbEntityActionBase } from '../../entity-action-base.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
// TODO: investigate what we need to finish the generic move action. We would need to open a picker, which requires a modal token,
// maybe we can use kinds to make a specific manifest to the move action.
export class UmbMoveEntityAction<T extends { move(): Promise<void> }> extends UmbEntityActionBase<T> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
export class UmbMoveEntityAction extends UmbEntityActionBase<any> {
constructor(host: UmbControllerHost, args: any) {
super(host, args);
}
async execute() {
console.log(`execute for: ${this.unique}`);
await this.repository?.move();
console.log(`execute move for: ${this.args.unique}`);
}
}

View File

@@ -1,15 +1,12 @@
import { UmbEntityActionBase } from '../../entity-action.js';
import { UmbEntityActionBase } from '../../entity-action-base.js';
import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
export class UmbSortChildrenOfEntityAction<
T extends { sortChildrenOf(): Promise<void> },
> extends UmbEntityActionBase<T> {
constructor(host: UmbControllerHostElement, repositoryAlias: string, unique: string, entityType: string) {
super(host, repositoryAlias, unique, entityType);
export class UmbSortChildrenOfEntityAction extends UmbEntityActionBase<any> {
constructor(host: UmbControllerHostElement, args: any) {
super(host, args);
}
async execute() {
console.log(`execute for: ${this.unique}`);
await this.repository?.sortChildrenOf();
console.log(`execute sort for: ${this.args.unique}`);
}
}

View File

@@ -1,11 +1,15 @@
import { UmbEntityActionBase } from '../../entity-action.js';
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import type { UmbItemRepository } from '@umbraco-cms/backoffice/repository';
import { UmbEntityActionBase } from '../../entity-action-base.js';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
//import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
export class UmbTrashEntityAction extends UmbEntityActionBase<any> {
constructor(host: UmbControllerHost, args: any) {
super(host, args);
}
export class UmbTrashEntityAction<
T extends UmbItemRepository<any> & { trash(unique: string): Promise<void> },
> extends UmbEntityActionBase<T> {
async execute() {
console.log(`execute trash for: ${this.args.unique}`);
/*
if (!this.repository) return;
const { data } = await this.repository.requestItems([this.unique]);
@@ -22,5 +26,6 @@ export class UmbTrashEntityAction<
this.repository?.trash(this.unique);
}
*/
}
}