diff --git a/entries/static/entries/js/components/LexicalUnitDisplay.js b/entries/static/entries/js/components/LexicalUnitDisplay.js index d2a3b9fa35ef1b2ab1c724478a10efab7deaab9d..fe96091aea7f2d306eb04820ef68a4b0b789c4ff 100644 --- a/entries/static/entries/js/components/LexicalUnitDisplay.js +++ b/entries/static/entries/js/components/LexicalUnitDisplay.js @@ -115,7 +115,7 @@ export default { </a> <a class="btn btn-sm btn-outline-dark mr-2" - v-if="frame?.status === 'B' && hasPermission('semantics.manage_invalid_lexical_units')" + v-if="(frame?.status === 'B' || frame?.status === 'Z') && hasPermission('semantics.manage_invalid_lexical_units')" @click="confirmInvalid" > {{ gettext('Potwierdź') }} diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js index 2d1c1bf0431385cab139c5f02db517e7c1ea0e08..801287e271da9f85612809ee608a29557e153a63 100644 --- a/entries/static/entries/js/components/LexicalUnitEdit.js +++ b/entries/static/entries/js/components/LexicalUnitEdit.js @@ -621,27 +621,23 @@ Object.assign(LexicalUnitEdit, { }); } }, + isSuperLeksykograf() { + return has_permission("users.view_assignment"); + }, isFrameVerified(frame) { - const isSuperLeksykograf = has_permission("users.view_assignment"); + const isSuperLeksykograf = this.isSuperLeksykograf(); return (!isSuperLeksykograf && frame.status === 'G') || (isSuperLeksykograf && frame.status === 'S') }, - change_slowal_frame_status() { + select_slowal_frame_req(to_invoke) { if(this.active_slowal_frame) { + to_invoke(); + } else { + alert(gettext("Wybierz ramę, dla której chcesz zmienić status.")); + } + }, + change_slowal_frame_status(status) { + this.select_slowal_frame_req(() => { let frame = this.active_slowal_frame; - const isSuperLeksykograf = has_permission("users.view_assignment"); - let status = null; - if (!isSuperLeksykograf && frame.status === 'G') { - //przywracamy O - status = 'O'; - } else if (!isSuperLeksykograf && frame.status === 'O') { - //ustawiany na Gotowe - status = 'G'; - } else if (isSuperLeksykograf && frame.status === 'S') { - //ustawiany Sprawdzone - status = 'G'; - } else { - status = 'S'; - } var data = { 'unified_frame_id': this.unified_frame.id, @@ -662,12 +658,34 @@ Object.assign(LexicalUnitEdit, { show_error(errorType + ' (' + errorMessage + ')'); } }); - } else { - alert(gettext("Wybierz ramę, dla której chcesz zmienić status.")); - } + }); + }, + slowal_frame_ready_rollback(status) { + this.select_slowal_frame_req(() => { + let frame = this.active_slowal_frame; + const isSuperLeksykograf = this.isSuperLeksykograf(); + let status = null; + if (!isSuperLeksykograf && frame.status === 'G') { + //przywracamy O + status = 'O'; + } else if (!isSuperLeksykograf && frame.status === 'O') { + //ustawiany na Gotowe + status = 'G'; + } else if (isSuperLeksykograf && frame.status === 'S') { + //ustawiany Sprawdzone + status = 'G'; + } else { + status = 'S'; + } + + this.change_slowal_frame_status(status); + }); + }, + isFrameVisible(status) { + return (status != 'B' && status != 'Z') || this.isSuperLeksykograf(); }, changeStatusButtonTitleToDefault() { - const isSuperLeksykograf = has_permission("users.view_assignment"); + const isSuperLeksykograf = this.isSuperLeksykograf(); this.statusButtonTitle = isSuperLeksykograf ? 'Sprawdź' : 'Gotowe'; }, slowalFrameSelected(frame) { @@ -893,11 +911,14 @@ Object.assign(LexicalUnitEdit, { <tr class="preferences py-0 px-0 border-top border-left border-secondary" v-for='lexical_unit in lexical_units' > - <td class="argument py-2 px-1 border-top border-left border-secondary">{{ lexical_unit.str }}</td> - <td class="argument py-2 px-1 border-top border-left border-secondary"> - <img v-bind:src="img_prefix + 'entries/img/' +lexical_unit.opinion_key + '.svg'" width="12" height="12" v-bind:alt="lexical_unit.opinion"> - {{ lexical_unit.opinion }} - </td> + <template v-if="isFrameVisible(lexical_unit.frame_status)"> + <td class="argument py-2 px-1 border-top border-left border-secondary">{{ lexical_unit.str }}</td> + <td class="argument py-2 px-1 border-top border-left border-secondary"> + <img v-bind:src="img_prefix + 'entries/img/' +lexical_unit.opinion_key + '.svg'" width="12" height="12" v-bind:alt="lexical_unit.opinion"> + {{ lexical_unit.opinion }} + </td> + <td class="argument py-2 px-1 border-top border-left border-secondary">[{{ lexical_unit.frame_status }}]</td> + </template> </tr> </tbody> </table> @@ -907,18 +928,18 @@ Object.assign(LexicalUnitEdit, { <div id="semantics-slowal-frames-pane" class="col w-100 p-0 overflow-auto"> <table v-if="!readOnly && unified_frame.id" class="table-button-menu sticky-top" cellspacing="1"> <tr style="background-color: white;"> - <td id="wrong-frame" style="padding: 10px 15px 10px 15px; color: #000000;">Błędna</td> + <td id="wrong-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="change_slowal_frame_status('Z')">Błędna</td> <td style="padding: 10px 15px 10px 15px; color: #000000;" > Rozdziel </td> <td id="hide-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="changeShowVerifiedFrames(false)">Ukryj</td> - <td id="ready-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="change_slowal_frame_status">{{ statusButtonTitle }}</td> + <td id="ready-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="slowal_frame_ready_rollback">{{ statusButtonTitle }}</td> <td id="filter-slowal-frames" style="padding: 10px 15px 10px 15px; color: #000000;">Filtruj</td> </tr> <tr style="background-color: white;"> - <td id="inccorect-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;"> + <td id="inccorect-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @click="change_slowal_frame_status('B')"> Niepasująca </td> <td id="move-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;" @@ -938,7 +959,7 @@ Object.assign(LexicalUnitEdit, { <div v-for="frame in frames" :key="frame.id"> <table class="table m-0 table-borderless border border-secondary text-dark" - v-if="!isFrameVerified(frame) || showVerifiedFrames" + v-if="(!isFrameVerified(frame) || showVerifiedFrames) && isFrameVisible(frame.status)" > <tbody> <tr> diff --git a/entries/static/entries/js/unification.js b/entries/static/entries/js/unification.js index 905dfa0bc3376eb8c4cdaf202adf750c925229fe..cf36939c99e8e6c0a491a0585f284d8fb74a26fd 100644 --- a/entries/static/entries/js/unification.js +++ b/entries/static/entries/js/unification.js @@ -106,6 +106,7 @@ function frames2lexical_units(frames) { var lexical_unit = frame.lexical_units[j]; lexical_unit.opinion = frame.opinion; lexical_unit.opinion_key = frame.opinion_key; + lexical_unit.frame_status = frame.status; lexical_units.push(lexical_unit); } } diff --git a/users/management/commands/create_groups_and_permissions.py b/users/management/commands/create_groups_and_permissions.py index b05773230c9550175225e71490a9f4c67b77c9d2..437bac3a98cc66c0d3a17ed1a5bd3c47cc788b05 100644 --- a/users/management/commands/create_groups_and_permissions.py +++ b/users/management/commands/create_groups_and_permissions.py @@ -27,6 +27,7 @@ class Command(BaseCommand): self._get_permission(User, 'delete_user'), self._get_permission(Assignment, 'view_assignment'), self._get_permission(Note, 'view_all_notes'), + self._get_permission(Frame, 'manage_invalid_lexical_units'), ) lexicographs, __ = Group.objects.get_or_create(name='Leksykografowie') lexicographs.permissions.add(