Small refactoring

This commit is contained in:
barsdeveloper
2021-12-11 23:58:40 +01:00
parent 6b02ab7e08
commit a5c4f04f2b
11 changed files with 235 additions and 150 deletions

View File

@@ -3,6 +3,7 @@ import ObjectEntity from "../entity/ObjectEntity"
import SelectableDraggable from "./SelectableDraggable"
import SerializerFactory from "../serialization/SerializerFactory"
import DragLink from "../input/DragLink"
import PinEntity from "../entity/PinEntity"
export default class GraphNode extends SelectableDraggable {
@@ -24,6 +25,14 @@ export default class GraphNode extends SelectableDraggable {
return new GraphNode(entity)
}
/**
*
* @returns {PinEntity[]}
*/
getPinEntities() {
return this.entity.CustomProperties.filter(v => v instanceof PinEntity)
}
connectedCallback() {
const type = this.getAttribute("type")?.trim()
super.connectedCallback()
@@ -40,8 +49,9 @@ export default class GraphNode extends SelectableDraggable {
}
setLocation(value = [0, 0]) {
this.entity.NodePosX = value[0]
this.entity.NodePosY = value[1]
let nodeType = this.entity.NodePosX.constructor
this.entity.NodePosX = new nodeType(value[0])
this.entity.NodePosY = new nodeType(value[1])
super.setLocation(value)
}
}

View File

@@ -3,13 +3,43 @@ import PinTemplate from "../template/PinTemplate"
export default class GraphPin extends GraphElement {
constructor() {
super({}, new PinTemplate())
constructor(entity) {
super(entity, new PinTemplate())
/** @type {import("../entity/PinEntity").default} */
this.entity
}
/*connectedCallback() {
connectedCallback() {
super.connectedCallback()
}*/
}
/**
*
* @returns {String}
*/
getPinDisplayName() {
return this.entity.PinName
}
getAttributes() {
return PinEntity.attributes
}
isInput() {
return this.entity.isInput()
}
isOutput() {
return this.entity.isOutput()
}
isConnected() {
return this.entity.isConnected()
}
getType() {
return this.entity.getType()
}
}
customElements.define("u-pin", GraphPin)