Corpus Following Functions & small QB fix

This commit is contained in:
Inga Kirschnick 2023-01-16 15:43:43 +01:00
parent d669ed3ffc
commit 8b7c334007
2 changed files with 23 additions and 5 deletions

View File

@ -558,6 +558,18 @@ class User(HashidMixin, UserMixin, db.Model):
self.profile_privacy_settings = 0 self.profile_privacy_settings = 0
#endregion Profile Privacy settings #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): def to_json_serializeable(self, backrefs=False, relationships=False, filter_by_privacy_settings=False):
json_serializeable = { json_serializeable = {
'id': self.hashid, 'id': self.hashid,

View File

@ -14,6 +14,7 @@ class ConcordanceQueryBuilder {
queryBuilderTutorialModal: document.querySelector('#query-builder-tutorial-modal'), queryBuilderTutorialModal: document.querySelector('#query-builder-tutorial-modal'),
valueValidator: true, valueValidator: true,
//#region QueryBuilder Elements //#region QueryBuilder Elements
positionalAttrButton: document.querySelector('#positional-attr-button'), positionalAttrButton: document.querySelector('#positional-attr-button'),
@ -175,6 +176,7 @@ class ConcordanceQueryBuilder {
closeQueryBuilderModal(closeInstance) { closeQueryBuilderModal(closeInstance) {
let instance = M.Modal.getInstance(closeInstance); let instance = M.Modal.getInstance(closeInstance);
instance.close(); instance.close();
} }
showPositionalAttrArea() { showPositionalAttrArea() {
@ -362,7 +364,7 @@ class ConcordanceQueryBuilder {
} }
clearAll() { 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); let instance = M.Tooltip.getInstance(this.elements.queryBuilderTutorialInfoIcon);
this.hideEverything(); this.hideEverything();
@ -375,16 +377,20 @@ class ConcordanceQueryBuilder {
this.elements.entity.innerHTML = 'Entity'; this.elements.entity.innerHTML = 'Entity';
this.elements.sentence.innerHTML = 'Sentence'; 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.background = '#98ACD2';
instance.tooltipEl.style.borderTop = 'solid 4px #0064A3'; instance.tooltipEl.style.borderTop = 'solid 4px #0064A3';
instance.tooltipEl.style.padding = '10px'; instance.tooltipEl.style.padding = '10px';
instance.tooltipEl.style.color = 'black'; instance.tooltipEl.style.color = 'black';
setTimeout(() => { setTimeout(() => {
let modalInstance = M.Modal.getInstance(this.elements.concordanceQueryBuilder);
if (modalInstance.isOpen) {
instance.open(); instance.open();
setTimeout(() => { setTimeout(() => {
instance.close(); instance.close();
}, 5000); }, 5000);
}
}, 5000); }, 5000);
} }