Editorial workflow Drag'nDrop

This commit is contained in:
Cássio Zen
2016-09-13 16:00:24 -03:00
parent e2b6e140f3
commit 0b447d483d
10 changed files with 237 additions and 61 deletions

View File

@ -1,7 +1,11 @@
import { Map, List, fromJS } from 'immutable';
import { EDITORIAL_WORKFLOW } from '../constants/publishModes';
import {
UNPUBLISHED_ENTRY_REQUEST, UNPUBLISHED_ENTRY_SUCCESS, UNPUBLISHED_ENTRIES_REQUEST, UNPUBLISHED_ENTRIES_SUCCESS
UNPUBLISHED_ENTRY_REQUEST,
UNPUBLISHED_ENTRY_SUCCESS,
UNPUBLISHED_ENTRIES_REQUEST,
UNPUBLISHED_ENTRIES_SUCCESS,
UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS
} from '../actions/editorialWorkflow';
import { CONFIG_SUCCESS } from '../actions/config';
@ -39,6 +43,21 @@ const unpublishedEntries = (state = null, action) => {
ids: List(entries.map((entry) => entry.slug))
}));
});
case UNPUBLISHED_ENTRY_STATUS_CHANGE_SUCCESS:
const { slug, oldStatus, newStatus } = action.payload;
return state.withMutations((map) => {
const entry = map.getIn(['entities', `${oldStatus}.${slug}`]);
let entities = map.get('entities').filter((val, key) => (
key !== `${oldStatus}.${slug}`
));
entities = entities.set(`${newStatus}.${slug}`, entry);
map.set('entities', entities);
});
default:
return state;
}