Merge master -> master_vca_intg
[osm/UI.git] / skyquake / plugins / composer / src / src / stores / CatalogDataStore.js
index 144332c..ea57627 100644 (file)
@@ -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);