diff --git a/entries/static/entries/js/components/LexicalUnitDisplay.js b/entries/static/entries/js/components/LexicalUnitDisplay.js index 1a9e2162088080701a3bcc41321509cc0eec2e13..50b503e45303f0bd29a6eb7a3506a175f4dd2b5b 100644 --- a/entries/static/entries/js/components/LexicalUnitDisplay.js +++ b/entries/static/entries/js/components/LexicalUnitDisplay.js @@ -48,16 +48,23 @@ export default { }, isLeksykograf() { return !has_permission("users.view_assignment"); + }, + setup_notes () { + setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes); + }, + setup () { + $('#lexical-unit-notes').html(''); + get_entry(this.entryId, false, this.lexicalUnitId).then(entry => { + this.frame = entry.frames[0]; + this.unifiedFrame = entry.unified_frame; + setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, 'meanings.LexicalUnit', this.setup_notes); + }); } }, - created () { - $('#lexical-unit-notes').html(''); - get_entry(this.entryId, false, this.lexicalUnitId).then(entry => { - this.frame = entry.frames[0]; - this.unifiedFrame = entry.unified_frame; - setup_notes($('#lexical-unit-notes'), $('#lexical-unit-notes-template'), this.lexicalUnitId, this.entryId); - }); - }, + + // created () { + // this.setup(); + // }, mounted () { Split(['#semantics-frames-pane', '#semantics-schemata-pane'], { sizes: [40, 60], @@ -69,6 +76,7 @@ export default { } }, }); + this.setup(); }, template: ` <div class="col h-100 px-1 pt-0 pb-2 overflow-auto" id="semantics-frames-pane"> diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js index 83f5f383aad485dccd1b2e855035e59754fb1cd0..b955f7a4d0f1dfb30d8a2f7b3844ef6e11672aa6 100644 --- a/entries/static/entries/js/components/LexicalUnitEdit.js +++ b/entries/static/entries/js/components/LexicalUnitEdit.js @@ -90,7 +90,6 @@ Object.assign(LexicalUnitEdit, { emits: ['goToDisplay', 'refresh', 'swapFrames', 'changePreviewToEdit'], watch: { forceRefresh(newVal, oldVal) { - console.log("forceRefresh exec") this.loadFrame(); } }, @@ -153,6 +152,8 @@ Object.assign(LexicalUnitEdit, { update_last_visited(response.last_visited); this.changeStatusButtonTitleToDefault(); + + this.setup_notes_unified_frame(); }.bind(this), error: function (request, errorType, errorMessage) { show_error(errorType + ' (' + errorMessage + ')'); @@ -163,6 +164,12 @@ Object.assign(LexicalUnitEdit, { console.log(error); } }, + setup_notes_unified_frame () { + setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.unified_frame.id, 'unifier.UnifiedFrame', this.setup_notes_unified_frame); + }, + setup_notes_slowal_frame () { + setup_notes($('#notes-component'), $('#lexical-unit-notes-template'), this.active_slowal_frame.id, 'semantics.Frame', this.setup_notes_slowal_frame); + }, unifiedFrameArgumentSelected(argument) { if (this.active_unified_frame_argument === argument) { this.active_unified_frame_argument = null; @@ -598,9 +605,11 @@ Object.assign(LexicalUnitEdit, { slowalFrameSelected(frame) { if (this.active_slowal_frame === frame) { this.active_slowal_frame = null; + this.setup_notes_unified_frame(); this.changeStatusButtonTitleToDefault(); } else { this.active_slowal_frame = frame; + this.setup_notes_slowal_frame() if(this.isFrameVerified(frame)) { this.statusButtonTitle = 'Przywróć'; } @@ -695,16 +704,18 @@ Object.assign(LexicalUnitEdit, { }, mounted() { this.changeStatusButtonTitleToDefault(); - !this.readOnly && Split(['#semantics-frames-pane', '#semantics-schemata-pane'], { - sizes: [40, 60], - minSize: 400, - gutterSize: 4, - elementStyle: (dimension, size, gutterSize) => { - return { - 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' - } - }, - }); + if(!this.readOnly) { + Split(['#semantics-frames-pane', '#semantics-schemata-pane'], { + sizes: [40, 60], + minSize: 400, + gutterSize: 4, + elementStyle: (dimension, size, gutterSize) => { + return { + 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' + } + }, + }); + } this.loadFrame(); }, template: ` @@ -901,7 +912,7 @@ Object.assign(LexicalUnitEdit, { @change-preview-to-edit="swapUnifiedFrames" :forceRefresh="internalForceRefresh" /> </div> - <div v-if="right_pane_tab === 'notes'">notateczki</div> + <div :class="right_pane_tab !== 'notes' && 'd-none'" id="notes-component"></div> </div> ` }); diff --git a/entries/static/entries/js/unification_entries_list.js b/entries/static/entries/js/unification_entries_list.js index 4589fba051c857c19875ed7cc10ba286a0608758..109a6005dcec9e9a71f031f5937e5beb513873ed 100644 --- a/entries/static/entries/js/unification_entries_list.js +++ b/entries/static/entries/js/unification_entries_list.js @@ -77,7 +77,7 @@ function setup_lexical_units_table(drilldown, lexical_units, can_see_assignees) }); } -function setup_notes($container, $template, lexical_unit_pk, entry_pk) { +function setup_notes($container, $template, pk, model, refreshFunction) { $container.html($template.children().clone()); $('.show-note-form', $container).click(function () { $('.note-form', $container).html($('#note-form-template > div', $container).clone()); @@ -85,12 +85,12 @@ function setup_notes($container, $template, lexical_unit_pk, entry_pk) { $('.add-note', $container).click(function () { $.ajax({ type : 'post', - url : $('#note-form-template').data('url').replace('MODEL', 'meanings.LexicalUnit').replace('PK', lexical_unit_pk), + url : $('#note-form-template').data('url').replace('MODEL', model).replace('PK', pk), dataType : 'json', data : { note: $('.note-form textarea[name=note]').val() }, timeout : 5000, success : function (response) { - window.unificationApp.refresh(); + refreshFunction(); }, error : function () { alert(gettext('Nie udało się dodać notatki.')); @@ -101,7 +101,7 @@ function setup_notes($container, $template, lexical_unit_pk, entry_pk) { }); $.ajax({ type: 'get', - url: $('.notes-table').data('url').replace('MODEL', 'meanings.LexicalUnit').replace('PK', lexical_unit_pk), + url: $('.notes-table').data('url').replace('MODEL', model).replace('PK', pk), success: function (data) { data.notes.map(function (note) { $('.notes-table tbody', $container).append(`<tr><td>${note.note}</td><td>${note.owner_label}</td></tr>`);