fix: saving options when creating select column

This commit is contained in:
shams mosowi
2019-09-25 12:44:37 +10:00
parent 970f257d5c
commit ddd7412794
2 changed files with 10 additions and 5 deletions

View File

@@ -126,8 +126,13 @@ const ColumnEditor = (props: any) => {
};
const createNewColumn = () => {
const { name, type } = values;
actions.add(name, type);
const { name, type, options } = values;
if (type === FieldType.multiSelect || type === FieldType.singleSelect) {
actions.add(name, type, { options: values.options });
} else {
actions.add(name, type);
}
handleClose();
clearValues();
};
@@ -136,6 +141,7 @@ const ColumnEditor = (props: any) => {
handleClose();
clearValues();
};
const updateColumn = () => {
let updatables: { field: string; value: any }[] = [
{ field: "name", value: values.name },
@@ -201,7 +207,6 @@ const ColumnEditor = (props: any) => {
label="Column name"
name="name"
defaultValue={values.name}
// onChange={handleChange}
onChange={e => {
setValue("name", e.target.value);
}}

View File

@@ -17,13 +17,13 @@ const useTableConfig = (tablePath: string) => {
const setTable = (table: string) => {
documentDispatch({ path: `${table}/_FIRETABLE_`, columns: [], doc: null });
};
const add = (name: string, type: FieldType) => {
const add = (name: string, type: FieldType, data?: any) => {
//TODO: validation
const { columns } = tableConfigState;
const key = _camelCase(name);
documentDispatch({
action: DocActions.update,
data: { columns: [...columns, { name, key, type }] },
data: { columns: [...columns, { name, key, type, ...data }] },
});
};
const resize = (index: number, width: number) => {