import PinEntity from "../entity/PinEntity" import Template from "./Template" /** * @typedef {import("../entity/ObjectEntity").default} ObjectEntity */ export default class NodeTemplate extends Template { /** * Computes the html content of the target element. * @param {ObjectEntity} entity Entity representing the element * @returns The computed html */ header(entity) { return `
${entity.getNodeDisplayName()}
` } /** * Computes the html content of the target element. * @param {ObjectEntity} entity Entity representing the element * @returns The computed html */ body(entity) { /** @type {PinEntity[]} */ let inputs = entity.CustomProperties.filter(v => v instanceof PinEntity) let outputs = inputs.filter(v => v.isOutput()) inputs = inputs.filter(v => !v.isOutput()) return `
${inputs.map((input, index) => `
${input.getPinDisplayName()}
`).join("") ?? ""}
${outputs.map((output, index) => `
${output.getPinDisplayName()}
`).join('') ?? ''}
` } /** * Computes the html content of the target element. * @param {ObjectEntity} entity Entity representing the element * @returns The computed html */ render(entity) { return `
${this.header(entity)} ${this.body(entity)}
` } }