Skip to content
Snippets Groups Projects
Commit 3490ad83 authored by Lewis Liu's avatar Lewis Liu
Browse files

Implemented details editing for databases and fields

parent 4c4944d5
Branches
Tags
No related merge requests found
......@@ -54,7 +54,7 @@ export const fetchData = async ({dispatch, getState, requestStatePath, existingS
return existingData;
}
}
//TODO: test this thoroughly
export const updateData = async ({dispatch, getState, requestStatePath, existingStatePath, putData}) => {
const existingData = i.getIn(getState(), existingStatePath);
const statePath = requestStatePath.concat(['update']);
......
......@@ -61,21 +61,35 @@ export default class EntityItem extends Component {
startEditing,
endEditing,
hasDisplayName,
updateTable,
handleSubmit,
submitting
} = this.props;
return (
<div className="full">
<form onSubmit={handleSubmit(fields => {
<form onSubmit={handleSubmit(async fields => {
console.log(entity)
const editedFields = Object.keys(fields)
.filter(key => fields[key] !== undefined)
.reduce((map, key) => i.assoc(map, key, fields[key]), {});
const newEntity = {...entity, ...editedFields};
console.log(newEntity)
//TODO: add update function to sections instead
switch(section.type) {
case "table":
await this.props.updateTable(newEntity);
break;
case "field":
await this.props.updateField(newEntity);
break;
case "database":
//FIXME: description field has no backend support right now
// only name updates work at the moment
await this.props.updateDatabase(newEntity);
break;
}
updateTable(newEntity);
endEditing();
})}>
{ isEditing &&
......
......@@ -476,7 +476,6 @@ export const getBreadcrumbs = createSelector(
export const getHasDisplayName = createSelector(
[getSection],
(section) =>
section.type === 'database' ||
section.type === 'table' ||
section.type === 'field'
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment