Skip to content

Commit

Permalink
Merge pull request #690 from sparna-git/issue-687
Browse files Browse the repository at this point in the history
Fix #687
  • Loading branch information
tfrancart authored Dec 1, 2024
2 parents a76cb42 + 7d3c7ff commit d6f24bc
Show file tree
Hide file tree
Showing 36 changed files with 98 additions and 133 deletions.
8 changes: 0 additions & 8 deletions src/sparnatural-form/components/FormFieldGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,6 @@ class FormField {

const removeBtn = new UnselectBtn(widget, () => {
selectedValues.delete(val);
widget.onRemoveValue(
widget
.getWidgetValues()
.find(
(w: { value: { label: string } }) => w.value.label === val.label
)
);
console.log("widget.getWidgetValues()", widget.getWidgetValues());
console.log(selectedValues);
updateValueDisplay();
queryLine.values = Array.from(selectedValues);
Expand Down
10 changes: 5 additions & 5 deletions src/sparnatural/components/HtmlComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class HTMLComponent implements IRenderable {
baseCssClass: string;
static BaseClassFactory = new BaseClassFactory();

ParentComponent: HTMLComponent;
parentComponent: HTMLComponent;
widgetHtml: JQuery<HTMLElement>;
html: JQuery<HTMLElement>;
// TODO this is only temporarly. Some components (ActionWhere) don't need to be attached on there parentcomponent but somewhere else
Expand All @@ -19,7 +19,7 @@ class HTMLComponent implements IRenderable {
widgetHtml: JQuery<HTMLElement>
) {
this.baseCssClass = baseCssClass;
this.ParentComponent = ParentComponent;
this.parentComponent = ParentComponent;

// create the HTML element
this.html = HTMLComponent.BaseClassFactory.getBaseClass(this.baseCssClass);
Expand All @@ -32,7 +32,7 @@ class HTMLComponent implements IRenderable {
if (this.htmlParent) {
this.htmlParent.append(this.html);
} else {
$(this.html).appendTo(this.ParentComponent.html);
$(this.html).appendTo(this.parentComponent.html);
}
}

Expand Down Expand Up @@ -65,10 +65,10 @@ class HTMLComponent implements IRenderable {
* @returns moves up the component hierarchy and returns the one that does not have a parent component
*/
getRootComponent():HTMLComponent {
if(this.ParentComponent == null) {
if(this.parentComponent == null) {
return this;
} else {
return this.ParentComponent.getRootComponent();
return this.parentComponent.getRootComponent();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ComponentsList extends HTMLComponent {
attachNewRoot(grpWrapper: GroupWrapper) {
this.rootGroupWrapper = grpWrapper;
// this should already be the case, but we are just making sure it is
this.rootGroupWrapper.ParentComponent = this;
this.rootGroupWrapper.parentComponent = this;

// display its eye and selects it
// TODO : this should be done only if previous StartClassGroup was itself selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class GroupWrapper extends HTMLComponent {

isRootGrpWrapper(): boolean{
return (
(this.ParentComponent instanceof ComponentsList)
(this.parentComponent instanceof ComponentsList)
&&
((this.ParentComponent as ComponentsList).rootGroupWrapper == this)
((this.parentComponent as ComponentsList).rootGroupWrapper == this)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class CriteriaGroup extends HTMLComponent {
unselectBtn: UnselectBtn;

constructor(
ParentComponent: GroupWrapper,
parentComponent: GroupWrapper,
specProvider: any,
startClassVal?: SelectedVal,
startClassEyeBtn?: boolean
) {
super("CriteriaGroup", ParentComponent, null);
super("CriteriaGroup", parentComponent, null);
this.specProvider = specProvider;
this.ParentGroupWrapper = ParentComponent;
this.ParentGroupWrapper = parentComponent;
this.StartClassGroup = new StartClassGroup(
this,
this.specProvider,
Expand Down Expand Up @@ -168,10 +168,7 @@ class CriteriaGroup extends HTMLComponent {
"updateWidgetList expects an object of type EndClassWidgetValue"
);
e.stopImmediatePropagation();
let removed = e.detail.unselectedVal as EndClassWidgetValue;
this.EndClassGroup.editComponents.widgetWrapper.widgetComponent?.onRemoveValue(
removed.widgetVal
);

this.html[0].dispatchEvent(
new CustomEvent("generateQuery", { bubbles: true })
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class EditComponents extends HTMLComponent {
widgetWrapper: WidgetWrapper;
specProvider: ISparnaturalSpecification;
RENDER_WHERE = RENDER_WHERE_ENUM;

constructor(
parentComponent: EndClassGroup,
startCassVal: SelectedVal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import HTMLComponent from "../../../../HtmlComponent";
import { SelectedVal } from "../../../../SelectedVal";
import SparnaturalComponent from "../../../../SparnaturalComponent";
import { AbstractWidget } from "../../../../widgets/AbstractWidget";
import CriteriaGroup from "../CriteriaGroup";
import EditComponents from "./EditComponents";
import { WidgetFactory } from "./WidgetFactory";

Expand All @@ -25,13 +26,13 @@ class WidgetWrapper extends HTMLComponent {
add_or: boolean = true;

constructor(
ParentComponent: HTMLComponent,
parentComponent: HTMLComponent,
specProvider: ISparnaturalSpecification,
startClassVal: SelectedVal,
objectPropVal: SelectedVal,
endClassVal: SelectedVal
) {
super("WidgetWrapper", ParentComponent, null);
super("WidgetWrapper", parentComponent, null);
this.specProvider = specProvider;
this.startClassVal = startClassVal;
this.objectPropVal = objectPropVal;
Expand Down Expand Up @@ -121,8 +122,10 @@ class WidgetWrapper extends HTMLComponent {
let htmlString = '';
widgetType == Config.NON_SELECTABLE_PROPERTY
? (htmlString = lineSpan + selectAnySpan)

// if there is a value, do not propose the "Any" selection option
: (this.widgetComponent.getWidgetValues().length > 0)
// : (this.widgetComponent.getWidgetValues().length > 0)
: ((this.parentComponent.parentComponent.parentComponent as CriteriaGroup).endClassWidgetGroup.getWidgetValues().length > 0)
?(htmlString = lineSpan + endLabelSpan)
:(htmlString = lineSpan + selectAnySpan + orSpan + endLabelSpan);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ObjectPropertyTypeId extends HTMLComponent {
) {
super("ObjectPropertyTypeId", ParentComponent, null);
this.temporaryLabel = temporaryLabel;
this.GrandParent = ParentComponent.ParentComponent as CriteriaGroup;
this.GrandParent = ParentComponent.parentComponent as CriteriaGroup;
this.specProvider = specProvider;
this.startClassVal = startClassVal;
}
Expand Down Expand Up @@ -232,7 +232,7 @@ class PropertySelectBuilder extends HTMLComponent {

initDagWidget(items:DagIfc<ISpecificationProperty>, default_value: DagWidgetDefaultValue) {
let jsonDag = this.convertToJsonDag(items.roots) ;
this.selectWidget = new HierarchicalClassSelectBuilder(this.ParentComponent, this.specProvider, jsonDag, default_value );
this.selectWidget = new HierarchicalClassSelectBuilder(this.parentComponent, this.specProvider, jsonDag, default_value );
return this.selectWidget.buildClassSelectFromJson() ; ;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import ISpecificationEntry from "../../../../../spec-providers/ISpecificationEnt
* The DOMAIN selection happens only for the very first line/criteria.
**/
class ClassTypeId extends HTMLComponent {
ParentComponent: EndClassGroup | StartClassGroup;
parentComponent: EndClassGroup | StartClassGroup;
id: string;
frontArrow: ArrowComponent = new ArrowComponent(
this,
Expand Down Expand Up @@ -65,7 +65,7 @@ class ClassTypeId extends HTMLComponent {


// no back arrow on start class
if (!isStartClassGroup(this.ParentComponent)) {
if (!isStartClassGroup(this.parentComponent)) {
this.backArrow.render();
}

Expand All @@ -74,7 +74,7 @@ class ClassTypeId extends HTMLComponent {
currentWrapper.append(this.htmlCurentValue) ;
this.html.append(currentWrapper);

if (isStartClassGroup(this.ParentComponent)) {
if (isStartClassGroup(this.parentComponent)) {
if(!this.startClassVal?.type) {
// If this Component is a child of the StartClassGroup component in the first row with no value selected
this.widgetHtml = this.selectBuilder.buildSelect_FirstStartClassGroup();
Expand Down Expand Up @@ -171,12 +171,12 @@ class ClassTypeId extends HTMLComponent {
? this.html.addClass("VariableSelected")
: this.html.removeClass("VariableSelected");

if (isEndClassGroup(this.ParentComponent))
this.#onSelectViewVar(this.ParentComponent.endClassVal,selected)
if (isEndClassGroup(this.parentComponent))
this.#onSelectViewVar(this.parentComponent.endClassVal,selected)

// The first StartClass gets an eye Btn to de/select
if(isStartClassGroup(this.ParentComponent) && this.ParentComponent.renderEyeBtn)
this.#onSelectViewVar(this.ParentComponent.startClassVal,selected)
if(isStartClassGroup(this.parentComponent) && this.parentComponent.renderEyeBtn)
this.#onSelectViewVar(this.parentComponent.startClassVal,selected)

};

Expand All @@ -202,14 +202,14 @@ class ClassTypeId extends HTMLComponent {
showTypeName(){
const currentSpan = this.htmlCurentValue.first()[0].getElementsByClassName('label').item(0)
//display label
currentSpan.textContent = this.specProvider.getEntity(this.ParentComponent.getTypeSelected()).getLabel();
currentSpan.textContent = this.specProvider.getEntity(this.parentComponent.getTypeSelected()).getLabel();
}

// renders the variable name
showVarName(){
const currentSpan = this.htmlCurentValue.first()[0].getElementsByClassName('label').item(0)
// display variable
currentSpan.textContent = this.ParentComponent.getVarName();
currentSpan.textContent = this.parentComponent.getVarName();
}

}
Expand Down Expand Up @@ -332,7 +332,7 @@ class ClassSelectBuilder extends HTMLComponent {

initDagWidget(items:DagIfc<ISpecificationEntity>, default_value: DagWidgetDefaultValue) {
let jsonDag = this.convertToJsonDag(items.roots) ;
this.selectWidget = new HierarchicalClassSelectBuilder(this.ParentComponent, this.specProvider, jsonDag, default_value );
this.selectWidget = new HierarchicalClassSelectBuilder(this.parentComponent, this.specProvider, jsonDag, default_value );
return this.selectWidget.buildClassSelectFromJson() ; ;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class EndClassGroup extends HTMLComponent {
constructor(ParentCriteriaGroup: CriteriaGroup, specProvider: ISparnaturalSpecification) {
super("EndClassGroup", ParentCriteriaGroup, null);
this.specProvider = specProvider;
this.ParentCriteriaGroup = this.ParentComponent as CriteriaGroup;
this.ParentCriteriaGroup = this.parentComponent as CriteriaGroup;
// this.endClassWidgetGroup = new EndClassWidgetGroup(this, this.specProvider);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export class EndClassWidgetGroup extends HTMLComponent {
)
return;

// if not, then create the EndclassWidgetValue and add it to the list
// if not, then create the EndclassWidgetValue and add it to the list
this.#renderEndClassWidgetVal(selectedVal);
}

Expand All @@ -149,7 +149,7 @@ export class EndClassWidgetGroup extends HTMLComponent {

// if the widget allows multiple values to be selected then AddWidgetValueBtn
// undefined for NON_SELECTABLE_PROPERTY
const widgetComp:AbstractWidget | undefined = (this.ParentComponent as CriteriaGroup).EndClassGroup.getWidgetComponent()
const widgetComp:AbstractWidget | undefined = (this.parentComponent as CriteriaGroup).EndClassGroup.getWidgetComponent()
if(widgetComp && widgetComp.valueRepetition == ValueRepetition.MULTIPLE && !(widgetVal instanceof SelectAllValue) ) {
// now (re)render the addMoreValuesButton
this.addWidgetValueBtn?.html
Expand Down Expand Up @@ -203,6 +203,13 @@ export class EndClassWidgetGroup extends HTMLComponent {
});
return vals;
}

/**
* @returns true if the widget value is the "Any" value
*/
hasAnyValue():boolean {
return this.getWidgetValues().some((v) => (v instanceof SelectAllValue))
}
}

export class EndClassWidgetValue extends HTMLComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,10 +469,10 @@ export class HierarchicalClassSelectBuilder extends HTMLComponent {

displayClassSelector() {
this.htmlSelectUiUx.addClass('open') ;
this.ParentComponent.html[0].classList.add('focus') ;
this.parentComponent.html[0].classList.add('focus') ;
}
hideClassSelector() {
this.ParentComponent.html[0].classList.remove('focus') ;
this.parentComponent.html[0].classList.remove('focus') ;
this.htmlSelectUiUx.removeClass('open') ;
}
setValue(selectedValue:string) {
Expand Down Expand Up @@ -537,11 +537,11 @@ export class HierarchicalClassSelectBuilder extends HTMLComponent {

if (this.isFlatHierarchy()) {
this.htmlSelectUiUx[0].classList.add('isFlat') ;
this.ParentComponent.html[0].classList.add('selectorIsFlat') ;
this.parentComponent.html[0].classList.add('selectorIsFlat') ;
}
if (this.hasIcon) {
this.htmlSelectUiUx[0].classList.add('hasIcon') ;
this.ParentComponent.html[0].classList.add('selectorHasIcon') ;
this.parentComponent.html[0].classList.add('selectorHasIcon') ;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class StartClassGroup extends HTMLComponent {

this.temporaryLabel = temporaryLabel;
this.inputSelector = new ClassTypeId(this, this.specProvider, this.temporaryLabel, startClassVal);
this.ParentCriteriaGroup = this.ParentComponent as CriteriaGroup;
this.ParentCriteriaGroup = this.parentComponent as CriteriaGroup;
this.startClassVal = startClassVal
? startClassVal
: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function addAndComponent(
startClassVal: SelectedVal
) {
grpWrapper.andSibling = new GroupWrapper(
grpWrapper.ParentComponent,
grpWrapper.parentComponent,
grpWrapper.specProvider,
// same depth
grpWrapper.depth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class VariableOptionsSelectBtn extends HTMLComponent {
}

render(): this {
this.htmlParent = this.ParentComponent.htmlParent;
this.htmlParent = this.parentComponent.htmlParent;
super.render();
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class DraggableComponent extends HTMLComponent {
aggrComponentInput: JQuery<HTMLElement>;
aggrComponentBadgeValue: JQuery<HTMLElement>;
aggrComponentOptionsExtend: JQuery<HTMLElement>;
ParentComponent: VariableOrderMenu;
parentComponent: VariableOrderMenu;

state: DraggableComponentState;

Expand Down Expand Up @@ -146,7 +146,7 @@ export class DraggableComponent extends HTMLComponent {
}

render(): this {
this.htmlParent = $(this.ParentComponent.html).find(
this.htmlParent = $(this.parentComponent.html).find(
".variablesOtherSelect"
);
super.render();
Expand Down Expand Up @@ -240,7 +240,7 @@ export class DraggableComponent extends HTMLComponent {
if(this.aggrComponentOptions[0].style.display == 'block') {
return this.closeAggrOptions() ;
}
if(this.ParentComponent.aggrOptionsExtend) {
if(this.parentComponent.aggrOptionsExtend) {
this.aggrComponentOptions[0].classList.remove('reducted');
this.aggrComponentOptions[0].classList.add('extended');
} else {
Expand All @@ -253,11 +253,11 @@ export class DraggableComponent extends HTMLComponent {
if(this.aggrComponentOptions[0].classList.contains('reducted')) {
this.aggrComponentOptions[0].classList.remove('reducted');
this.aggrComponentOptions[0].classList.add('extended');
this.ParentComponent.aggrOptionsExtend = true;
this.parentComponent.aggrOptionsExtend = true;
} else {
this.aggrComponentOptions[0].classList.add('reducted');
this.aggrComponentOptions[0].classList.remove('extended');
this.ParentComponent.aggrOptionsExtend = false;
this.parentComponent.aggrOptionsExtend = false;
}
}
onpenAggrOptions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class VariableOrderMenu extends HTMLComponent {
}

render(): this {
this.htmlParent = $(this.ParentComponent.html).find(".line2");
this.htmlParent = $(this.parentComponent.html).find(".line2");
super.render();
let otherSelectHtml = $('<div class="variablesOtherSelect"></div>');
this.html.append(otherSelectHtml);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class VariableSortOption extends HTMLComponent {
}

render(): this {
this.htmlParent = $(this.ParentComponent.html).find(".line1");
this.htmlParent = $(this.parentComponent.html).find(".line1");
super.render();
this.ascendBtn = new AscendBtn(this, this.changeSortOrderCallBack).render();
this.descendBtn = new DescendBtn(this, this.changeSortOrderCallBack).render();
Expand Down
Loading

0 comments on commit d6f24bc

Please sign in to comment.