Linting.
This commit is contained in:
parent
a8ff2cc7bd
commit
9aa672101e
|
@ -11,16 +11,25 @@
|
||||||
export let toRelationship = {}
|
export let toRelationship = {}
|
||||||
export let close
|
export let close
|
||||||
|
|
||||||
let originalFromName = fromRelationship.name, originalToName = toRelationship.name
|
let originalFromName = fromRelationship.name,
|
||||||
|
originalToName = toRelationship.name
|
||||||
|
|
||||||
function isValid(relationship) {
|
function isValid(relationship) {
|
||||||
if (relationship.relationshipType === RelationshipTypes.MANY_TO_MANY && !relationship.through) {
|
if (
|
||||||
|
relationship.relationshipType === RelationshipTypes.MANY_TO_MANY &&
|
||||||
|
!relationship.through
|
||||||
|
) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return relationship.name && relationship.tableId && relationship.relationshipType
|
return (
|
||||||
|
relationship.name && relationship.tableId && relationship.relationshipType
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
$: tableOptions = plusTables.map(table => ({ label: table.name, value: table._id }))
|
$: tableOptions = plusTables.map(table => ({
|
||||||
|
label: table.name,
|
||||||
|
value: table._id,
|
||||||
|
}))
|
||||||
$: fromTable = plusTables.find(table => table._id === toRelationship?.tableId)
|
$: fromTable = plusTables.find(table => table._id === toRelationship?.tableId)
|
||||||
$: toTable = plusTables.find(table => table._id === fromRelationship?.tableId)
|
$: toTable = plusTables.find(table => table._id === fromRelationship?.tableId)
|
||||||
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
$: through = plusTables.find(table => table._id === fromRelationship?.through)
|
||||||
|
@ -34,7 +43,7 @@
|
||||||
{
|
{
|
||||||
label: "One",
|
label: "One",
|
||||||
value: RelationshipTypes.MANY_TO_ONE,
|
value: RelationshipTypes.MANY_TO_ONE,
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
$: updateRelationshipType(fromRelationship?.relationshipType)
|
$: updateRelationshipType(fromRelationship?.relationshipType)
|
||||||
|
|
||||||
|
@ -48,7 +57,8 @@
|
||||||
|
|
||||||
function buildRelationships() {
|
function buildRelationships() {
|
||||||
// if any to many only need to check from
|
// if any to many only need to check from
|
||||||
const manyToMany = fromRelationship.relationshipType === RelationshipTypes.MANY_TO_MANY
|
const manyToMany =
|
||||||
|
fromRelationship.relationshipType === RelationshipTypes.MANY_TO_MANY
|
||||||
// main is simply used to know this is the side the user configured it from
|
// main is simply used to know this is the side the user configured it from
|
||||||
const id = uuid()
|
const id = uuid()
|
||||||
let relateFrom = {
|
let relateFrom = {
|
||||||
|
@ -97,9 +107,11 @@
|
||||||
async function saveRelationship() {
|
async function saveRelationship() {
|
||||||
buildRelationships()
|
buildRelationships()
|
||||||
// source of relationship
|
// source of relationship
|
||||||
datasource.entities[fromTable.name].schema[fromRelationship.name] = fromRelationship
|
datasource.entities[fromTable.name].schema[fromRelationship.name] =
|
||||||
|
fromRelationship
|
||||||
// save other side of relationship in the other schema
|
// save other side of relationship in the other schema
|
||||||
datasource.entities[toTable.name].schema[toRelationship.name] = toRelationship
|
datasource.entities[toTable.name].schema[toRelationship.name] =
|
||||||
|
toRelationship
|
||||||
|
|
||||||
// If relationship has been renamed
|
// If relationship has been renamed
|
||||||
if (originalFromName !== fromRelationship.name) {
|
if (originalFromName !== fromRelationship.name) {
|
||||||
|
|
|
@ -19,15 +19,20 @@
|
||||||
if (!table || !table.schema) {
|
if (!table || !table.schema) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return Object.entries(table.schema).filter(field => field[1].type !== "link").map(([fieldName]) => fieldName)
|
return Object.entries(table.schema)
|
||||||
|
.filter(field => field[1].type !== "link")
|
||||||
|
.map(([fieldName]) => fieldName)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Edit display columns"
|
title="Edit display columns"
|
||||||
confirmText="Save"
|
confirmText="Save"
|
||||||
onConfirm={saveDisplayColumns}
|
onConfirm={saveDisplayColumns}
|
||||||
>
|
>
|
||||||
<Body>Select the columns that will be shown when displaying relationships.</Body>
|
<Body
|
||||||
|
>Select the columns that will be shown when displaying relationships.</Body
|
||||||
|
>
|
||||||
{#each plusTables as table}
|
{#each plusTables as table}
|
||||||
<Select
|
<Select
|
||||||
label={table.name}
|
label={table.name}
|
||||||
|
|
Loading…
Reference in New Issue