X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fstores%2FCatalogDataStore.js;h=ea57627603c40a5dcce9a0447a5224d4d7f8b3d6;hb=5d3c7164d13c5915370a48fb0b747a95777d9f24;hp=144332cb61a1ccafc1541174b8e6e97077a42b4e;hpb=e29efc315df33d546237e270470916e26df391d6;p=osm%2FUI.git diff --git a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js index 144332cb6..ea5762760 100644 --- a/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js +++ b/skyquake/plugins/composer/src/src/stores/CatalogDataStore.js @@ -61,6 +61,14 @@ class CatalogDataStore { this.registerAsync(CatalogDataSource); this.bindActions(CatalogDataSourceActions); this.bindActions(CatalogItemsActions); + this.exportPublicMethods({ + getCatalogs: this.getCatalogs, + getCatalogItemById: this.getCatalogItemById, + getCatalogItemByUid: this.getCatalogItemByUid, + getTransientCatalogs: this.getTransientCatalogs, + getTransientCatalogItemById: this.getTransientCatalogItemById, + getTransientCatalogItemByUid: this.getTransientCatalogItemByUid + }); } resetSelectionState = () => { @@ -72,6 +80,10 @@ class CatalogDataStore { return this.catalogs || (this.catalogs = []); } + getTransientCatalogs() { + return this.state.catalogs || (this.state.catalogs = []); + } + getAllSelectedCatalogItems() { return this.getCatalogs().reduce((r, d) => { d.descriptors.forEach(d => { @@ -95,12 +107,24 @@ class CatalogDataStore { }, [])[0]; } + getTransientCatalogItemById(id) { + return this.getTransientCatalogs().reduce((r, catalog) => { + return r.concat(catalog.descriptors.filter(d => d.id === id)); + }, [])[0]; + } + getCatalogItemByUid(uid) { return this.getCatalogs().reduce((r, catalog) => { return r.concat(catalog.descriptors.filter(d => UID.from(d) === uid)); }, [])[0]; } + getTransientCatalogItemByUid(uid) { + return this.getTransientCatalogs().reduce((r, catalog) => { + return r.concat(catalog.descriptors.filter(d => UID.from(d) === uid)); + }, [])[0]; + } + removeCatalogItem(deleteItem = {}) { this.getCatalogs().map(catalog => { catalog.descriptors = catalog.descriptors.filter(d => d.id !== deleteItem.id);