extract logic from component and disable one to one
This commit is contained in:
parent
18fd154ab5
commit
7d4613c3f6
|
@ -73,6 +73,8 @@
|
||||||
// Initial value for column name in other table for linked records
|
// Initial value for column name in other table for linked records
|
||||||
fieldName: $tables.selected.name,
|
fieldName: $tables.selected.name,
|
||||||
}
|
}
|
||||||
|
let relationshipOpts1 = Object.values(PrettyRelationshipDefinitions)
|
||||||
|
let relationshipOpts2 = Object.values(PrettyRelationshipDefinitions)
|
||||||
|
|
||||||
$: if (primaryDisplay) {
|
$: if (primaryDisplay) {
|
||||||
editableColumn.constraints.presence = { allowEmpty: false }
|
editableColumn.constraints.presence = { allowEmpty: false }
|
||||||
|
@ -95,6 +97,21 @@
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (editableColumn.type === LINK_TYPE) {
|
if (editableColumn.type === LINK_TYPE) {
|
||||||
|
if (relationshipPart1 === PrettyRelationshipDefinitions.ONE) {
|
||||||
|
relationshipOpts2 = relationshipOpts2.filter(
|
||||||
|
opt => opt !== PrettyRelationshipDefinitions.ONE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
relationshipOpts2 = Object.values(PrettyRelationshipDefinitions)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (relationshipPart2 === PrettyRelationshipDefinitions.ONE) {
|
||||||
|
relationshipOpts1 = relationshipOpts1.filter(
|
||||||
|
opt => opt !== PrettyRelationshipDefinitions.ONE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
relationshipOpts1 = Object.values(PrettyRelationshipDefinitions)
|
||||||
|
}
|
||||||
// Determine the relationship type based on the selected values of both parts
|
// Determine the relationship type based on the selected values of both parts
|
||||||
editableColumn.relationshipType = Object.entries(relationshipMap).find(
|
editableColumn.relationshipType = Object.entries(relationshipMap).find(
|
||||||
([_, parts]) =>
|
([_, parts]) =>
|
||||||
|
@ -104,7 +121,6 @@
|
||||||
editableColumn.tableId = relationshipTableIdSecondary
|
editableColumn.tableId = relationshipTableIdSecondary
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialiseField = (field, savingColumn) => {
|
const initialiseField = (field, savingColumn) => {
|
||||||
isCreating = !field
|
isCreating = !field
|
||||||
if (field && !savingColumn) {
|
if (field && !savingColumn) {
|
||||||
|
@ -564,6 +580,8 @@
|
||||||
bind:relationshipTableIdPrimary={table.name}
|
bind:relationshipTableIdPrimary={table.name}
|
||||||
bind:relationshipTableIdSecondary
|
bind:relationshipTableIdSecondary
|
||||||
bind:editableColumn
|
bind:editableColumn
|
||||||
|
{relationshipOpts1}
|
||||||
|
{relationshipOpts2}
|
||||||
{linkEditDisabled}
|
{linkEditDisabled}
|
||||||
{tableOptions}
|
{tableOptions}
|
||||||
{errors}
|
{errors}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
export let linkEditDisabled
|
export let linkEditDisabled
|
||||||
export let tableOptions
|
export let tableOptions
|
||||||
export let errors
|
export let errors
|
||||||
|
export let relationshipOpts1
|
||||||
|
export let relationshipOpts2
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="relationship-container">
|
<div class="relationship-container">
|
||||||
|
@ -17,7 +19,7 @@
|
||||||
<Select
|
<Select
|
||||||
disabled={linkEditDisabled}
|
disabled={linkEditDisabled}
|
||||||
bind:value={relationshipPart1}
|
bind:value={relationshipPart1}
|
||||||
options={Object.values(PrettyRelationshipDefinitions)}
|
options={relationshipOpts1}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="relationship-label">in</div>
|
<div class="relationship-label">in</div>
|
||||||
|
@ -34,7 +36,7 @@
|
||||||
<Select
|
<Select
|
||||||
disabled={linkEditDisabled}
|
disabled={linkEditDisabled}
|
||||||
bind:value={relationshipPart2}
|
bind:value={relationshipPart2}
|
||||||
options={Object.values(PrettyRelationshipDefinitions)}
|
options={relationshipOpts2}
|
||||||
getOptionLabel={option => "To " + option.toLowerCase()}
|
getOptionLabel={option => "To " + option.toLowerCase()}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue