UNPKG

sparnatural

Version:

Visual client-side SPARQL query builder and knowledge graph exploration tool

94 lines 4.66 kB
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); }; var _ObjectPropertyGroup_instances, _ObjectPropertyGroup_addEventListener, _ObjectPropertyGroup_createSparqlVar, _ObjectPropertyGroup_valueWasSelected; import tippy from "tippy.js"; import ObjectPropertyTypeId from "./ObjectPropertyTypeId"; import { HTMLComponent } from "../../../../HtmlComponent"; import { TOOLTIP_CONFIG } from "../../../../../settings/defaultSettings"; /** * The property selection part of a criteria/line, encapsulating an ObjectPropertyTypeId **/ class ObjectPropertyGroup extends HTMLComponent { constructor(ParentComponent, specProvider, temporaryLabel) { super("ObjectPropertyGroup", ParentComponent, null); _ObjectPropertyGroup_instances.add(this); // value which shows which object property got chosen by the config for subject and object this.objectPropVal = { variable: null, type: null, }; this.ParentCriteriaGroup = ParentComponent; this.temporaryLabel = temporaryLabel; this.specProvider = specProvider; } render() { super.render(); __classPrivateFieldGet(this, _ObjectPropertyGroup_instances, "m", _ObjectPropertyGroup_addEventListener).call(this); return this; } /* renders the temporarly object property */ onStartClassGroupSelected(startClassVal) { this.startClassVal = startClassVal; //this will set the temporary label since there hasn't been a Value chosen for EndClassGroup this.inputSelector = new ObjectPropertyTypeId(this, this.specProvider, this.temporaryLabel, this.startClassVal).render(); } getTypeSelected() { return this.objectPropVal.type; } getVarName() { return this.objectPropVal.variable; } /* This method is triggered when an Object is selected. For example: Museum isRelatedTo Country. As soon as Country is chosen this method gets called */ onEndClassGroupSelected(endClassVal) { // this will update the temporarly label this.inputSelector.setEndClassVal(endClassVal); this.inputSelector.render(); } } _ObjectPropertyGroup_instances = new WeakSet(), _ObjectPropertyGroup_addEventListener = function _ObjectPropertyGroup_addEventListener() { // event is caught here and then bubbles up to the CriteriaGroup this.html[0].addEventListener("onObjectPropertyTypeIdSelected", (e) => { e.stopImmediatePropagation(); if (e.detail === "" || !e.detail) throw Error('No value received on "onObjectPropertyGroupSelected"'); __classPrivateFieldGet(this, _ObjectPropertyGroup_instances, "m", _ObjectPropertyGroup_createSparqlVar).call(this, e.detail); __classPrivateFieldGet(this, _ObjectPropertyGroup_instances, "m", _ObjectPropertyGroup_valueWasSelected).call(this); }); }, _ObjectPropertyGroup_createSparqlVar = function _ObjectPropertyGroup_createSparqlVar(type) { this.objectPropVal.type = type; this.html[0].dispatchEvent(new CustomEvent("getSparqlVar", { bubbles: true, detail: { type: type, callback: (variable) => { //callback this.objectPropVal.variable = variable; } } })); }, _ObjectPropertyGroup_valueWasSelected = function _ObjectPropertyGroup_valueWasSelected() { this.html[0].dispatchEvent(new CustomEvent("onObjectPropertyGroupSelected", { bubbles: true, detail: this.objectPropVal, })); var desc = this.specProvider.getProperty(this.objectPropVal.type).getTooltip(); if (desc) { $(this.ParentCriteriaGroup.objectPropertyGroup.html).find('.ObjectPropertyTypeId').attr('data-tippy-content', desc.replace(/"/g, '"')); var tippySettings = Object.assign({}, TOOLTIP_CONFIG); tippySettings.placement = "top-start"; tippy('.ObjectPropertyGroup .ObjectPropertyTypeId[data-tippy-content]', tippySettings); } else { $(this.ParentCriteriaGroup.objectPropertyGroup.html).removeAttr('data-tippy-content'); } }; export default ObjectPropertyGroup; //# sourceMappingURL=ObjectPropertyGroup.js.map