sparnatural
Version:
Visual client-side SPARQL query builder and knowledge graph exploration tool
45 lines • 2.1 kB
JavaScript
import { HTMLComponent } from "../HtmlComponent";
import GroupWrapper from "./groupwrapper/GroupWrapper";
/*
Componentslist does correspond to the <ul class="componentsListe"> OR <ul class="childsList">
Depending on the ParentComponent. If BGWrapper is parent, then it is the root Componentslist
Componentslist holds a list of GroupWrapper siblings added with 'addAndComponent'.
*/
class ComponentsList extends HTMLComponent {
constructor(ParentComponent, specProvider) {
super("componentsListe", ParentComponent, null);
this.specProvider = specProvider;
}
render() {
super.render();
this.initFirstGroupWrapper();
return this;
}
initFirstGroupWrapper() {
this.rootGroupWrapper = new GroupWrapper(null, this, this.specProvider,
// depth = 0
0,
// order = 0, it is the first sibling
0, undefined,
// render eye button on the root StartClassGroup
true).render();
// The first criteriaGrp always has the "eye" icon to select it as a variable in the result set
this.rootGroupWrapper.criteriaGroup.startClassGroup.inputSelector.selectViewVariableBtn.render();
}
/**
* Called when the first GroupWrapper is deleted and there is a sibling AND : the sibling becomes the root
* @param grpWrapper the sibling GroupWrapper that becomes the new root
*/
attachNewRoot(grpWrapper) {
this.rootGroupWrapper = grpWrapper;
// this should already be the case, but we are just making sure it is
this.rootGroupWrapper.parentComponent = this;
// display its eye and selects it
// TODO : this should be done only if previous StartClassGroup was itself selected
this.rootGroupWrapper.criteriaGroup.startClassGroup.renderEyeBtn = true;
this.rootGroupWrapper.criteriaGroup.startClassGroup.autoSelectEyeBtn();
this.rootGroupWrapper.criteriaGroup.startClassGroup.inputSelector.html[0].classList.add("Highlited");
}
}
export default ComponentsList;
//# sourceMappingURL=ComponentsList.js.map