adds oneToMany property to save table method
This commit is contained in:
parent
6d751ce588
commit
a2610097c8
|
@ -232,8 +232,9 @@ export const getBackendUiStore = () => {
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
saveField: ({ originalName, field, primaryDisplay = false }) => {
|
saveField: ({ originalName, field, primaryDisplay = false, oneToMany = false }) => {
|
||||||
store.update(state => {
|
store.update(state => {
|
||||||
|
console.log(state)
|
||||||
// delete the original if renaming
|
// delete the original if renaming
|
||||||
// need to handle if the column had no name, empty string
|
// need to handle if the column had no name, empty string
|
||||||
if (originalName || originalName === "") {
|
if (originalName || originalName === "") {
|
||||||
|
@ -248,6 +249,10 @@ export const getBackendUiStore = () => {
|
||||||
if (primaryDisplay) {
|
if (primaryDisplay) {
|
||||||
state.draftTable.primaryDisplay = field.name
|
state.draftTable.primaryDisplay = field.name
|
||||||
}
|
}
|
||||||
|
// Set one-to-many
|
||||||
|
if (oneToMany) {
|
||||||
|
state.draftTable.oneToMany = field.name
|
||||||
|
}
|
||||||
|
|
||||||
state.draftTable.schema[field.name] = cloneDeep(field)
|
state.draftTable.schema[field.name] = cloneDeep(field)
|
||||||
store.actions.tables.save(state.draftTable)
|
store.actions.tables.save(state.draftTable)
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
let primaryDisplay =
|
let primaryDisplay =
|
||||||
$backendUiStore.selectedTable.primaryDisplay == null ||
|
$backendUiStore.selectedTable.primaryDisplay == null ||
|
||||||
$backendUiStore.selectedTable.primaryDisplay === field.name
|
$backendUiStore.selectedTable.primaryDisplay === field.name
|
||||||
|
let oneToMany = false;
|
||||||
let confirmDeleteDialog
|
let confirmDeleteDialog
|
||||||
let deletion
|
let deletion
|
||||||
|
|
||||||
|
@ -41,6 +42,7 @@
|
||||||
originalName,
|
originalName,
|
||||||
field,
|
field,
|
||||||
primaryDisplay,
|
primaryDisplay,
|
||||||
|
oneToMany,
|
||||||
})
|
})
|
||||||
return state
|
return state
|
||||||
})
|
})
|
||||||
|
@ -150,7 +152,7 @@
|
||||||
bind:value={field.constraints.numericality.lessThanOrEqualTo} />
|
bind:value={field.constraints.numericality.lessThanOrEqualTo} />
|
||||||
{:else if field.type === 'link'}
|
{:else if field.type === 'link'}
|
||||||
<Toggle
|
<Toggle
|
||||||
bind:checked={field.constraints.oneToMany}
|
bind:checked={field.oneToMany}
|
||||||
thin
|
thin
|
||||||
text="One to many?" />
|
text="One to many?" />
|
||||||
<Select label="Table" thin secondary bind:value={field.tableId}>
|
<Select label="Table" thin secondary bind:value={field.tableId}>
|
||||||
|
|
Loading…
Reference in New Issue