UNPKG

sparnatural

Version:

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

89 lines 4.22 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 _EditComponents_instances, _EditComponents_addEventListeners, _EditComponents_onAddWhere; import { getSettings } from "../../../../../../sparnatural/settings/defaultSettings"; import { Config } from "../../../../../ontologies/SparnaturalConfig"; import { HTMLComponent } from "../../../../HtmlComponent"; import WidgetWrapper from "./WidgetWrapper"; import ActionWhere from "../../../../buttons/actions/actioncomponents/ActionWhere"; class EditComponents extends HTMLComponent { constructor(parentComponent, startCassVal, objectPropVal, endClassVal, specProvider) { super("EditComponents", parentComponent, null); _EditComponents_instances.add(this); // MUST be arrowfunction _EditComponents_onAddWhere.set(this, () => { // Render the ViewVarBtn this.html[0].dispatchEvent(new CustomEvent("addWhereComponent", { bubbles: true, detail: this.endClassVal, })); }); this.startClassVal = startCassVal; this.objectPropVal = objectPropVal; this.endClassVal = endClassVal; this.specProvider = specProvider; } render() { super.render(); this.widgetWrapper = new WidgetWrapper(this, this.specProvider, this.startClassVal, this.objectPropVal, this.endClassVal).render(); let widgetType = this.widgetWrapper.getWidgetType(); if (EditComponents.RENDER_WHERE_WIDGET_TYPES.indexOf(widgetType) > -1 && // Do not allow WHERE if wehave reached max depth !this.maxDepthIsReached() && // If this owl:Class is not in a rdf:domain of a owl:ObjectProperty don't allow (this.specProvider.getEntity(this.endClassVal.type).getConnectedEntities().length !== 0)) { this.actionWhere = new ActionWhere(this, this.specProvider, __classPrivateFieldGet(this, _EditComponents_onAddWhere, "f")).render(); } __classPrivateFieldGet(this, _EditComponents_instances, "m", _EditComponents_addEventListeners).call(this); return this; } // The selectedValues are widgetValues which got selected by the user // For example a list of countries renderWidgetsWrapper() { super.render(); this.widgetWrapper.render(); } /** * Can be called from the outside when loading queries */ onSelectAll() { this.html[0].dispatchEvent(new CustomEvent("selectAll", { bubbles: true })); } maxDepthIsReached() { let maxreached = false; this.html[0].dispatchEvent(new CustomEvent("getMaxDepth", { bubbles: true, detail: (index) => { if (index >= getSettings().maxDepth) maxreached = true; }, })); return maxreached; } } _EditComponents_onAddWhere = new WeakMap(), _EditComponents_instances = new WeakSet(), _EditComponents_addEventListeners = function _EditComponents_addEventListeners() { // Binds a selection in an input widget with the display of the value in the line this.widgetWrapper.html[0].addEventListener("selectAll", (e) => { e.stopImmediatePropagation(); this.onSelectAll(); }); }; // the list of widget types for which the "WHERE" option should be available // this is an array of string to facilitate test with the widgetType value below EditComponents.RENDER_WHERE_WIDGET_TYPES = [ Config.LIST_PROPERTY, Config.LITERAL_LIST_PROPERTY, Config.RDFS_LITERAL, Config.AUTOCOMPLETE_PROPERTY, Config.TREE_PROPERTY, Config.NON_SELECTABLE_PROPERTY, ]; export default EditComponents; //# sourceMappingURL=EditComponents.js.map