Classes naming refactoring

This commit is contained in:
barsdeveloper
2022-02-27 12:44:48 +01:00
parent 96f0d593e7
commit e8946745d6
35 changed files with 790 additions and 786 deletions

View File

@@ -1,7 +1,7 @@
import Configuration from "../Configuration"
import GraphSelector from "../graph/GraphSelector"
import html from "./html"
import sanitizeText from "./sanitizeText"
import SelectorElement from "../element/SelectorElement"
import Template from "./Template"
/** @typedef {import("../Blueprint").default} Blueprint */
@@ -77,7 +77,7 @@ export default class BlueprintTemplate extends Template {
blueprint.viewportElement = blueprint.querySelector('.ueb-viewport-body')
blueprint.gridElement = blueprint.viewportElement.querySelector(".ueb-grid")
blueprint.nodesContainerElement = blueprint.querySelector("[data-nodes]")
blueprint.selectorElement = new GraphSelector()
blueprint.selectorElement = new SelectorElement()
blueprint.nodesContainerElement.append(blueprint.selectorElement, ...blueprint.getNodes())
this.applyEndDragScrolling(blueprint)
}

View File

@@ -1,15 +1,15 @@
import GraphLink from "../graph/GraphLink"
import LinkElement from "../element/LinkElement"
import html from "./html"
import Template from "./Template"
/**
* @typedef {import("../graph/GraphLinkMessage").default} GraphLinkMessage
* @typedef {import("../element/LinkMessageElement").default} LinkMessageElement
*/
export default class LinkMessageTemplate extends Template {
/**
* Computes the html content of the target element.
* @param {GraphLinkMessage} linkMessage attached to link destination
* @param {LinkMessageElement} linkMessage attached to link destination
* @returns The result html
*/
render(linkMessage) {
@@ -21,11 +21,11 @@ export default class LinkMessageTemplate extends Template {
/**
* Applies the style to the element.
* @param {GraphLinkMessage} linkMessage element
* @param {LinkMessageElement} linkMessage element
*/
apply(linkMessage) {
super.apply(linkMessage)
linkMessage.linkElement = linkMessage.closest(GraphLink.tagName)
linkMessage.linkElement = linkMessage.closest(LinkElement.tagName)
linkMessage.querySelector(".ueb-link-message").innerText = linkMessage.message(
linkMessage.linkElement.getSourcePin(),
linkMessage.linkElement.getDestinationPin()

View File

@@ -4,8 +4,8 @@ import Template from "./Template"
import Configuration from "../Configuration"
/**
* @typedef {import("../graph/GraphLink").default} GraphLink
* @typedef {import("../graph/GraphLinkMessage").default} GraphLinkMessage
* @typedef {import("../element/LinkElement").default} LinkElement
* @typedef {import("../element/LinkMessageElement").default} LinkMessageElement
*/
export default class LinkTemplate extends Template {
@@ -19,7 +19,7 @@ export default class LinkTemplate extends Template {
/**
* Computes the html content of the target element.
* @param {GraphLink} link connecting two graph nodes
* @param {LinkElement} link connecting two graph nodes
* @returns The result html
*/
render(link) {
@@ -32,7 +32,7 @@ export default class LinkTemplate extends Template {
/**
* Applies the style to the element.
* @param {GraphLink} link Element of the graph
* @param {LinkElement} link Element of the graph
*/
apply(link) {
super.apply(link)
@@ -45,7 +45,7 @@ export default class LinkTemplate extends Template {
/**
* Applies the style relative to the source pin location.
* @param {GraphLink} link Link element
* @param {LinkElement} link Link element
*/
applySourceLocation(link) {
link.style.setProperty("--ueb-from-input", link.originatesFromInput ? "0" : "1")
@@ -55,7 +55,7 @@ export default class LinkTemplate extends Template {
/**
* Applies the style relative to the destination pin location.
* @param {GraphLink} link Link element
* @param {LinkElement} link Link element
*/
applyFullLocation(link) {
const dx = Math.max(Math.abs(link.sourceLocation[0] - link.destinationLocation[0]), 1)
@@ -97,8 +97,8 @@ export default class LinkTemplate extends Template {
/**
*
* @param {GraphLink} link element
* @param {GraphLinkMessage} linkMessage
* @param {LinkElement} link element
* @param {LinkMessageElement} linkMessage
*/
applyLinkMessage(link, linkMessage) {
link.querySelectorAll(linkMessage.constructor.tagName).forEach(element => element.remove())

View File

@@ -1,17 +1,17 @@
import GraphPin from "../graph/GraphPin"
import PinElement from "../element/PinElement"
import html from "./html"
import PinEntity from "../entity/PinEntity"
import sanitizeText from "./sanitizeText"
import SelectableDraggableTemplate from "./SelectableDraggableTemplate"
/**
* @typedef {import("../graph/GraphNode").default} GraphNode
* @typedef {import("../element/NodeElement").default} NodeElement
*/
export default class NodeTemplate extends SelectableDraggableTemplate {
/**
* Computes the html content of the target element.
* @param {GraphNode} node Graph node element
* @param {NodeElement} node Graph node element
* @returns The result html
*/
render(node) {
@@ -35,7 +35,7 @@ export default class NodeTemplate extends SelectableDraggableTemplate {
/**
* Applies the style to the element.
* @param {GraphNode} node Element of the graph
* @param {NodeElement} node Element of the graph
*/
apply(node) {
super.apply(node)
@@ -49,7 +49,7 @@ export default class NodeTemplate extends SelectableDraggableTemplate {
/** @type {HTMLElement} */
let outputContainer = node.querySelector(".ueb-node-outputs")
let pins = node.getPinEntities()
pins.filter(v => v.isInput()).forEach(v => inputContainer.appendChild(new GraphPin(v)))
pins.filter(v => v.isOutput()).forEach(v => outputContainer.appendChild(new GraphPin(v)))
pins.filter(v => v.isInput()).forEach(v => inputContainer.appendChild(new PinElement(v)))
pins.filter(v => v.isOutput()).forEach(v => outputContainer.appendChild(new PinElement(v)))
}
}

View File

@@ -4,13 +4,13 @@ import sanitizeText from "./sanitizeText"
import Template from "./Template"
/**
* @typedef {import("../graph/GraphPin").default} GraphPin
* @typedef {import("../element/PinElement").default} PinElement
*/
export default class PinTemplate extends Template {
/**
* Computes the html content of the pin.
* @param {GraphPin} pin Pin entity
* @param {PinElement} pin html element
* @returns The result html
*/
render(pin) {
@@ -29,7 +29,7 @@ export default class PinTemplate extends Template {
/**
* Applies the style to the element.
* @param {GraphPin} pin Element of the graph
* @param {PinElement} pin element of the graph
*/
apply(pin) {
super.apply(pin)
@@ -40,7 +40,7 @@ export default class PinTemplate extends Template {
/**
*
* @param {GraphPin} pin
* @param {PinElement} pin
* @returns
*/
getLinkLocation(pin) {

View File

@@ -2,13 +2,13 @@ import sanitizeText from "./sanitizeText"
import Template from "./Template"
/**
* @typedef {import("../graph/SelectableDraggable").default} SelectableDraggable
* @typedef {import("../element/ISelectableDraggableElement").default} ISelectableDraggableElement
*/
export default class SelectableDraggableTemplate extends Template {
/**
* Returns the html elements rendered from this template.
* @param {SelectableDraggable} element Element of the graph
* @param {ISelectableDraggableElement} element Element of the graph
*/
applyLocation(element) {
element.style.setProperty("--ueb-position-x", sanitizeText(element.location[0]))
@@ -17,7 +17,7 @@ export default class SelectableDraggableTemplate extends Template {
/**
* Returns the html elements rendered from this template.
* @param {SelectableDraggable} element Element of the graph
* @param {ISelectableDraggableElement} element Element of the graph
*/
applySelected(element) {
if (element.selected) {

View File

@@ -2,13 +2,13 @@ import sanitizeText from "./sanitizeText"
import Template from "./Template"
/**
* @typedef {import("../graph/GraphSelector").default} GraphSelector
* @typedef {import("../element/SelectorElement").default} SelectorElement
*/
export default class SelectorTemplate extends Template {
/**
* Applies the style to the element.
* @param {GraphSelector} selector Selector element
* @param {SelectorElement} selector Selector element
*/
apply(selector) {
super.apply(selector)
@@ -18,7 +18,7 @@ export default class SelectorTemplate extends Template {
/**
* Applies the style relative to selection beginning.
* @param {GraphSelector} selector Selector element
* @param {SelectorElement} selector Selector element
*/
applyStartSelecting(selector, initialPosition) {
// Set initial position
@@ -32,7 +32,7 @@ export default class SelectorTemplate extends Template {
/**
* Applies the style relative to selection.
* @param {GraphSelector} selector Selector element
* @param {SelectorElement} selector Selector element
*/
applyDoSelecting(selector, finalPosition) {
selector.style.setProperty("--ueb-to-x", sanitizeText(finalPosition[0]))
@@ -41,7 +41,7 @@ export default class SelectorTemplate extends Template {
/**
* Applies the style relative to selection finishing.
* @param {GraphSelector} selector Selector element
* @param {SelectorElement} selector Selector element
*/
applyFinishSelecting(selector) {
selector.blueprint.dataset.selecting = "false"

View File

@@ -1,11 +1,11 @@
/**
* @typedef {import("../graph/GraphElement").default} GraphElement
* @typedef {import("../element/IElement").default} IElement
*/
export default class Template {
/**
* Computes the html content of the target element.
* @param {GraphElement} entity Element of the graph
* @param {IElement} entity Element of the graph
* @returns The result html
*/
render(entity) {
@@ -14,7 +14,7 @@ export default class Template {
/**
* Applies the style to the element.
* @param {GraphElement} element Element of the graph
* @param {IElement} element Element of the graph
*/
apply(element) {
// TODO replace with the safer element.setHTML(...) when it will be available