adds oneToMany property to save table method

This commit is contained in:
Keviin Åberg Kultalahti 2021-02-09 13:10:01 +01:00
parent 9dda10d0a3
commit 7dffc1881d
2 changed files with 9 additions and 2 deletions

View File

@ -232,8 +232,9 @@ export const getBackendUiStore = () => {
return state
})
},
saveField: ({ originalName, field, primaryDisplay = false }) => {
saveField: ({ originalName, field, primaryDisplay = false, oneToMany = false }) => {
store.update(state => {
console.log(state)
// delete the original if renaming
// need to handle if the column had no name, empty string
if (originalName || originalName === "") {
@ -248,6 +249,10 @@ export const getBackendUiStore = () => {
if (primaryDisplay) {
state.draftTable.primaryDisplay = field.name
}
// Set one-to-many
if (oneToMany) {
state.draftTable.oneToMany = field.name
}
state.draftTable.schema[field.name] = cloneDeep(field)
store.actions.tables.save(state.draftTable)

View File

@ -24,6 +24,7 @@
let primaryDisplay =
$backendUiStore.selectedTable.primaryDisplay == null ||
$backendUiStore.selectedTable.primaryDisplay === field.name
let oneToMany = false;
let confirmDeleteDialog
let deletion
@ -41,6 +42,7 @@
originalName,
field,
primaryDisplay,
oneToMany,
})
return state
})
@ -150,7 +152,7 @@
bind:value={field.constraints.numericality.lessThanOrEqualTo} />
{:else if field.type === 'link'}
<Toggle
bind:checked={field.constraints.oneToMany}
bind:checked={field.oneToMany}
thin
text="One to many?" />
<Select label="Table" thin secondary bind:value={field.tableId}>