From f01e0a2954128723654d6204fef36d62c4b11acb Mon Sep 17 00:00:00 2001 From: dcz <dcz@ipipan.waw.pl> Date: Thu, 29 Feb 2024 13:43:48 +0100 Subject: [PATCH] Free lus for lexicografs. --- entries/static/entries/js/free_lus_list.js | 2 +- entries/templates/entries_base.html | 2 +- freelus/views.py | 2 ++ frontend/src/components/unification/free_lu/FreeLuEdit.vue | 7 +++++-- .../src/components/unification/free_lu/FreeLusList.vue | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/entries/static/entries/js/free_lus_list.js b/entries/static/entries/js/free_lus_list.js index 9b9a691..908c223 100644 --- a/entries/static/entries/js/free_lus_list.js +++ b/entries/static/entries/js/free_lus_list.js @@ -2,7 +2,7 @@ function setup_free_lus_list(options) { const can_see_assignees = has_permission("users.view_assignment"); let ajaxURL = '/' + lang + '/entries/get_entries/?has_unified_frame=false&with_lexical_units=false&without_frames='+ (options.show_all ? 'false' : 'true') +'&show_linked_entries_disabled=true'; - if(!can_see_assignees) { + if(!can_see_assignees && !options.show_all) { ajaxURL += '&restrict_to_user='+window.USER_USERNAME; } diff --git a/entries/templates/entries_base.html b/entries/templates/entries_base.html index 2acdd29..d75b147 100644 --- a/entries/templates/entries_base.html +++ b/entries/templates/entries_base.html @@ -33,8 +33,8 @@ <li class="nav-item mr-1"><a onclick='window.location.replace(window.currUnifiedFrameId ? "/pl/entries/hierarchy/?unified_frame_id="+window.currUnifiedFrameId : "/pl/entries/hierarchy")' class="nav-link cursor-pointer">{% trans "Hierarchia" %}</a></li> + <li class="nav-item mr-1"><a href="{% url 'entries:lu_free' %}" class="nav-link">{% trans "Wolne jednostki" %}</a></li> {% if is_superlexicograf %} - <li class="nav-item mr-1"><a href="{% url 'entries:lu_free' %}" class="nav-link">{% trans "Wolne jednostki" %}</a></li> <li class="nav-item mr-1"><a onclick='window.location.replace(window.currUnifiedFrameId ? "/pl/entries/vertical-relations/?unified_frame_id="+window.currUnifiedFrameId : "/pl/entries/vertical-relations")' class="nav-link cursor-pointer">{% trans "Relacie poziome" %}</a></li> diff --git a/freelus/views.py b/freelus/views.py index 1a9544f..820d48e 100644 --- a/freelus/views.py +++ b/freelus/views.py @@ -87,6 +87,8 @@ def create_new_slowal_frame(request): frame = Frame(opinion=FrameOpinion.objects.get(key='unk'), in_building=True) frame.save() + Assignment.assign(user=request.user, subject=frame) + entry = Entry.objects.get(pk=entry_id) for lu_id in lu_ids: lu = LexicalUnit.objects.get(pk=lu_id) diff --git a/frontend/src/components/unification/free_lu/FreeLuEdit.vue b/frontend/src/components/unification/free_lu/FreeLuEdit.vue index 0135b6b..ff6da8d 100644 --- a/frontend/src/components/unification/free_lu/FreeLuEdit.vue +++ b/frontend/src/components/unification/free_lu/FreeLuEdit.vue @@ -63,6 +63,9 @@ }, }, methods: { + isSuperLeksykograf() { + return has_permission("users.view_assignment"); + }, hideLexicalUnits() { this.lexicalUnitsVisible = false; }, @@ -357,7 +360,7 @@ example_sources_display += "</select>" return '<div class="attach-examples-table-wrapper-scroll-y attach-examples-custom-scrollbar"><table id="attach-examples" class="table table-bordered table-striped mb-0"><thead><tr class="font-weight-bold"><th>Zdanie</th><th>Źródło</th><th>Opinia</th></tr></thead>' + - '<tr><td><input type="text" name="sentence"/></td><td>'+example_sources_display+'</td><td>'+example_opinions_display+'</td></tr></table></div>'; + '<tr><td><input size="100" type="text" name="sentence"/></td><td>'+example_sources_display+'</td><td>'+example_opinions_display+'</td></tr></table></div>'; }.bind(this); const attach_examples_popup = { @@ -718,7 +721,7 @@ </td> </tr> <tr style="background-color: white;"> - <td id="modify-frame" class="table-button-menu-td" @click="change_frame_status_to_building()" + <td v-if="isSuperLeksykograf()" id="modify-frame" class="table-button-menu-td" @click="change_frame_status_to_building()" style="padding: 10px 15px 10px 15px; color: #000000;">{{'Modyfikuj ramę'}} </td> <td id="change-role" class="table-button-menu-td" diff --git a/frontend/src/components/unification/free_lu/FreeLusList.vue b/frontend/src/components/unification/free_lu/FreeLusList.vue index 39193e4..03e8d11 100644 --- a/frontend/src/components/unification/free_lu/FreeLusList.vue +++ b/frontend/src/components/unification/free_lu/FreeLusList.vue @@ -40,7 +40,7 @@ </script> <template> - <label class="mt-2 position-absolute" style="z-index: 2"><input type="checkbox" v-model="show_all" /> {{ !show_all ? gettext('Wszystkie') : gettext('Tylko luźne') }}</label> + <label class="mt-2 position-absolute" style="z-index: 2"><input type="checkbox" v-model="show_all" /> {{ !show_all ? gettext('Wszystkie') : canViewAssignment ? gettext('Tylko luźne') : gettext('Tylko moje') }}</label> <table ref="framestable" class="table table-sm table-hover text-dark"> <thead> <tr> -- GitLab