Admin page Corpus List fix

This commit is contained in:
Inga Kirschnick 2023-06-07 11:23:59 +02:00
parent a54ff2e35a
commit 8aeafc33bd
3 changed files with 15 additions and 3 deletions

View File

@ -52,10 +52,12 @@ def users():
@register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc) @register_breadcrumb(bp, '.users.entity', '', dynamic_list_constructor=user_dlc)
def user(user_id): def user(user_id):
user = User.query.get_or_404(user_id) user = User.query.get_or_404(user_id)
corpora = Corpus.query.filter(Corpus.user == user).all()
return render_template( return render_template(
'admin/user.html.j2', 'admin/user.html.j2',
title=user.username, title=user.username,
user=user user=user,
corpora=corpora
) )

View File

@ -21,7 +21,7 @@
corpusList.add( corpusList.add(
[ [
{% for corpus in corpora %} {% for corpus in corpora %}
{{ corpus.to_json_serializeable(backrefs=True)|tojson }}, {{ corpus.to_json_serializeable(backrefs=True,relationships=True)|tojson }},
{% endfor %} {% endfor %}
] ]
); );

View File

@ -56,7 +56,7 @@
<div class="col s12" id="user-corpora"> <div class="col s12" id="user-corpora">
<div class="card"> <div class="card">
<div class="card-content"> <div class="card-content">
<div class="corpus-list" data-user-id="{{ user.hashid }}"></div> <div class="corpus-list no-autoinit" data-user-id="{{ user.hashid }}"></div>
</div> </div>
</div> </div>
</div> </div>
@ -107,6 +107,16 @@
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
<script> <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 userRoleChip = document.querySelector('#user-role-chip');
let userRoleChipTooltip = M.Tooltip.init( let userRoleChipTooltip = M.Tooltip.init(
userRoleChip, userRoleChip,