dont use store, use context
This commit is contained in:
@@ -18,11 +18,20 @@ export interface UmbTreeStore<T> extends UmbDataStore {
|
||||
// Notice: this might not be right to put here as only some content items has ability to be trashed.
|
||||
/**
|
||||
* @description - Trash data.
|
||||
* @param {object} data
|
||||
* @param {string[]} keys
|
||||
* @return {*} {(Promise<void>)}
|
||||
* @memberof UmbContentStore
|
||||
* @memberof UmbTreeStore
|
||||
*/
|
||||
trash(keys: string[]): Promise<void>;
|
||||
|
||||
// Notice: this might not be right to put here as only some content items has ability to be moved.
|
||||
/**
|
||||
* @description - Move data.
|
||||
* @param {string[]} keys
|
||||
* @return {*} {(Promise<void>)}
|
||||
* @memberof UmbTreeStore
|
||||
*/
|
||||
move(keys: string[], destination: string): Promise<void>;
|
||||
}
|
||||
|
||||
export interface UmbEntityDetailStore<T> extends UmbDataStore {
|
||||
|
||||
@@ -4,7 +4,6 @@ import { customElement } from 'lit/decorators.js';
|
||||
import { ifDefined } from 'lit/directives/if-defined.js';
|
||||
import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_TOKEN } from '../collection.context';
|
||||
import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_TOKEN } from '../../../../core/modal';
|
||||
import { UmbMediaTreeStore, UMB_MEDIA_TREE_STORE_CONTEXT_TOKEN } from '../../../media/media/media.tree.store';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
import type { ManifestCollectionBulkAction } from '@umbraco-cms/models';
|
||||
|
||||
@@ -18,7 +17,6 @@ export class UmbCollectionBulkActionMoveElement extends UmbLitElement {
|
||||
public manifest?: ManifestCollectionBulkAction;
|
||||
|
||||
#modalService?: UmbModalService;
|
||||
#mediaTreeStore?: UmbMediaTreeStore;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
@@ -31,9 +29,6 @@ export class UmbCollectionBulkActionMoveElement extends UmbLitElement {
|
||||
this.#modalService = instance;
|
||||
});
|
||||
|
||||
this.consumeContext(UMB_MEDIA_TREE_STORE_CONTEXT_TOKEN, (instance) => {
|
||||
this.#mediaTreeStore = instance;
|
||||
});
|
||||
}
|
||||
|
||||
#handleClick() {
|
||||
@@ -44,7 +39,7 @@ export class UmbCollectionBulkActionMoveElement extends UmbLitElement {
|
||||
});
|
||||
modalHandler?.onClose().then((data) => {
|
||||
if (selection.length > 0) {
|
||||
this.#mediaTreeStore?.move(selection, data.selection[0]);
|
||||
this.#collectionContext?.move(selection, data.selection[0]);
|
||||
}
|
||||
selectionSubscription?.unsubscribe();
|
||||
this.#collectionContext?.clearSelection();
|
||||
|
||||
@@ -93,10 +93,15 @@ export class UmbCollectionContext<
|
||||
}
|
||||
|
||||
// TODO: Not all can trash, so maybe we need to differentiate on collection contexts or fix it with another architecture.
|
||||
public trash(keys:string[]) {
|
||||
public trash(keys: string[]) {
|
||||
this._store?.trash(keys);
|
||||
}
|
||||
|
||||
// TODO: Not all can move, so maybe we need to differentiate on collection contexts or fix it with another architecture.
|
||||
public move(keys: string[], destination: string) {
|
||||
this._store?.move(keys, destination);
|
||||
}
|
||||
|
||||
public clearSelection() {
|
||||
this.#selection.next([]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user