hpcc-systems / Visualization

HPCC JavaScript Framework
https://hpcc-systems.github.io/Visualization/
Other
93 stars 62 forks source link

Table logic should be abstracted from PropertyEditor #3025

Closed jbrundage closed 5 years ago

jbrundage commented 5 years ago

@GordonSmith Here's what I'm thinking... Replace these lines: https://github.com/hpcc-systems/Visualization/blob/candidate-2.x.x/packages/other/src/PropertyEditor.ts#L94-L137

...with something like this:

const containerMode = "table";
const divs = element.selectAll(`div.property-div.div-${this.depth()}`).data(rootWidgets, function (d) {
    return typeof d.id !== "function" ? `meta-${d.id}` : d.id();
});
divs.enter().append("div")
    .attr("class", `property-div div-${this.depth()}`)
    .each(function (d) {
        if (!d._propertyContainer) {
            if (containerMode === "table") {
                d._propertyContainer = new PropertyTable();
            }
        }
        d._propertyContainer
            .target(this)
            .dataEnter()
            .render();
    })
    .merge(divs)
    .each(function (tableData) {
        tableData._propertyContainer.dataUpdate();
    });
divs.exit()
    .each(function (d) {
        d._propertyContainer.dataExit();
    })
    .remove();

Where PropertyTable is a new widget responsible for handling the html and events related to the inputs being used. I'm thinking you'll probably prefer not to bind instances of new PropertyTable() to each data row, but what would be an alternate implementation? Could we just cache the instances in an array at the PropertyEditor level?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.