Create edit relationship modal (#9400)
* Flip from to fields the correct way * Do not allow through table foreign keys to match
This commit is contained in:
parent
738db2cc6a
commit
1382227c30
|
@ -30,8 +30,8 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
let originalFromColumnName = fromRelationship.name,
|
let originalFromColumnName = toRelationship.name,
|
||||||
originalToColumnName = toRelationship.name
|
originalToColumnName = fromRelationship.name
|
||||||
let originalFromTable = plusTables.find(
|
let originalFromTable = plusTables.find(
|
||||||
table => table._id === toRelationship?.tableId
|
table => table._id === toRelationship?.tableId
|
||||||
)
|
)
|
||||||
|
@ -170,10 +170,10 @@
|
||||||
errObj.throughTable = tableError
|
errObj.throughTable = tableError
|
||||||
}
|
}
|
||||||
const colError = "Column name cannot be an existing column"
|
const colError = "Column name cannot be an existing column"
|
||||||
if (isColumnNameBeingUsed(fromTable, fromColumn, originalFromColumnName)) {
|
if (isColumnNameBeingUsed(toTable, fromColumn, originalFromColumnName)) {
|
||||||
errObj.fromColumn = colError
|
errObj.fromColumn = colError
|
||||||
}
|
}
|
||||||
if (isColumnNameBeingUsed(toTable, toColumn, originalToColumnName)) {
|
if (isColumnNameBeingUsed(fromTable, toColumn, originalToColumnName)) {
|
||||||
errObj.toColumn = colError
|
errObj.toColumn = colError
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,12 +274,12 @@
|
||||||
function removeExistingRelationship() {
|
function removeExistingRelationship() {
|
||||||
if (originalFromTable && originalFromColumnName) {
|
if (originalFromTable && originalFromColumnName) {
|
||||||
delete datasource.entities[originalFromTable.name].schema[
|
delete datasource.entities[originalFromTable.name].schema[
|
||||||
originalFromColumnName
|
originalToColumnName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
if (originalToTable && originalToColumnName) {
|
if (originalToTable && originalToColumnName) {
|
||||||
delete datasource.entities[originalToTable.name].schema[
|
delete datasource.entities[originalToTable.name].schema[
|
||||||
originalToColumnName
|
originalFromColumnName
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -369,14 +369,24 @@
|
||||||
options={Object.keys(throughTable?.schema)}
|
options={Object.keys(throughTable?.schema)}
|
||||||
bind:value={throughToKey}
|
bind:value={throughToKey}
|
||||||
bind:error={errors.throughToKey}
|
bind:error={errors.throughToKey}
|
||||||
on:change={() => (errors.throughToKey = null)}
|
on:change={e => {
|
||||||
|
if (throughFromKey === e.detail) {
|
||||||
|
throughFromKey = null
|
||||||
|
}
|
||||||
|
errors.throughToKey = null
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<Select
|
<Select
|
||||||
label={`Foreign Key (${toTable?.name})`}
|
label={`Foreign Key (${toTable?.name})`}
|
||||||
options={Object.keys(throughTable?.schema)}
|
options={Object.keys(throughTable?.schema)}
|
||||||
bind:value={throughFromKey}
|
bind:value={throughFromKey}
|
||||||
bind:error={errors.throughFromKey}
|
bind:error={errors.throughFromKey}
|
||||||
on:change={() => (errors.throughFromKey = null)}
|
on:change={e => {
|
||||||
|
if (throughToKey === e.detail) {
|
||||||
|
throughToKey = null
|
||||||
|
}
|
||||||
|
errors.throughFromKey = null
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if isManyToOne && toTable}
|
{:else if isManyToOne && toTable}
|
||||||
|
|
Loading…
Reference in New Issue