Refactoring, various fixes

This commit is contained in:
barsdeveloper
2022-03-24 22:54:41 +01:00
parent 4dd2929a9f
commit 8a4e60c9ae
43 changed files with 937 additions and 589 deletions

View File

@@ -9,19 +9,27 @@ export default class IElement extends HTMLElement {
static tagName = ""
/** @type {Blueprint} */
blueprint
/** @type {IEntity} */
entity
/** @type {ITemplate} */
template
/** @type {IContext[]} */
inputObjects = []
/**
* @param {IEntity} entity The entity containing blueprint related data for this graph element
* @param {ITemplate} template The template to render this node
*/
constructor(entity, template) {
super()
/** @type {Blueprint} */
this.blueprint = null
/** @type {IEntity} */
this.entity = entity
/** @type {ITemplate} */
this.template = template
/** @type {IContext[]} */
this.inputObjects = []
}
@@ -39,14 +47,22 @@ export default class IElement extends HTMLElement {
this.inputObjects.forEach(v => v.unlistenDOMElement())
}
createInputObjects() {
return []
}
/**
* @param {IElement} element
*/
/** @param {IElement} element */
isSameGraph(element) {
return this.blueprint && this.blueprint == element?.blueprint
}
/**
* @template {} T
* @param {new () => T} type
* @returns {T}
*/
getInputObject(type) {
return this.inputObjects.find(object => object.constructor == type)
}
// Subclasses will want to override
createInputObjects() {
return []
}
}