From f183f0f262191e1ef9745f5ee3e0c2f4deec552f Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Fri, 2 Dec 2022 15:41:31 +0100 Subject: [PATCH] DOC: more docs for the free query feature --- src/core/js/webcaosdb.js | 16 +++++++++++++--- src/core/xsl/query.xsl | 2 +- test/core/js/modules/webcaosdb.js.js | 2 +- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/js/webcaosdb.js b/src/core/js/webcaosdb.js index 955bdd0b..8c15cab3 100644 --- a/src/core/js/webcaosdb.js +++ b/src/core/js/webcaosdb.js @@ -1374,6 +1374,9 @@ var paging = new function () { }; var queryForm = new function () { + var logger = log.getLogger("queryForm"); + this.logger = logger; + this.init = function (form) { this.restoreLastQuery(form, () => window.sessionStorage.lastQuery); this.bindOnClick(form, (set) => { @@ -1395,14 +1398,21 @@ var queryForm = new function () { * instead which goes like: FIND Persion WHICH HAS A PROPERTY LIKE * "*something*". * + * Note: This feature is disabled by default. Enable it by specifying the + * build variable BUILD_FREE_SEARCH_ROLE_NAME_FACET_OPTIONS as a + * comma-separated list of **properly quoted** expressions, e.g. + * "FILE 'numpy array', 'Plant Experiemnt', 'quotes_not_necessary'". + * Otherwise, the server will throw a syntax error. + * * @param {HTMLElement} form - the form which will be initialized for the * free search. - * @param {string} options - comma separated list of options. + * @param {string} options - comma-separated list of options. * @return {boolean} - true if the initialization was successful, false * otherwise. */ this.initFreeSearch = function (form, options) { - const textArea = $(form).find(".caosdb-query-textarea"); + const textArea = $(form).find(".caosdb-f-query-textarea"); + logger.trace("initFreeSearch", form, textArea, options); if (textArea.length > 0 && options && options != "") { const lastQuery = window.localStorage["freeTextQuery:" + textArea[0].value]; if (lastQuery) { @@ -1534,7 +1544,7 @@ var queryForm = new function () { btn.html(`<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>`); btn.prop("disabled", true); - var textField = $(form).find(".caosdb-query-textarea"); + var textField = $(form).find(".caosdb-f-query-textarea"); textField.blur(); textField.prop("disabled", true); }; diff --git a/src/core/xsl/query.xsl b/src/core/xsl/query.xsl index 702a390f..6497cc9c 100644 --- a/src/core/xsl/query.xsl +++ b/src/core/xsl/query.xsl @@ -359,7 +359,7 @@ </xsl:attribute> <input id="caosdb-query-paging-input" name="P" type="hidden" value="0L10"/> <div class="input-group"> - <input class="form-control" id="caosdb-query-textarea" name="query" placeholder="E.g. 'FIND Experiment'" rows="1" style="resize: vertical;" type="text"></input> + <input class="form-control caosdb-f-query-textarea" id="caosdb-query-textarea" name="query" placeholder="E.g. 'FIND Experiment'" rows="1" style="resize: vertical;" type="text"></input> <a class="btn btn-secondary caosdb-search-btn" href="#" title="Click to execute the query."> <i class="bi-search"></i> </a> diff --git a/test/core/js/modules/webcaosdb.js.js b/test/core/js/modules/webcaosdb.js.js index b47c98a6..cfb86e45 100644 --- a/test/core/js/modules/webcaosdb.js.js +++ b/test/core/js/modules/webcaosdb.js.js @@ -1255,7 +1255,7 @@ QUnit.test("splitSearchTerms", function (assert) { QUnit.test("initFreeSearch", function (assert) { const form = $('<form></form>'); const inputGroup = $('<div class="input-group"></div>'); - const textArea = $( '<textarea class="caosdb-query-textarea" name="query"></textarea>'); + const textArea = $( '<textarea class="caosdb-f-query-textarea" name="query"></textarea>'); const submitButton = $('<input class="caosdb-search-btn" type="submit">'); inputGroup.append(textArea); form.append(inputGroup).append(submitButton); -- GitLab