definitions and tidy up
This commit is contained in:
parent
5cc3f6fbfb
commit
e183a9e607
|
@ -2,19 +2,14 @@
|
||||||
import { RelationshipTypes } from "constants/backend"
|
import { RelationshipTypes } from "constants/backend"
|
||||||
import { Menu, MenuItem, MenuSection, Button, Input, Icon, ModalContent, RadioGroup, Heading } from "@budibase/bbui"
|
import { Menu, MenuItem, MenuSection, Button, Input, Icon, ModalContent, RadioGroup, Heading } from "@budibase/bbui"
|
||||||
|
|
||||||
// "tasks_something": {
|
|
||||||
// "name": "tasks_something",
|
|
||||||
// "type": "link",
|
|
||||||
// "tableId": "whatever/othertable",
|
|
||||||
// "relationshipType": "one-to-many",
|
|
||||||
// },
|
|
||||||
|
|
||||||
export let save
|
export let save
|
||||||
export let datasource
|
export let datasource
|
||||||
export let from
|
export let from
|
||||||
export let tables
|
export let tables
|
||||||
export let relationship = {}
|
export let relationship = {}
|
||||||
|
|
||||||
|
let originalName = relationship.name
|
||||||
|
|
||||||
$: console.log(relationship)
|
$: console.log(relationship)
|
||||||
$: valid = relationship.name && relationship.tableId && relationship.relationshipType
|
$: valid = relationship.name && relationship.tableId && relationship.relationshipType
|
||||||
$: from = tables.find(table => table._id === relationship.source)
|
$: from = tables.find(table => table._id === relationship.source)
|
||||||
|
@ -43,24 +38,15 @@
|
||||||
|
|
||||||
// save the relationship on to the datasource
|
// save the relationship on to the datasource
|
||||||
function saveRelationship() {
|
function saveRelationship() {
|
||||||
let key
|
datasource.entities[from.name].schema[relationship.name] = {
|
||||||
|
|
||||||
// find the entity on the datasource
|
|
||||||
|
|
||||||
for (let entity in datasource.entities) {
|
|
||||||
// TODO: update with _id instead of name
|
|
||||||
if (relationship.from.name === entity) {
|
|
||||||
key = entity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
datasource.entities[key].schema[relationship.name] = {
|
|
||||||
name: relationship.name,
|
|
||||||
type: "link",
|
type: "link",
|
||||||
relationshipType: relationship.relationshipType,
|
...relationship
|
||||||
tableId: relationship.to._id,
|
|
||||||
through: relationship.through
|
|
||||||
}
|
}
|
||||||
|
if (originalName) {
|
||||||
|
// TODO: possible bug if you change name
|
||||||
|
delete datasource.entities[from.name][originalName]
|
||||||
|
}
|
||||||
|
|
||||||
save()
|
save()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -26,3 +26,17 @@ export interface Table {
|
||||||
primaryDisplay?: string
|
primaryDisplay?: string
|
||||||
sourceId?: string
|
sourceId?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BudibaseAppMetadata {
|
||||||
|
_id: string
|
||||||
|
_rev?: string
|
||||||
|
appId: string
|
||||||
|
type: string
|
||||||
|
version: string
|
||||||
|
componentlibraries: string[]
|
||||||
|
name: string
|
||||||
|
url: string
|
||||||
|
instance: { _id: string }
|
||||||
|
updatedAt: Date,
|
||||||
|
createdAt: Date
|
||||||
|
}
|
Loading…
Reference in New Issue