From 7d0436dd0a8b107b030170947b4c746e462a5e2f Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 30 Jun 2017 20:12:11 +0900 Subject: [PATCH] update it --- webui/src/modules/crud/reducers.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webui/src/modules/crud/reducers.js b/webui/src/modules/crud/reducers.js index 7360c35a28..50ea927349 100644 --- a/webui/src/modules/crud/reducers.js +++ b/webui/src/modules/crud/reducers.js @@ -103,11 +103,14 @@ function collectionsReducer(state = collectionsInitialState, action) { return state.update(index, s => collectionReducer(s, action)); case CRUD.CREATE_SUCCESS: const idProperty = action.meta ? action.meta.idProperty : '_id'; - return state.map((item, idx) => ( + /* At this point, the ID is stored in the 0-index collection. + Later you will need to find the collection to which you want to add the ID. */ + return state.update(0, item => ( item.set('ids', item.get('ids').push(action.payload.data[idProperty])) )) case CRUD.DELETE_SUCCESS: const id = action.meta ? action.meta.id : undefined; + /* Find ID from all collections and delete them if they exist. */ return state.map((item, idx) => ( item.set('ids', item.get('ids').filter(x => x !== id)) ))