diff --git a/app/models.py b/app/models.py index 9b232c1a..c53956fd 100644 --- a/app/models.py +++ b/app/models.py @@ -558,6 +558,18 @@ class User(HashidMixin, UserMixin, db.Model): self.profile_privacy_settings = 0 #endregion Profile Privacy settings + def follow_corpus(self, corpus): + if not self.is_following(corpus): + self.followed_corpora.append(corpus) + + def unfollow_corpus(self, corpus): + if self.is_following(corpus): + self.followed_corpora.remove(corpus) + + def is_following_corpus(self, corpus): + return self.followed_corpora.filter( + corpus_followers.c.corpus_id == corpus.id).count() > 0 + def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False): json_serializeable = { 'id': self.hashid, diff --git a/app/static/js/CorpusAnalysis/QueryBuilder.js b/app/static/js/CorpusAnalysis/QueryBuilder.js index 4e34f04c..ef7d96f1 100644 --- a/app/static/js/CorpusAnalysis/QueryBuilder.js +++ b/app/static/js/CorpusAnalysis/QueryBuilder.js @@ -14,6 +14,7 @@ class ConcordanceQueryBuilder { queryBuilderTutorialModal: document.querySelector('#query-builder-tutorial-modal'), valueValidator: true, + //#region QueryBuilder Elements positionalAttrButton: document.querySelector('#positional-attr-button'), @@ -175,6 +176,7 @@ class ConcordanceQueryBuilder { closeQueryBuilderModal(closeInstance) { let instance = M.Modal.getInstance(closeInstance); instance.close(); + } showPositionalAttrArea() { @@ -362,7 +364,7 @@ class ConcordanceQueryBuilder { } clearAll() { - // Everything is reset. After 5 seconds for 5 seconds (with 'instance'), a message is displayed indicating that further information can be obtained via the question mark icon + // Everything is reset. let instance = M.Tooltip.getInstance(this.elements.queryBuilderTutorialInfoIcon); this.hideEverything(); @@ -375,16 +377,20 @@ class ConcordanceQueryBuilder { this.elements.entity.innerHTML = 'Entity'; this.elements.sentence.innerHTML = 'Sentence'; + // If the Modal is open after 5 seconds for 5 seconds (with 'instance'), a message is displayed indicating that further information can be obtained via the question mark icon instance.tooltipEl.style.background = '#98ACD2'; instance.tooltipEl.style.borderTop = 'solid 4px #0064A3'; instance.tooltipEl.style.padding = '10px'; instance.tooltipEl.style.color = 'black'; setTimeout(() => { - instance.open(); - setTimeout(() => { - instance.close(); - }, 5000); + let modalInstance = M.Modal.getInstance(this.elements.concordanceQueryBuilder); + if (modalInstance.isOpen) { + instance.open(); + setTimeout(() => { + instance.close(); + }, 5000); + } }, 5000); }