diff --git a/app/static/js/CorpusAnalysis/QueryBuilder.js b/app/static/js/CorpusAnalysis/QueryBuilder.js index f9a102566e17d8a6df2fbc876452e5dc36bbcf80..522054dd3d44681d4386eec28f3e75fdfe34869a 100644 --- a/app/static/js/CorpusAnalysis/QueryBuilder.js +++ b/app/static/js/CorpusAnalysis/QueryBuilder.js @@ -166,7 +166,6 @@ class ConcordanceQueryBuilder { } - // ########################################################################## // #################### General Functions ################################### // ########################################################################## @@ -229,27 +228,13 @@ class ConcordanceQueryBuilder { this.elements.queryContainer.classList.remove('hide'); this.queryPreviewBuilder(); - // Opens a hint about the possible functions for editing the query when the first chip is added. It is displayed for 5 seconds and then deleted. - if (this.elements.yourQuery.classList.contains('tooltipped')) { - let tooltipInstance = M.Tooltip.getInstance(this.elements.yourQuery); - tooltipInstance.tooltipEl.style.background = '#98ACD2'; - tooltipInstance.tooltipEl.style.borderTop = 'solid 4px #0064A3' - tooltipInstance.tooltipEl.style.padding = '10px'; - tooltipInstance.tooltipEl.style.color = 'black'; - - if (tooltipInstance !== undefined) { - setTimeout(() => { - tooltipInstance.open(); - setTimeout(() => { - tooltipInstance.destroy(); - }, 5000); - }, 500); - } - this.elements.yourQuery.classList.remove('tooltipped'); + // Shows a hint about possible functions for editing the query at the first added element in the query + if (this.elements.yourQuery.childNodes.length === 1) { + app.flash('You can edit your query by deleting individual elements or moving them via drag and drop.'); } } - //#region Drag&Drop Events + //#region Drag&Drop Events dragStartHandler(event) { // Creates element with the class 'target' and all necessary drop functions, in which drop content can be released this.elements.dropButton = event.target; @@ -329,12 +314,15 @@ class ConcordanceQueryBuilder { deleteAttr(attr) { this.elements.yourQuery.removeChild(attr); - + if (attr.dataset.type === "start-sentence") { + this.elements.sentence.innerHTML = 'Sentence'; + } else if (attr.dataset.type === "start-entity" || attr.dataset.type === "start-empty-entity") { + this.elements.entity.innerHTML = 'Entity'; + } this.elements.counter -= 1; if (this.elements.counter === 0) { this.elements.queryContainer.classList.add('hide'); } - this.queryPreviewBuilder(); } @@ -374,12 +362,19 @@ class ConcordanceQueryBuilder { entityEndCounter += 1; } } - if (sentenceCounter !== sentenceEndCounter) { - app.flash('Please add a closing sentence tag', 'error'); + // Checks if the same number of opening and closing tags (entity and sentence) are present. Depending on what is missing, the corresponding error message is ejected + if (sentenceCounter > sentenceEndCounter) { + app.flash('Please add the closing sentence tag', 'error'); + this.elements.valueValidator = false; + } else if (sentenceCounter < sentenceEndCounter) { + app.flash('Please remove the closing sentence tag', 'error'); this.elements.valueValidator = false; } - if (entityCounter !== entityEndCounter) { - app.flash('Please add a closing entity tag', 'error'); + if (entityCounter > entityEndCounter) { + app.flash('Please add the closing entity tag', 'error'); + this.elements.valueValidator = false; + } else if (entityCounter < entityEndCounter) { + app.flash('Please remove the closing entity tag', 'error'); this.elements.valueValidator = false; } } @@ -395,6 +390,8 @@ class ConcordanceQueryBuilder { this.elements.structuralAttrArea.classList.add('hide'); this.elements.yourQuery.innerHTML = ''; this.elements.queryContainer.classList.add('hide'); + this.elements.entity.innerHTML = 'Entity'; + this.elements.sentence.innerHTML = 'Sentence'; instance.tooltipEl.style.background = '#98ACD2'; instance.tooltipEl.style.borderTop = 'solid 4px #0064A3'; @@ -420,15 +417,13 @@ class ConcordanceQueryBuilder { //#endregion General Functions - - // ########################################################################## // ############## Token Attribute Builder Functions ######################### // ########################################################################## //#region Token Attribute Builder Functions - //#region General functions of the Token Builder + //#region General functions of the Token Builder tokenTypeSelector() { this.hideEverything(); switch (this.elements.positionalAttr.value) { @@ -871,8 +866,6 @@ class ConcordanceQueryBuilder { //#endregion Token Attribute Builder Functions - - // ########################################################################## // ############ Structural Attribute Builder Functions ###################### // ########################################################################## @@ -961,7 +954,7 @@ class ConcordanceQueryBuilder { this.elements.noValueMetadataMessage.classList.add('hide'); }, 3000); } else { - let queryText = `:: match.text_${this.elements.textAnnotationOptions.value}='${this.elements.textAnnotationInput.value}'`; + let queryText = `:: match.text_${this.elements.textAnnotationOptions.value}="${this.elements.textAnnotationInput.value}"`; this.buttonfactory('text-annotation', `${this.elements.textAnnotationOptions.value}=${this.elements.textAnnotationInput.value}`, queryText); this.hideEverything(); } diff --git a/app/templates/corpora/analyse_corpus.concordance.html.j2 b/app/templates/corpora/analyse_corpus.concordance.html.j2 index d223ca307a13adb050c9e22917e4a966a3a4a01a..e19a372861bafd2917964c5eb76b6ac628e80ecf 100644 --- a/app/templates/corpora/analyse_corpus.concordance.html.j2 +++ b/app/templates/corpora/analyse_corpus.concordance.html.j2 @@ -66,7 +66,7 @@ <p class="hide-on-small-only"> </p> <a class="btn waves-effect waves-light modal-trigger" href="#concordance-query-builder" id="concordance-query-builder-button"> <i class="material-icons left">build</i> - Query builder + Query builder (beta) </a> <button class="btn waves-effect waves-light corpus-analysis-action" id="concordance-extension-form-submit" type="submit" name="submit"> Send diff --git a/app/templates/corpora/analyse_corpus.html.j2 b/app/templates/corpora/analyse_corpus.html.j2 index 50c7d71c0038a973f91a4af8fe3339961ce4a0a9..779eafd4e707a92d450bacf0639ddd9b391e4464 100644 --- a/app/templates/corpora/analyse_corpus.html.j2 +++ b/app/templates/corpora/analyse_corpus.html.j2 @@ -254,7 +254,7 @@ <div> <nav> <div class="nav-wrapper" id="query-builder-nav"> - <a href="#!" class="brand-logo"><i class="material-icons">build</i>Query Builder</a> + <a href="#!" class="brand-logo"><i class="material-icons">build</i>Query Builder (beta)</a> <i class="material-icons close right" id="close-query-builder">close</i> <a class="modal-trigger" href="#query-builder-tutorial-modal" > <i class="material-icons right tooltipped" id="query-builder-tutorial-info-icon" data-position="bottom" data-tooltip="Click here if you are unsure how to use the Query Builder <br>and want to find out what other options it offers.">help</i> @@ -274,7 +274,7 @@ </h6> </div> <div class="row"> - <div class="col s10 tooltipped" id="your-query" data-position="bottom" data-tooltip="You can edit your query by deleting individual elements or moving them via drag and drop."></div> + <div class="col s10" id="your-query"></div> <a class="btn-small waves-effect waves-teal col s1" id="insert-query-button"> <i class="material-icons">send</i> </a> diff --git a/app/templates/test/analyse_corpus.html.j2 b/app/templates/test/analyse_corpus.html.j2 index 8f7374c9985d5cfa3255395ad6b31e843625209d..faef6abd6672c03c79510e64f4dff9116a478f2c 100644 --- a/app/templates/test/analyse_corpus.html.j2 +++ b/app/templates/test/analyse_corpus.html.j2 @@ -106,7 +106,7 @@ </h6> </div> <div class="row"> - <div class="col s10 tooltipped" id="your-query" data-position="bottom" data-tooltip="You can edit your query by deleting individual elements or moving them via drag and drop."></div> + <div class="col s10" id="your-query" data-position="bottom" data-tooltip="You can edit your query by deleting individual elements or moving them via drag and drop."></div> <a class="btn-small waves-effect waves-teal col s1" id="insert-query-button"> <i class="material-icons">send</i> </a>