sparnatural
Version:
Visual client-side SPARQL query builder and knowledge graph exploration tool
57 lines • 3 kB
JavaScript
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 _SearchRegexWidget_addValueBtnClicked;
import { DataFactory } from "rdf-data-factory";
import { AddUserInputBtn } from "../buttons/AddUserInputBtn";
import { AbstractWidget, ValueRepetition } from "./AbstractWidget";
import { Config } from "../../ontologies/SparnaturalConfig";
import { InfoBtn } from "../buttons/InfoBtn";
import { I18n } from "../../settings/I18n";
import { TOOLTIP_CONFIG } from "../../settings/defaultSettings";
const factory = new DataFactory();
export class SearchRegexWidget extends AbstractWidget {
constructor(configuration, parentComponent, startClassVal, objectPropVal, endClassVal) {
super("search-widget", parentComponent, null, startClassVal, objectPropVal, endClassVal,
// simple search or regexes can be multivalued, but proprietary seaerch patterns are not
(configuration.widgetType == Config.STRING_EQUALS_PROPERTY || configuration.widgetType == Config.SEARCH_PROPERTY)
? ValueRepetition.MULTIPLE
: ValueRepetition.SINGLE);
_SearchRegexWidget_addValueBtnClicked.set(this, () => {
this.searchInput.trigger("change");
let searchWidgetValue = {
label: this.searchInput.val().toString(),
criteria: {
search: this.searchInput.val().toString()
}
};
this.triggerRenderWidgetVal(searchWidgetValue);
});
this.configuration = configuration;
}
render() {
super.render();
this.searchInput = $(`<input />`);
this.html.append(this.searchInput);
// Build datatippy info
if (this.configuration.widgetType == Config.VIRTUOSO_SEARCH_PROPERTY) {
let datatippy = I18n.labels.VirtuosoSearchHelp;
// set a tooltip on the info circle
var tippySettings = Object.assign({}, TOOLTIP_CONFIG);
tippySettings.placement = "left";
tippySettings.trigger = "click";
tippySettings.offset = [50, -20];
tippySettings.delay = [0, 0];
this.infoBtn = new InfoBtn(this, datatippy, tippySettings).render();
} //finish datatippy
this.addValueBtn = new AddUserInputBtn(this, I18n.labels.ButtonAdd, __classPrivateFieldGet(this, _SearchRegexWidget_addValueBtnClicked, "f")).render();
return this;
}
parseInput(input) {
return input;
}
}
_SearchRegexWidget_addValueBtnClicked = new WeakMap();
//# sourceMappingURL=SearchRegexWidget.js.map