- dispatch(collectionPanelActions.LOAD_COLLECTION({ uuid, kind }));
- return services.collectionService
- .get(uuid)
- .then(item => {
- dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource }));
- });
+ const item = getState().collectionPanel.item;
+ if (!item) { return; }
+
+ const properties = Object.assign({}, item.properties);
+ const key = data.keyID || data.key;
+ const value = data.valueID || data.value;
+ services.collectionService.update(
+ item.uuid, {
+ properties: addProperty(properties, key, value)
+ }
+ ).then(updatedCollection => {
+ dispatch(collectionPanelActions.SET_COLLECTION(updatedCollection));
+ dispatch(resourcesActions.SET_RESOURCES([updatedCollection]));
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: "Property has been successfully added.",
+ hideDuration: 2000,
+ kind: SnackbarKind.SUCCESS }));
+ dispatch<any>(loadDetailsPanel(updatedCollection.uuid));
+ return updatedCollection;
+ }).catch (e =>
+ dispatch(snackbarActions.OPEN_SNACKBAR({
+ message: e.errors[0],
+ hideDuration: 2000,
+ kind: SnackbarKind.ERROR }))
+ );