From 5ff4e425738ed62014148e2fdc95b4bf2383fd83 Mon Sep 17 00:00:00 2001 From: Thomas Francart Date: Sat, 13 Jul 2024 19:05:29 +0200 Subject: [PATCH] comments --- .../criteriagroup/edit-components/WidgetWrapper.ts | 2 +- src/sparnatural/components/widgets/AbstractWidget.ts | 11 +---------- src/sparnatural/generators/sparql/ValueBuilder.ts | 4 ++++ src/sparnatural/generators/sparql/WhereBuilder.ts | 4 ++-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/sparnatural/components/builder-section/groupwrapper/criteriagroup/edit-components/WidgetWrapper.ts b/src/sparnatural/components/builder-section/groupwrapper/criteriagroup/edit-components/WidgetWrapper.ts index bc9a0cc5..239608fe 100644 --- a/src/sparnatural/components/builder-section/groupwrapper/criteriagroup/edit-components/WidgetWrapper.ts +++ b/src/sparnatural/components/builder-section/groupwrapper/criteriagroup/edit-components/WidgetWrapper.ts @@ -135,7 +135,7 @@ class WidgetWrapper extends HTMLComponent { 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) ?(htmlString = lineSpan + endLabelSpan) :(htmlString = lineSpan + selectAnySpan + orSpan + endLabelSpan); diff --git a/src/sparnatural/components/widgets/AbstractWidget.ts b/src/sparnatural/components/widgets/AbstractWidget.ts index 269b1133..121ea68c 100644 --- a/src/sparnatural/components/widgets/AbstractWidget.ts +++ b/src/sparnatural/components/widgets/AbstractWidget.ts @@ -94,22 +94,13 @@ export abstract class AbstractWidget extends HTMLComponent { // Is used to parse the inputs from the ISparnaturalJson e.g "preloaded" queries abstract parseInput(value:WidgetValue["value"]):WidgetValue - - getSparnaturalRepresentation() { - let vals = this.widgetValues.map((v) => v.value); - return JSON.stringify(vals); - } addWidgetValue(widgetValue: WidgetValue) { this.widgetValues.push(widgetValue); } - getLastValue() { - return this.widgetValues[this.widgetValues.length - 1]; - } - // returns null if valueObject has not been set before - getwidgetValues(): WidgetValue[] { + getWidgetValues(): WidgetValue[] { return this.widgetValues; } diff --git a/src/sparnatural/generators/sparql/ValueBuilder.ts b/src/sparnatural/generators/sparql/ValueBuilder.ts index 8387dfcb..9b2b05a3 100644 --- a/src/sparnatural/generators/sparql/ValueBuilder.ts +++ b/src/sparnatural/generators/sparql/ValueBuilder.ts @@ -17,6 +17,10 @@ import { LatLng } from "leaflet"; const factory = new DataFactory(); +/** + * A factory for creating ValueBuilders from the widgetType. This is the association between the widget type + * and the corresponding ValueBuilder + */ export class ValueBuilderFactory { buildValueBuilder( diff --git a/src/sparnatural/generators/sparql/WhereBuilder.ts b/src/sparnatural/generators/sparql/WhereBuilder.ts index 225490dd..39492c81 100644 --- a/src/sparnatural/generators/sparql/WhereBuilder.ts +++ b/src/sparnatural/generators/sparql/WhereBuilder.ts @@ -58,7 +58,7 @@ export default class WhereBuilder{ this.#grpWrapper.CriteriaGroup.ObjectPropertyGroup.objectPropVal, this.#grpWrapper.CriteriaGroup.EndClassGroup.endClassVal, this.#grpWrapper.CriteriaGroup.EndClassGroup.isVarSelected(), - this.#grpWrapper.CriteriaGroup.EndClassGroup?.editComponents?.widgetWrapper?.widgetComponent.getwidgetValues() + this.#grpWrapper.CriteriaGroup.EndClassGroup?.editComponents?.widgetWrapper?.widgetComponent.getWidgetValues() ); } } @@ -114,7 +114,7 @@ export default class WhereBuilder{ #buildRdfPtrn(){ let widgetComponent = this.#grpWrapper.CriteriaGroup.EndClassGroup?.editComponents?.widgetWrapper?.widgetComponent - if (widgetComponent?.getwidgetValues()?.length > 0 ) { + if (widgetComponent?.getWidgetValues()?.length > 0 ) { this.#rdfPtrns = this.#valueBuilder.build(); }