New: Project Aphrodite

This commit is contained in:
Qstick
2018-11-23 02:04:42 -05:00
parent 65efa15551
commit 8430cb40ab
1080 changed files with 73015 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import _ from 'lodash';
import getSectionState from 'Utilities/State/getSectionState';
function getProviderState(payload, getState, section) {
const {
id,
...otherPayload
} = payload;
const state = getSectionState(getState(), section, true);
const pendingChanges = Object.assign({}, state.pendingChanges, otherPayload);
const pendingFields = state.pendingChanges.fields || {};
delete pendingChanges.fields;
const item = id ? _.find(state.items, { id }) : state.selectedSchema || state.schema || {};
if (item.fields) {
pendingChanges.fields = _.reduce(item.fields, (result, field) => {
const name = field.name;
const value = pendingFields.hasOwnProperty(name) ?
pendingFields[name] :
field.value;
// Only send the name and value to the server
result.push({
name,
value
});
return result;
}, []);
}
const result = Object.assign({}, item, pendingChanges);
delete result.presets;
return result;
}
export default getProviderState;