add file system item store
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { UmbStoreBase } from './store-base.js';
|
||||
import { UmbItemStore } from './item-store.interface.js';
|
||||
import type { FileItemResponseModelBaseModel } from '@umbraco-cms/backoffice/backend-api';
|
||||
import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
|
||||
import { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbFileSystemItemStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Data Store for File system items
|
||||
*/
|
||||
|
||||
export class UmbFileSystemItemStore<T extends FileItemResponseModelBaseModel>
|
||||
extends UmbStoreBase<T>
|
||||
implements UmbItemStore<T>
|
||||
{
|
||||
constructor(host: UmbControllerHost, storeAlias: string) {
|
||||
super(host, storeAlias, new UmbArrayState<T>([], (x) => x.path));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an observable to observe file system items
|
||||
* @param {Array<string>} ids
|
||||
* @return {*}
|
||||
* @memberof UmbFileSystemItemStore
|
||||
*/
|
||||
items(ids: Array<string>) {
|
||||
return this._data.asObservablePart((items) => items.filter((item) => ids.includes(item.path ?? '')));
|
||||
}
|
||||
}
|
||||
@@ -5,3 +5,4 @@ export * from './store-base.js';
|
||||
export * from './store.interface.js';
|
||||
export * from './store.js';
|
||||
export * from './tree-store.interface.js';
|
||||
export * from './file-system-item.store.js';
|
||||
|
||||
Reference in New Issue
Block a user