mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2025-01-16 21:10:35 +00:00
Compare commits
4 Commits
62d20409ea
...
15e7fa6dd3
Author | SHA1 | Date | |
---|---|---|---|
|
15e7fa6dd3 | ||
|
589c4a6c56 | ||
|
9ffc41a133 | ||
|
4944d31dd5 |
@ -72,7 +72,6 @@ def corpus(corpus_id):
|
||||
)
|
||||
if (current_user.is_following_corpus(corpus) or corpus.is_public):
|
||||
cfas = CorpusFollowerAssociation.query.filter(Corpus.id == corpus_id, CorpusFollowerAssociation.follower_id != corpus.user.id).all()
|
||||
print(cfas)
|
||||
return render_template(
|
||||
'corpora/public_corpus.html.j2',
|
||||
title=corpus.title,
|
||||
|
@ -39,10 +39,8 @@ def faq():
|
||||
@register_breadcrumb(bp, '.dashboard', '<i class="material-icons left">dashboard</i>Dashboard')
|
||||
@login_required
|
||||
def dashboard():
|
||||
corpora = Corpus.query.filter(or_(Corpus.followers.any(id=current_user.id), Corpus.user == current_user)).all()
|
||||
return render_template(
|
||||
'main/dashboard.html.j2',
|
||||
corpora=corpora,
|
||||
title='Dashboard'
|
||||
)
|
||||
|
||||
|
@ -493,7 +493,7 @@ class CorpusFollowerAssociation(HashidMixin, db.Model):
|
||||
def to_json_serializeable(self, backrefs=False, relationships=False):
|
||||
json_serializeable = {
|
||||
'id': self.hashid,
|
||||
'corpus': self.corpus.to_json_serializeable(),
|
||||
'corpus': self.corpus.to_json_serializeable(backrefs=True),
|
||||
'follower': self.follower.to_json_serializeable(),
|
||||
'role': self.role.to_json_serializeable()
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class CorpusFileList extends ResourceList {
|
||||
get item() {
|
||||
return (values) => {
|
||||
return `
|
||||
<tr class="list-item">
|
||||
<tr class="list-item clickable hoverable">
|
||||
<td>
|
||||
<label class="list-action-trigger ${this.hasPermissionView ? '' : 'hide'}" data-list-action="select">
|
||||
<input class="select-checkbox" type="checkbox">
|
||||
@ -79,7 +79,7 @@ class CorpusFileList extends ResourceList {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<label class="selection-action-trigger ${this.listContainerElement.dataset?.hasPermissionView == 'true' ? '' : 'hide'}" data-selection-action="select-all">
|
||||
<label class="disable-on-click selection-action-trigger ${this.listContainerElement.dataset?.hasPermissionView == 'true' ? '' : 'hide'}" data-selection-action="select-all">
|
||||
<input class="select-all-checkbox" type="checkbox">
|
||||
<span class="disable-on-click"></span>
|
||||
</label>
|
||||
@ -121,7 +121,7 @@ class CorpusFileList extends ResourceList {
|
||||
if (listItemElement === null) {return;}
|
||||
let itemId = listItemElement.dataset.id;
|
||||
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||
let listAction = listActionElement === null ? '' : listActionElement.dataset.listAction;
|
||||
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||
switch (listAction) {
|
||||
case 'delete': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
|
@ -185,7 +185,6 @@ class CorpusFollowerList extends ResourceList {
|
||||
case 'replace': {
|
||||
let re = new RegExp(`^/users/${this.userId}/corpora/${this.corpusId}/corpus_follower_associations/([A-Za-z0-9]*)/role$`);
|
||||
if (re.test(operation.path)) {
|
||||
console.log('role updated');
|
||||
let [match, jobId, valueName] = operation.path.match(re);
|
||||
this.replace(jobId, valueName, operation.value);
|
||||
}
|
||||
|
@ -20,13 +20,50 @@ class CorpusList extends ResourceList {
|
||||
if (this.isInitialized) {this.onPatch(patch);}
|
||||
});
|
||||
});
|
||||
app.getUser(this.userId).then((user) => {
|
||||
this.add(this.aggregateData(user));
|
||||
this.isInitialized = true;
|
||||
});
|
||||
}
|
||||
|
||||
aggregateData(user) {
|
||||
const aggregatedData = [];
|
||||
for (let corpus of Object.values(user.corpora)) {
|
||||
aggregatedData.push(
|
||||
{
|
||||
'id': corpus.id,
|
||||
'creation-date': corpus.creation_date,
|
||||
'description': corpus.description,
|
||||
'status': corpus.status,
|
||||
'title': corpus.title,
|
||||
'owner': user.username,
|
||||
'is-owner': true,
|
||||
'current-user-is-following': false
|
||||
}
|
||||
);
|
||||
}
|
||||
for (let cfa of Object.values(user.corpus_follower_associations)) {
|
||||
aggregatedData.push(
|
||||
{
|
||||
'id': cfa.corpus.id,
|
||||
'creation-date': cfa.corpus.creation_date,
|
||||
'description': cfa.corpus.description,
|
||||
'status': cfa.corpus.status,
|
||||
'title': cfa.corpus.title,
|
||||
'owner': cfa.corpus.user.username,
|
||||
'is-owner': false,
|
||||
'current-user-is-following': true
|
||||
}
|
||||
);
|
||||
}
|
||||
return aggregatedData;
|
||||
}
|
||||
|
||||
// #region Mandatory getters and methods to implement
|
||||
get item() {
|
||||
return (values) => {
|
||||
return `
|
||||
<tr class="list-item">
|
||||
<tr class="list-item clickable hoverable">
|
||||
<td>
|
||||
<label class="list-action-trigger" data-list-action="select">
|
||||
<input class="select-checkbox" type="checkbox">
|
||||
@ -93,19 +130,6 @@ class CorpusList extends ResourceList {
|
||||
`.trim();
|
||||
}
|
||||
|
||||
mapResourceToValue(corpus) {
|
||||
return {
|
||||
'id': corpus.id,
|
||||
'creation-date': corpus.creation_date,
|
||||
'description': corpus.description,
|
||||
'status': corpus.status,
|
||||
'title': corpus.title,
|
||||
'owner': corpus.user.username,
|
||||
'is-owner': corpus.user.id === this.userId ? true : false,
|
||||
'current-user-is-following': Object.values(corpus.corpus_follower_associations).some(association => association.follower.id === currentUserId)
|
||||
};
|
||||
}
|
||||
|
||||
sort() {
|
||||
this.listjs.sort('creation-date', {order: 'desc'});
|
||||
}
|
||||
@ -115,7 +139,7 @@ class CorpusList extends ResourceList {
|
||||
if (listItemElement === null) {return;}
|
||||
let itemId = listItemElement.dataset.id;
|
||||
let listActionElement = event.target.closest('.list-action-trigger[data-list-action]');
|
||||
let listAction = listActionElement === null ? '' : listActionElement.dataset.listAction;
|
||||
let listAction = listActionElement === null ? 'view' : listActionElement.dataset.listAction;
|
||||
switch (listAction) {
|
||||
case 'delete-request': {
|
||||
let values = this.listjs.get('id', itemId)[0].values();
|
||||
|
@ -1,6 +1,6 @@
|
||||
class PublicCorpusList extends CorpusList {
|
||||
get item() {
|
||||
return (values) => {
|
||||
return (values) => {
|
||||
return `
|
||||
<tr class="list-item clickable hoverable">
|
||||
<td><b class="title"></b><br><i class="description"></i></td>
|
||||
@ -14,6 +14,19 @@ class PublicCorpusList extends CorpusList {
|
||||
};
|
||||
}
|
||||
|
||||
mapResourceToValue(corpus) {
|
||||
return {
|
||||
'id': corpus.id,
|
||||
'creation-date': corpus.creation_date,
|
||||
'description': corpus.description,
|
||||
'status': corpus.status,
|
||||
'title': corpus.title,
|
||||
'owner': corpus.user.username,
|
||||
'is-owner': corpus.user.id === this.userId ? true : false,
|
||||
'current-user-is-following': Object.values(corpus.corpus_follower_associations).some(association => association.follower.id === currentUserId)
|
||||
};
|
||||
}
|
||||
|
||||
initListContainerElement() {
|
||||
if (!this.listContainerElement.hasAttribute('id')) {
|
||||
this.listContainerElement.id = Utils.generateElementId('corpus-list-');
|
||||
|
@ -56,7 +56,7 @@
|
||||
<div class="col s12" id="user-corpora">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="corpus-list no-autoinit" data-user-id="{{ user.hashid }}"></div>
|
||||
<div class="corpus-list" data-user-id="{{ user.hashid }}"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -107,16 +107,6 @@
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
|
||||
let corpusList = new CorpusList(document.querySelector('.corpus-list'));
|
||||
corpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
{{ corpus.to_json_serializeable(backrefs=True, relationships=True)|tojson }},
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
|
||||
let userRoleChip = document.querySelector('#user-role-chip');
|
||||
let userRoleChipTooltip = M.Tooltip.init(
|
||||
userRoleChip,
|
||||
|
@ -15,7 +15,7 @@
|
||||
<div class="col s12">
|
||||
<div class="card">
|
||||
<div class="card-content">
|
||||
<div class="corpus-list no-autoinit" data-user-id="{{ current_user.hashid }}"></div>
|
||||
<div class="corpus-list" data-user-id="{{ current_user.hashid }}"></div>
|
||||
</div>
|
||||
<div class="card-action right-align">
|
||||
<a class="btn disabled waves-effect waves-light" href="{{ url_for('corpora.import_corpus') }}">Import Corpus<i class="material-icons right">import_export</i></a>
|
||||
@ -135,17 +135,3 @@
|
||||
</div>
|
||||
</div>
|
||||
{% endblock modals %}
|
||||
|
||||
{% block scripts %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
let corpusList = new CorpusList(document.querySelector('.corpus-list'));
|
||||
corpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
{{ corpus.to_json_serializeable(backrefs=True, relationships=True)|tojson }},
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
</script>
|
||||
{% endblock scripts %}
|
||||
|
@ -70,7 +70,7 @@
|
||||
{% endfor %}
|
||||
]
|
||||
);
|
||||
let publicCorpusList = new DetailledPublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||
let publicCorpusList = new PublicCorpusList(document.querySelector('.public-corpus-list'));
|
||||
publicCorpusList.add(
|
||||
[
|
||||
{% for corpus in corpora %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user