Allow the creation of new entries

This commit is contained in:
Cássio Zen
2016-08-24 21:36:44 -03:00
parent fd79381160
commit b717874e7b
9 changed files with 73 additions and 29 deletions

View File

@ -13,6 +13,7 @@ export const ENTRIES_SUCCESS = 'ENTRIES_SUCCESS';
export const ENTRIES_FAILURE = 'ENTRIES_FAILURE';
export const DRAFT_CREATE_FROM_ENTRY = 'DRAFT_CREATE_FROM_ENTRY';
export const DRAFT_CREATE_EMPTY = 'DRAFT_CREATE_EMPTY';
export const DRAFT_DISCARD = 'DRAFT_DISCARD';
export const DRAFT_CHANGE = 'DRAFT_CHANGE';
@ -102,6 +103,13 @@ function entryPersistFail(collection, entry, error) {
};
}
function emmptyDraftCreated(entry) {
return {
type: DRAFT_CREATE_EMPTY,
payload: entry
};
}
/*
* Exported simple Action Creators
*/
@ -153,6 +161,15 @@ export function loadEntries(collection) {
};
}
export function createEmptyDraft(collection) {
return (dispatch, getState) => {
const state = getState();
const backend = currentBackend(state.config);
const newEntry = backend.newEntry(collection);
dispatch(emmptyDraftCreated(newEntry));
};
}
export function persistEntry(collection, entry) {
return (dispatch, getState) => {
const state = getState();