diff --git a/src/core/js/webcaosdb.js b/src/core/js/webcaosdb.js index 955bdd0b777033531242b8533055cb925d96bae4..8c15cab34cc7e743497b65f2ca0fb77b8712ab8a 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 702a390f28ada96e140f40f10218b1740ab10700..6497cc9c64f7921c2b26b4ccd6535d181ddfeb4b 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 b47c98a6547b89192fd003c2734dfde5e89ee7f4..cfb86e459acf6f38e5672918df81a42b0eb1ea2a 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);