diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js index 801287e271da9f85612809ee608a29557e153a63..16a36422623d59e22e9b8c7b4bf7bbce0995bb00 100644 --- a/entries/static/entries/js/components/LexicalUnitEdit.js +++ b/entries/static/entries/js/components/LexicalUnitEdit.js @@ -159,7 +159,9 @@ Object.assign(LexicalUnitEdit, { this.changeStatusButtonTitleToDefault(); - this.setup_notes_unified_frame(); + if(!this.active_slowal_frame) { + this.setup_notes_unified_frame(); + } }.bind(this), error: function (request, errorType, errorMessage) { show_error(errorType + ' (' + errorMessage + ')'); @@ -176,6 +178,10 @@ Object.assign(LexicalUnitEdit, { setup_notes_slowal_frame () { setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id, 'semantics.Frame', this.setup_notes_slowal_frame); }, + setup_notes_slowal_frame_with_title_and_body (title, body) { + this.right_pane_tab = 'notes'; + setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id, 'semantics.Frame', this.setup_notes_slowal_frame, title, body); + }, unifiedFrameArgumentSelected(argument) { if (this.active_unified_frame_argument === argument) { this.active_unified_frame_argument = null; @@ -639,6 +645,14 @@ Object.assign(LexicalUnitEdit, { this.select_slowal_frame_req(() => { let frame = this.active_slowal_frame; + if(status === 'B') { + this.setup_notes_slowal_frame_with_title_and_body("Niedopasowana jednostka (identyfikator jednostki)", "Do zatwierdzenia uznanie ramy Walentego jednostek (lista jednostek)" + + "za niedopasowana do zunifikowanej ramy (identyfikator) przez (Leksykograf)."); + } else if(status === 'Z') { + this.setup_notes_slowal_frame_with_title_and_body("Błędna jednostka (identyfikator jednostki)", "Do zatwierdzenia uznanie ramy Walentego jednostek (lista jednostek)" + + "za niedopasowana do zunifikowanej ramy (identyfikator) przez (Leksykograf)."); + } + var data = { 'unified_frame_id': this.unified_frame.id, 'slowal_frame_id': frame.id, @@ -701,6 +715,13 @@ Object.assign(LexicalUnitEdit, { } } }, + isSelectedFrame(frame) { + if(this.active_slowal_frame) { + return frame.id === this.active_slowal_frame.id; + } else { + return false; + } + }, extract_frames_to_new_frame() { var existingSelect = function () { @@ -967,7 +988,7 @@ Object.assign(LexicalUnitEdit, { <div v-html="slowal_frame_html(frame)" @click="slowalFrameSelected(frame)" - :class="frame === active_slowal_frame ? 'active-frame' : ''" + :class="isSelectedFrame(frame) ? 'active-frame' : ''" ></div> </th> <th scope="row"> diff --git a/entries/static/entries/js/unification_entries_list.js b/entries/static/entries/js/unification_entries_list.js index 5847bfac5167fe39eb4294831ac4839f2c8c58d0..72525ff922a489e3b49f16df5b6c304b1b59a7f5 100644 --- a/entries/static/entries/js/unification_entries_list.js +++ b/entries/static/entries/js/unification_entries_list.js @@ -78,31 +78,48 @@ function setup_lexical_units_table(drilldown, lexical_units, can_see_assignees, }); } -function setup_notes($container, $template, pk, model, refreshFunction) { +function show_notes_form($container, pk, model, refreshFunction, title, body) { + $('.note-form', $container).html($('#note-form-template > div', $container).clone()); + $('.hide-note-form', $container).click(function () { + $('.note-form', $container).html(''); + }); + $('.add-note', $container).click(function () { + $.ajax({ + type: 'post', + url: $('#note-form-template').data('url').replace('MODEL', model).replace('PK', pk), + dataType: 'json', + data: { + title: $('.note-form input[name=title]').val(), + note: $('.note-form textarea[name=note]').val() + }, + timeout: 5000, + success: function (response) { + refreshFunction(); + }, + error: function () { + alert(gettext('Nie udało się dodać notatki.')); + } + }); + }); + if(title) { + const input = $('#title', $container); + input[1].defaultValue = title; + } + if(body) { + const input = $('#note', $container); + input[1].defaultValue = body; + } +} + +function setup_notes($container, $template, pk, model, refreshFunction, title, body) { $container.html($template.children().clone()); $('.show-note-form', $container).click(function () { - $('.note-form', $container).html($('#note-form-template > div', $container).clone()); - $('.hide-note-form', $container).click(function () { $('.note-form', $container).html(''); }); - $('.add-note', $container).click(function () { - $.ajax({ - type : 'post', - url : $('#note-form-template').data('url').replace('MODEL', model).replace('PK', pk), - dataType : 'json', - data : { - title: $('.note-form input[name=title]').val(), - note: $('.note-form textarea[name=note]').val() - }, - timeout : 5000, - success : function (response) { - refreshFunction(); - }, - error : function () { - alert(gettext('Nie udało się dodać notatki.')); - } - }); - }); + show_notes_form($container, pk, model, refreshFunction, title, body); return false }); + if(title || body) { + show_notes_form($container, pk, model, refreshFunction, title, body); + } $.ajax({ type: 'get', url: $('.notes-table').data('url').replace('MODEL', model).replace('PK', pk), diff --git a/users/templates/notes.html b/users/templates/notes.html index d9aa102edf93a53f6d1342393dec8f48f212dfc7..25240c81039341feb3862670dabf624427492a38 100644 --- a/users/templates/notes.html +++ b/users/templates/notes.html @@ -9,8 +9,8 @@ </div> <div class="d-flex"> <div class="flex-grow-1 mr-3"> - <input name="title" class="form-control mb-2" placeholder="{% trans 'Tytuł notatki' %}" /> - <textarea name="note" class="form-control" placeholder="{% trans 'Treść notatki' %}"></textarea> + <input id="title" name="title" class="form-control mb-2" placeholder="{% trans 'Tytuł notatki' %}" /> + <textarea id="note" name="note" class="form-control" placeholder="{% trans 'Treść notatki' %}"></textarea> </div> <a href="#" class="btn btn-sm btn-outline-dark ml-auto align-self-end add-note">{% trans 'Dodaj' %}</a> </div>