diff --git a/app/static/js/CorpusAnalysis/QueryBuilder.js b/app/static/js/CorpusAnalysis/QueryBuilder.js index f9a10256..522054dd 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 d223ca30..e19a3728 100644 --- a/app/templates/corpora/analyse_corpus.concordance.html.j2 +++ b/app/templates/corpora/analyse_corpus.concordance.html.j2 @@ -66,7 +66,7 @@

 

build - Query builder + Query builder (beta)