From e8060f671e622bbb8166054a382b4613c2ef1461 Mon Sep 17 00:00:00 2001 From: dcz <dcz@ipipan.waw.pl> Date: Mon, 30 Oct 2023 15:48:23 +0100 Subject: [PATCH] Free lus module - final stage. --- entries/static/entries/css/entries.css | 14 + .../static/entries/css/unification_frames.css | 4 + entries/static/entries/js/entries.js | 10 +- entries/static/entries/js/free_lus_list.js | 3 +- entries/views.py | 4 +- freelus/urls.py | 4 + freelus/views.py | 82 +- .../components/unification/free_lu/FreeLu.vue | 85 +- .../unification/free_lu/FreeLuEdit.vue | 1261 +++++++++-------- .../unification/free_lu/FreeLuElement.vue | 188 --- .../unification/free_lu/FreeLuPreview.vue | 64 - .../unification/free_lu/FreeLuRightPane.vue | 66 - .../unification/free_lu/FreeLusList.vue | 104 +- .../frame-components/MeaningComponent.vue | 2 +- .../SemanticsSchemataComponent.vue | 50 +- shellvalier/settings.py | 1 + 16 files changed, 908 insertions(+), 1034 deletions(-) delete mode 100644 frontend/src/components/unification/free_lu/FreeLuElement.vue delete mode 100644 frontend/src/components/unification/free_lu/FreeLuPreview.vue delete mode 100644 frontend/src/components/unification/free_lu/FreeLuRightPane.vue diff --git a/entries/static/entries/css/entries.css b/entries/static/entries/css/entries.css index 66f9917..55067e2 100644 --- a/entries/static/entries/css/entries.css +++ b/entries/static/entries/css/entries.css @@ -347,3 +347,17 @@ legend { display: none; } } + + +.attach-examples-custom-scrollbar { + position: relative; + height: 70%; + overflow: auto; +} +.attach-examples-table-wrapper-scroll-y { + display: block; +} + +#attach-examples tr td { + padding: 2px; +} diff --git a/entries/static/entries/css/unification_frames.css b/entries/static/entries/css/unification_frames.css index bfe6d5f..b4efb72 100644 --- a/entries/static/entries/css/unification_frames.css +++ b/entries/static/entries/css/unification_frames.css @@ -23,6 +23,10 @@ table.table-button-menu { font-weight: bold; } +#schemata-positions-table .active { + background-color: #dee1e4; +} + #unified-frame .argument.active { background-color: #dee1e4; } diff --git a/entries/static/entries/js/entries.js b/entries/static/entries/js/entries.js index 51c9478..25ead31 100644 --- a/entries/static/entries/js/entries.js +++ b/entries/static/entries/js/entries.js @@ -1009,10 +1009,12 @@ function setup_datatable(options) { $(row).addClass('hierarchy_not_exists'); } - for (let i in options.columns) { - const column = options.columns[i]; - if (column.data == 'status') { - $(cells)[i].innerHTML = "<img src='/static/entries/img_status/"+data['status']+"_status.svg' width='10' height='10'> "+data['status']; + if(!options.disable_display_graphical_status) { + for (let i in options.columns) { + const column = options.columns[i]; + if (column.data == 'status') { + $(cells)[i].innerHTML = "<img src='/static/entries/img_status/" + data['status'] + "_status.svg' width='10' height='10'> " + data['status']; + } } } }, diff --git a/entries/static/entries/js/free_lus_list.js b/entries/static/entries/js/free_lus_list.js index 4b9fbd6..49c0aa3 100644 --- a/entries/static/entries/js/free_lus_list.js +++ b/entries/static/entries/js/free_lus_list.js @@ -13,7 +13,8 @@ function setup_free_lus_list(options) { ], hidden_columns: [2], selectEntryId: options.selectEntryId, - setup_hierarchy_marking: false + setup_hierarchy_marking: false, + disable_display_graphical_status: true, }); datatable.on('click', 'tr.entry', function () { const data = datatable.row(this).data(); diff --git a/entries/views.py b/entries/views.py index 40da2f3..e569546 100644 --- a/entries/views.py +++ b/entries/views.py @@ -446,8 +446,6 @@ def get_entries(request): if without_frames: entries = entries.filter(Exists(LexicalUnit.objects.filter(base=OuterRef('name'), frames__isnull=True))) - # entries = entries.filter(~Exists(LexicalUnit.objects.filter( - # ~Exists(Frame.objects.filter(frames=OuterRef('pk')))))) total = entries.count() if scroller_params['filter']: @@ -934,7 +932,7 @@ def get_entry(request): frame_objects = get_filtered_objects(local_frame_filter_form, frame_objects) frames = [frame2dict(frame, entry.lexical_units.all()) for frame in filter(lambda frame: not frame.in_building, frame_objects.all())] frames_in_building_process = [frame2dict(frame, entry.lexical_units.all()) for frame in filter(lambda frame: frame.in_building, frame_objects.all())] - alternations, realisation_phrases, realisation_descriptions = get_alternations(all_schema_objects, filter(lambda frame: not frame.in_building, frame_objects.all())) + alternations, realisation_phrases, realisation_descriptions = get_alternations(all_schema_objects, frame_objects) examples = get_examples(entry) unified_frame = None if lexical_unit and (unified_frame := UnifiedFrame.objects.all().for_lexical_unit(lexical_unit).first()): diff --git a/freelus/urls.py b/freelus/urls.py index 9291677..6b44695 100644 --- a/freelus/urls.py +++ b/freelus/urls.py @@ -8,5 +8,9 @@ urlpatterns = [ path('create_new_slowal_frame/', views.create_new_slowal_frame, name='create_new_slowal_frame'), path('add_argument_to_frame/', views.add_argument_to_frame, name='add_argument_to_frame'), path('change_role/', views.change_role, name='change_role'), + path('attach_examples_to_frame/', views.attach_examples_to_frame, name='attach_examples_to_frame'), + path('attach_schema_to_argument/', views.attach_schema_to_argument, name='attach_schema_to_argument'), + path('delete_schema_to_argument_connection/', views.delete_schema_to_argument_connection, name='delete_schema_to_argument_connection'), + path('finish_frame_processing/', views.finish_frame_processing, name='finish_frame_processing'), ] diff --git a/freelus/views.py b/freelus/views.py index 3c929bb..fa482e2 100644 --- a/freelus/views.py +++ b/freelus/views.py @@ -3,7 +3,8 @@ from django.db import transaction from django.http import JsonResponse from common.decorators import ajax_required -from connections.models import Entry, Status +from connections.models import Entry, Status, ExampleConnection, SchemaHook, ArgumentConnection, RealisationDescription +from examples.models import Example from meanings.models import LexicalUnit from semantics.models import Frame, FrameOpinion, Argument, ArgumentRole, SemanticRole, RoleAttribute, RoleSubAttribute, \ RoleType @@ -95,4 +96,83 @@ def change_role_base(frame_argument, request): frame_argument.role_type = RoleType.objects.get(type=role_type) +@ajax_required +@transaction.atomic +def attach_examples_to_frame(request): + if request.method == 'POST': + frame_id = request.POST['frame_id'] + argument_id = request.POST['argument_id'] + example_ids = json.loads(request.POST['example_ids']) + + argument = Argument.objects.get(id=argument_id) + frame = Frame.objects.get(id=frame_id) + + lexical_units = frame.lexical_units.all() + + for example_id in example_ids: + for lexical_unit in lexical_units: + example_conn = ExampleConnection(example_id=example_id, lexical_unit=lexical_unit) + example_conn.save() + example_conn.arguments.add(argument) + example_conn.save() + + return JsonResponse({}) + + +@ajax_required +@transaction.atomic +def attach_schema_to_argument(request): + if request.method == 'POST': + frame_id = request.POST['frame_id'] + argument_id = request.POST['argument_id'] + schema_id = request.POST['schema_id'] + schema_position_id = request.POST['schema_position_id'] + + argument = Argument.objects.get(id=argument_id) + + schema_hooks = SchemaHook.objects.filter(schema_id=schema_id, position_id=schema_position_id) + if len(schema_hooks) > 0: + schema_hook = schema_hooks[0] + argument_connection, xxx = ArgumentConnection.objects.get_or_create(argument=argument, defaults={'argument': argument}) + argument_connection.save() + argument_connection.schema_connections.add(schema_hook) + argument_connection.save() + + realisation_description = RealisationDescription.objects.get_or_create(frame_id=frame_id, schema_id=schema_id, + defaults={'alternation': 1, 'description': ''}) + + return JsonResponse({}) + + +@ajax_required +@transaction.atomic +def delete_schema_to_argument_connection(request): + if request.method == 'POST': + frame_id = request.POST['frame_id'] + argument_id = request.POST['argument_id'] + schema_id = request.POST['schema_id'] + schema_position_id = request.POST['schema_position_id'] + + argument = Argument.objects.get(id=argument_id) + + schema_hooks = SchemaHook.objects.filter(schema_id=schema_id, position=schema_position_id) + + argument_connection = ArgumentConnection.objects.get(argument=argument) + argument_connection.schema_connections.remove(schema_hooks[0]) + argument_connection.save() + + return JsonResponse({}) + + +@ajax_required +@transaction.atomic +def finish_frame_processing(request): + if request.method == 'POST': + frame_id = request.POST['frame_id'] + + frame = Frame.objects.get(id=frame_id) + frame.in_building = False + frame.save() + + return JsonResponse({}) diff --git a/frontend/src/components/unification/free_lu/FreeLu.vue b/frontend/src/components/unification/free_lu/FreeLu.vue index e433502..1303f3b 100644 --- a/frontend/src/components/unification/free_lu/FreeLu.vue +++ b/frontend/src/components/unification/free_lu/FreeLu.vue @@ -1,55 +1,50 @@ <script> -import FreeLuEdit from "./FreeLuEdit.vue"; -import FreeLusList from "./FreeLusList.vue"; + import FreeLuEdit from "./FreeLuEdit.vue"; + import FreeLusList from "./FreeLusList.vue"; -export default { - data () { - return { - entryId: null, - gettext: window.gettext, + export default { + data() { + return { + entryId: null, + gettext: window.gettext, + }; + }, + components: {FreeLuEdit, FreeLusList}, + methods: { + entrySelected(entryId) { + this.entryId = entryId; + }, + }, + mounted() { + $('#entries-list').length && Split(['#entries-list', '#entry-display'], { + sizes: [20, 80], + gutterSize: 4, + minSize: 10, + elementStyle: (dimension, size, gutterSize) => { + return { + 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' + } + }, + }); + }, }; - }, - components: {FreeLuEdit, FreeLusList}, - methods: { - entrySelected (entryId) { - this.entryId = entryId; - console.log("entrySelected: " + entryId); - }, - refreshEntriesList() { - } - }, - mounted () { - $('#entries-list').length && Split(['#entries-list', '#entry-display'], { - sizes: [20, 80], - gutterSize: 4, - minSize: 10, - elementStyle: (dimension, size, gutterSize) => { - return { - 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' - } - }, - }); - }, -}; </script> <template> - <div id="entries-list" class="col h-100 w-100 pr-0 overflow-hidden"> - <div id="entries-list-div" class="col p-0 h-100 w-100 overflow-hidden"> - <free-lus-list @entry-selected="entrySelected"/> + <div id="entries-list" class="col h-100 w-100 pr-0 overflow-hidden"> + <div id="entries-list-div" class="col p-0 h-100 w-100 overflow-hidden"> + <free-lus-list @entry-selected="entrySelected"/> + </div> </div> - </div> - <div id="entry-display" class="col h-100 p-0 overflow-hidden"> - - <div v-if="entryId" :key="entryId" class="row h-100 m-0 p-0 overflow-auto" id="semantics-top-pane"> - <free-lu-edit - ref="freeLusEdit" - v-if="entryId" - :key="entryId" - :entryId="entryId" - @refresh-entries-list="refreshEntriesList" - /> + <div id="entry-display" class="col h-100 p-0 overflow-hidden"> + <div v-if="entryId" :key="entryId" class="row h-100 m-0 p-0 overflow-auto" id="semantics-top-pane"> + <free-lu-edit + ref="freeLusEdit" + v-if="entryId" + :key="entryId" + :entryId="entryId" + /> + </div> </div> - </div> </template> diff --git a/frontend/src/components/unification/free_lu/FreeLuEdit.vue b/frontend/src/components/unification/free_lu/FreeLuEdit.vue index 1f94391..9f563bb 100644 --- a/frontend/src/components/unification/free_lu/FreeLuEdit.vue +++ b/frontend/src/components/unification/free_lu/FreeLuEdit.vue @@ -1,644 +1,713 @@ <script> -import InfoTooltip from "../../shared/InfoTooltip.vue"; -import Spinner from "../../shared/Spinner.vue"; -import ExamplesComponent from "../shared/frame-components/ExamplesComponent.vue"; -import SlowalFrameComponent from "../shared/frame-components/SlowalFrameComponent.vue"; -import SemanticsSchemataComponent from "../shared/frame-components/SemanticsSchemataComponent.vue"; -import MeaningComponent from "../shared/frame-components/MeaningComponent.vue"; -import SelectionalPreference from "../Unification/SelectionalPreference.js"; -import FreeLuPreview from "./FreeLuPreview.vue"; -import FreeLuElement from "./FreeLuElement.vue"; -import {frames2lexical_units, send_post_request} from "../shared/utils"; + import InfoTooltip from "../../shared/InfoTooltip.vue"; + import Spinner from "../../shared/Spinner.vue"; + import ExamplesComponent from "../shared/frame-components/ExamplesComponent.vue"; + import SlowalFrameComponent from "../shared/frame-components/SlowalFrameComponent.vue"; + import SemanticsSchemataComponent from "../shared/frame-components/SemanticsSchemataComponent.vue"; + import MeaningComponent from "../shared/frame-components/MeaningComponent.vue"; + import SelectionalPreference from "../Unification/SelectionalPreference.js"; + import {frames2lexical_units, send_post_request} from "../shared/utils"; -let FreeLuEdit = { - components: {FreeLuElement, FreeLuPreview} -}; + export default { + props: { + entryId: Number, + }, + data() { + return { + gettext: window.gettext, + lexical_units: [], + free_lexical_units: [], + frame_in_progress: null, + frame_in_progress_arguments: null, + img_prefix: window.STATIC_URL, + frames: [], + right_pane_tabs: [ + {id: 'schemata', label: gettext('Schematy')}, + ], + active_slowal_frame: null, + subentries: null, + alternations: null, + realisation_phrases: null, + realisation_descriptions: null, + examples: null, + selectedFrameArguments: null, + frame_arguments_or_type: false, + selectedLus: null, + selectedSchemas: null, + selectedExamples: null, + lexicalUnitsVisible: true, + selected_frame_argument_id: null, + selected_schemata_position_id: null, + } + }, + components: { + InfoTooltip, + Spinner, + SlowalFrameComponent, + ExamplesComponent, + SemanticsSchemataComponent, + MeaningComponent + }, + emits: ['frameSelectionChanged'], + watch: { + forceRefresh(newVal, oldVal) { + this.loadFrame(); + } + }, + computed: { + selectionalPreference() { + return new SelectionalPreference(); + }, + }, + methods: { + hideLexicalUnits() { + this.lexicalUnitsVisible = false; + }, + showLexicalUnits() { + this.lexicalUnitsVisible = true; + }, + loadEntry() { + $('#lexical-unit-notes').html(''); -Object.assign(FreeLuEdit, { - props: { - entryId: Number, - }, - data() { - return { - gettext: window.gettext, - FreeLuEdit: FreeLuEdit, - unified_frame: {}, - unified_frame_title: '', - unified_frame_arguments: [], - active_unified_frame_argument: null, - slowal_frames2selecional_preferencies_mapping: {}, - lexical_units: [], - free_lexical_units: [], - frame_in_progress: null, - frame_in_progress_arguments: null, - img_prefix: window.STATIC_URL, - frames: [], - right_pane_tabs: [ - {id: 'schemata', label: gettext('Schematy')}, - ], - right_pane_tab: 'schemata', - currentPreviewedUnifiedFrameId: this.previewedUnifiedFrameId, - internalForceRefresh: this.forceRefresh, - statusButtonTitle: '', - active_slowal_frame: null, - showVerifiedFrames: false, - subentries: null, - alternations: null, - realisation_phrases: null, - realisation_descriptions: null, - examples: null, - selectedFrameArguments: null, - frame_arguments_or_type: false, - selectedLus: null, - selectedSchemas: null, - selectedExamples: null, - hidden_frames: [], - hierarchy_hyponyms: null, - lexicalUnitsVisible: true, - selected_frame_argument_id: null, - } - }, - components: {FreeLuElement, InfoTooltip, Spinner, FreeLuPreview, SlowalFrameComponent, ExamplesComponent, SemanticsSchemataComponent, MeaningComponent}, - emits: ['frameSelectionChanged'], - watch: { - forceRefresh(newVal, oldVal) { - this.loadFrame(); - } - }, - computed: { - selectionalPreference() { - return new SelectionalPreference(); - }, - }, - methods: { - hideLexicalUnits() { - this.lexicalUnitsVisible = false; - }, - showLexicalUnits() { - this.lexicalUnitsVisible = true; - }, - hasWhiteSpace(s) { - return /\s/g.test(s); - }, - loadEntry() { - $('#lexical-unit-notes').html(''); + var data = {'entry': this.entryId, 'no_filters': false, 'lexical_unit_id': this.lexicalUnitId}; + $.ajax({ + type: 'post', + url: '/' + lang + '/entries/get_entry/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { - var data = { 'entry' : this.entryId, 'no_filters' : false, 'lexical_unit_id': this.lexicalUnitId }; - $.ajax({ - type : 'post', - url : '/' + lang + '/entries/get_entry/', - dataType : 'json', - data : data, - timeout : 60000, - success : function(response) { + window.clear_info(); + this.frames = response.frames; + this.unifiedFrame = response.unified_frame; + this.subentries = response.subentries; + this.alternations = response.alternations; + this.realisation_phrases = response.realisation_phrases; + this.realisation_descriptions = response.realisation_descriptions; + this.examples = response.examples; + this.lexical_units = frames2lexical_units(response.frames); + this.free_lexical_units = response.free_lexical_units; + this.frame_in_progress = null; + this.frame_in_progress_arguments = null; + if (response.frames_in_building_process.length > 0) { + this.frame_in_progress = response.frames_in_building_process[0]; + this.frame_in_progress_arguments = response.frames_in_building_process[0]['arguments']; + } - window.clear_info(); - this.frames = response.frames; - this.unifiedFrame = response.unified_frame; - this.subentries = response.subentries; - this.alternations = response.alternations; - this.realisation_phrases = response.realisation_phrases; - this.realisation_descriptions = response.realisation_descriptions; - this.examples = response.examples; - this.lexical_units = frames2lexical_units(response.frames); - this.free_lexical_units = response.free_lexical_units; - if(response.frames_in_building_process.length > 0) { - this.frame_in_progress = response.frames_in_building_process[0]; - this.frame_in_progress_arguments = response.frames_in_building_process[0]['arguments']; - } + window.update_last_visited(response.last_visited); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + } + }); + }, + deselectSlowalFrameSelectedElements() { + this.subentries.forEach(subentry => { + subentry.schemata.forEach(s => { + s.selected = false; + }); + }); + this.frames.forEach(frame => { + frame.lexical_units.forEach(lu => { + lu.selected = false; + }); + frame.arguments.forEach(argument => { + argument.selected = false; + }); + }); + this.examples.forEach(example => { + example.selected = false; + }); + this.selectedLus = []; + this.selectedFrameArguments = []; + this.selectedSchemas = []; + this.selectedExamples = []; + }, + schemataSelected(schemas) { + this.selectedSchemas = schemas; + }, + selectSchemaPositionSelected(selected_schemata_position_id) { + this.selected_schemata_position_id = selected_schemata_position_id; + }, + exampleSelected(selectedExamples) { + this.selectedExamples = selectedExamples; + }, + meaningLuSelected(selectedLus) { + this.selectedLus = selectedLus; + }, + insideFrameSelectionChanged(selectedFrameArguments) { + this.selectedFrameArguments = selectedFrameArguments; + }, + slowalFrameSelected(frame) { + this.deselectSlowalFrameSelectedElements(); + if (this.active_slowal_frame === frame) { + this.active_slowal_frame = null; + } else { + this.active_slowal_frame = frame; + } + }, + create_new_slowal_frame() { + const lusSelect = function () { + return this.free_lexical_units.map(lu => { + return `<label><input type="checkbox" name="lus" value="${lu.pk}" /> ${lu.display}</label><br />`; + }).join(""); + }.bind(this); - window.update_last_visited(response.last_visited); - }.bind(this), - error: function(request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - } - }); - }, - deselectSlowalFrameSelectedElements() { - this.subentries.forEach(subentry => { - subentry.schemata.forEach(s => { - s.selected = false; - }); - }); - this.frames.forEach(frame => { - frame.lexical_units.forEach(lu => { - lu.selected = false; - }); - frame.arguments.forEach(argument => { - argument.selected = false; - }); - }); - this.examples.forEach(example => { - example.selected = false; - }); - this.selectedLus = []; - this.selectedFrameArguments = []; - this.selectedSchemas = []; - this.selectedExamples = []; - }, - schemataSelected(schemas) { - this.selectedSchemas = schemas; - }, - exampleSelected(selectedExamples) { - this.selectedExamples = selectedExamples; - }, - meaningLuSelected(selectedLus) { - this.selectedLus = selectedLus; - }, - insideFrameSelectionChanged(selectedFrameArguments) { - this.selectedFrameArguments = selectedFrameArguments; - }, - slowalFrameSelected(frame) { - this.deselectSlowalFrameSelectedElements(); - if (this.active_slowal_frame === frame) { - this.active_slowal_frame = null; - } else { - this.active_slowal_frame = frame; - } - }, - create_new_slowal_frame() { - const lusSelect = function () { - return this.free_lexical_units.map(lu => { - return `<label><input type="checkbox" name="lus" value="${lu.pk}" /> ${lu.display}</label><br />`; - }).join(""); - }.bind(this); + const extract_frames_to_new_frame_popup = { + state0: { + title: 'Wybierz jednostki leksykalne', + html: lusSelect, + buttons: {Anuluj: 0, Stwórz: 1}, + focus: -1, + submit: function (e, v, m, f) { + if (v == 0) { + e.preventDefault(); + $.prompt.close(); + } + if (v === 1) { + e.preventDefault(); + let lu_ids = normalizeFormData(f.lus); + const data = { + 'lu_ids': JSON.stringify(lu_ids), + 'entry_id': this.entryId + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/create_new_slowal_frame/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + show_info('Nowa rama zostaÅ‚a stworzona.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } + }.bind(this) + } + } + $.prompt(extract_frames_to_new_frame_popup); + }, + attach_examples() { + if (this.frame_in_progress) { + if (this.selected_frame_argument_id) { + const examplesSelect = function () { + 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></th><th>Zdanie</th><th>ŹródÅ‚o</th><th>Opinia</th></tr></thead>' + this.examples.map(example => { + return `<tr><td><input type="checkbox" name="lus" value="${example.id}" /></td><td>${example.sentence}</td><td>${example.source}</td><td>${example.opinion}</td></tr>`; + }).join("") + '</table></div>'; + }.bind(this); - const extract_frames_to_new_frame_popup = { - state0: { - title: 'Wybierz jednostki leksykalne', - html: lusSelect, - buttons: {Anuluj: 0, Stwórz: 1}, - focus: -1, - submit: function (e, v, m, f) { - if (v == 0) { - e.preventDefault(); - $.prompt.close(); - } - if (v === 1) { - e.preventDefault(); - let lu_ids = normalizeFormData(f.lus); - const data = { - 'lu_ids': JSON.stringify(lu_ids), - 'entry_id': this.entryId - }; - $.ajax({ - type: 'post', - url: '/' + lang + '/freelus/create_new_slowal_frame/', - dataType: 'json', - data: data, - timeout: 60000, - success: function (response) { - show_info('Nowa rama zostaÅ‚a stworzona.'); - this.loadEntry(); - $.prompt.close(); - }.bind(this), - error: function (request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - $.prompt.close(); - } - }); - } - }.bind(this) - } - } - $.prompt(extract_frames_to_new_frame_popup); - }, - // add_argument() { - // if(this.frame_in_progress) { - // send_post_request('/freelus/add_argument_to_frame/', - // { - // 'frame_id': this.frame_in_progress.id, - // }, - // (reponse) => { - // show_info('Argument zostaÅ‚ dodany.'); - // alert(gettext("Argument zostaÅ‚ dodany.")); - // this.loadEntry(); - // }, - // (request, errorType, errorMessage) => { - // show_error(errorType + ' (' + errorMessage + ')'); - // alert(gettext("Dodanie argumentu nie powiodÅ‚o siÄ™. Błąd: "+errorType + ' (' + errorMessage + ')')); - // }) - // } else { - // alert(gettext("Stwórz nowÄ… ramÄ™.")); - // } - // }, - change_frame_opinion() { - if(this.frame_in_progress) { - send_post_request('/freelus/change_frame_opinion/', - { - 'frame_id': this.frame_in_progress.id, - 'opinion': frame.id, - }, - (reponse) => { - show_info('Opinia zostaÅ‚a zmieniona.'); - alert(gettext("Opinia zostaÅ‚a zmieniona.")); - this.loadEntry(); - }, - (request, errorType, errorMessage) => { - show_error(errorType + ' (' + errorMessage + ')'); - alert(gettext("Zmiana opinii nie powiodÅ‚a siÄ™. Błąd: "+errorType + ' (' + errorMessage + ')')); - }) - } else { - alert(gettext("Stwórz nowÄ… ramÄ™.")); - } - }, - roleStrMapping(roleName) { - if(roleName === 'role') { - return 'required'; - } else if(roleName === 'modifier') { - return 'typical'; - } else { - return roleName; - } - }, - change_role(selected_frame_argument_id, api_path) { - if (selected_frame_argument_id === null) { - alert(gettext("Zaznacz argument, dla którego chcesz wybrać rolÄ™.")); - } else { - const newSelect = function () { - let rolesHTML = roles.map(role => { - return `<label style="background-color:rgb(${role.color})"><input type="radio" name="role" value="${role.id}" /> ${role.role}</label><br />`; - }).join(""); - let attributesHTML = role_attributes.map(attribute => { - return `<label><input type="radio" name="attribute" value="${attribute.id}" /> ${attribute.attribute}</label><br />`; - }).join(""); - let subAttributesHTML = role_sub_attributes.map(subAttribute => { - return `<label><input type="radio" name="sub_attribute" value="${subAttribute.id}" /> ${subAttribute.sub_attribute}</label><br />`; - }).join(""); - // const roleTypeHTML = ['required', 'typical'].map(type => { - const roleTypeHTML = ['role', 'modifier'].map(type => { - return `<label><input type="radio" name="role_type" value="${type}" /> ${this.roleStrMapping(type)}</label><br />`; - }).join(""); - return '<div class="row">' + - '<div class="column"><div class="role_select_header">Type</div>' + roleTypeHTML + '</div>' + - '<div class="column"><div class="role_select_header">Role</div>' + rolesHTML + '</div>' + - '<div class="column"><div class="role_select_header">Atrybuty</div>' + attributesHTML + '</div>' + - '<div class="column"><div class="role_select_header">Podatrybuty</div>' + subAttributesHTML + '</div>' + - '</div>'; - }.bind(this); + const attach_examples_popup = { + state0: { + title: 'Wybierz przykÅ‚ady', + html: examplesSelect, + buttons: {Anuluj: 0, Wybierz: 1}, + focus: -1, + submit: function (e, v, m, f) { + if (v == 0) { + e.preventDefault(); + $.prompt.close(); + } + if (v === 1) { + e.preventDefault(); + let example_ids = normalizeFormData(f.lus); + const data = { + 'example_ids': JSON.stringify(example_ids), + 'frame_id': this.frame_in_progress.id, + 'argument_id': this.selected_frame_argument_id.split('-')[1] + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/attach_examples_to_frame/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + show_info('PrzykÅ‚ady zostaÅ‚y przypisane.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } + }.bind(this) + } + } + $.prompt(attach_examples_popup); + } else { + alert(gettext("Wybierz argument, do którego chcesz podłączyć przykÅ‚ady.")); + } + } else { + alert(gettext("Stwórz nowÄ… ramÄ™.")); + } + }, + change_frame_opinion() { + if (this.frame_in_progress) { + send_post_request('/freelus/change_frame_opinion/', + { + 'frame_id': this.frame_in_progress.id, + 'opinion': frame.id, + }, + (reponse) => { + show_info('Opinia zostaÅ‚a zmieniona.'); + alert(gettext("Opinia zostaÅ‚a zmieniona.")); + this.loadEntry(); + }, + (request, errorType, errorMessage) => { + show_error(errorType + ' (' + errorMessage + ')'); + alert(gettext("Zmiana opinii nie powiodÅ‚a siÄ™. Błąd: " + errorType + ' (' + errorMessage + ')')); + }) + } else { + alert(gettext("Stwórz nowÄ… ramÄ™.")); + } + }, + roleStrMapping(roleName) { + if (roleName === 'role') { + return 'required'; + } else if (roleName === 'modifier') { + return 'typical'; + } else { + return roleName; + } + }, + change_role(selected_frame_argument_id, api_path) { + if (selected_frame_argument_id === null) { + alert(gettext("Zaznacz argument, dla którego chcesz wybrać rolÄ™.")); + } else { + const newSelect = function () { + let rolesHTML = roles.map(role => { + return `<label style="background-color:rgb(${role.color})"><input type="radio" name="role" value="${role.id}" /> ${role.role}</label><br />`; + }).join(""); + let attributesHTML = role_attributes.map(attribute => { + return `<label><input type="radio" name="attribute" value="${attribute.id}" /> ${attribute.attribute}</label><br />`; + }).join(""); + let subAttributesHTML = role_sub_attributes.map(subAttribute => { + return `<label><input type="radio" name="sub_attribute" value="${subAttribute.id}" /> ${subAttribute.sub_attribute}</label><br />`; + }).join(""); + // const roleTypeHTML = ['required', 'typical'].map(type => { + const roleTypeHTML = ['role', 'modifier'].map(type => { + return `<label><input type="radio" name="role_type" value="${type}" /> ${this.roleStrMapping(type)}</label><br />`; + }).join(""); + return '<div class="row">' + + '<div class="column"><div class="role_select_header">Type</div>' + roleTypeHTML + '</div>' + + '<div class="column"><div class="role_select_header">Role</div>' + rolesHTML + '</div>' + + '<div class="column"><div class="role_select_header">Atrybuty</div>' + attributesHTML + '</div>' + + '<div class="column"><div class="role_select_header">Podatrybuty</div>' + subAttributesHTML + '</div>' + + '</div>'; + }.bind(this); - let change_role_popup = { - state0: { - title: 'Dodaj rolÄ™', - html: newSelect(), - buttons: {Anuluj: -1, Zatwierdź: 1}, - focus: -1, - submit: function (e, v, m, f) { - if (v == -1) { - $.prompt.close(); - } - if (v == 1) { - e.preventDefault(); + let change_role_popup = { + state0: { + title: 'Dodaj rolÄ™', + html: newSelect(), + buttons: {Anuluj: -1, Zatwierdź: 1}, + focus: -1, + submit: function (e, v, m, f) { + if (v == -1) { + $.prompt.close(); + } + if (v == 1) { + e.preventDefault(); - const role_id = normalizeFormData(f.role)[0]; - const role_type = normalizeFormData(f.role_type)[0]; + const role_id = normalizeFormData(f.role)[0]; + const role_type = normalizeFormData(f.role_type)[0]; - if (role_id != null && role_type != null) { - const attribute_id = normalizeFormData(f.attribute)[0]; + if (role_id != null && role_type != null) { + const attribute_id = normalizeFormData(f.attribute)[0]; - const sub_attribute_id = normalizeFormData(f.sub_attribute)[0]; + const sub_attribute_id = normalizeFormData(f.sub_attribute)[0]; - const data = { - 'frame_id': this.frame_in_progress.id, - 'argument_id': selected_frame_argument_id, - 'role_type': role_type, - 'role_id': role_id, - 'attribute_id': attribute_id, - 'sub_attribute_id': sub_attribute_id - }; - $.ajax({ - type: 'post', - url: '/' + lang + '/freelus/' + api_path + '/', - dataType: 'json', - data: data, - timeout: 60000, - success: function (response) { - alert(gettext("Nowa rola zosaÅ‚a zapisana.")); - show_info('Nowa rola zosaÅ‚a zapisana.'); - this.loadEntry(); - $.prompt.close(); - }.bind(this), - error: function (request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - $.prompt.close(); - } - }); - } else { - alert(gettext("Musisz wybrać typ oraz rolÄ™.")); - } - } - }.bind(this) - } - }; - $.prompt(change_role_popup); - } - }, - computeArgumentCSS(argument) { - const selectedExampleFrameArguments = this.selectedExamples && this.selectedExamples.length > 0 ? new Set(this.selectedExamples.map(e => e.argument_ids).flat()) : null; - return argument.role + ' ' + (argument.id === this.selected_frame_argument_id ? 'active' : argument.hover ? 'bg-highlight' : '') - + (selectedExampleFrameArguments != null ? selectedExampleFrameArguments.has(argument.id) ? 'example-yes' : 'example-no' : ''); - }, - selectArgument(argument) { - if(this.selected_frame_argument_id != argument.id) { - this.selected_frame_argument_id = argument.id; - } else { - this.selected_frame_argument_id = null; - } - // const selectedArguments = this.frame_in_progress.arguments.filter(argument => argument.selected) - // this.$emit('frameSelectionChanged', selectedArguments); - }, - }, - mounted() { - if(this.entryId) { - this.loadEntry(); - } - Split(['#semantics-frames-pane', '#free-lus-schemata-pane'], { - sizes: [40, 60], - minSize: 10, - gutterSize: 4, - elementStyle: (dimension, size, gutterSize) => { - return { - 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' + const data = { + 'frame_id': this.frame_in_progress.id, + 'argument_id': selected_frame_argument_id, + 'role_type': role_type, + 'role_id': role_id, + 'attribute_id': attribute_id, + 'sub_attribute_id': sub_attribute_id + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/' + api_path + '/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + alert(gettext("Nowa rola zosaÅ‚a zapisana.")); + show_info('Nowa rola zosaÅ‚a zapisana.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } else { + alert(gettext("Musisz wybrać typ oraz rolÄ™.")); + } + } + }.bind(this) + } + }; + $.prompt(change_role_popup); + } + }, + computeArgumentCSS(argument) { + const selectedExampleFrameArguments = this.selectedExamples && this.selectedExamples.length > 0 ? new Set(this.selectedExamples.map(e => e.argument_ids).flat()) : null; + return argument.role + ' ' + (argument.id === this.selected_frame_argument_id ? 'active' : argument.hover ? 'bg-highlight' : '') + + (selectedExampleFrameArguments != null ? selectedExampleFrameArguments.has(argument.id) ? 'example-yes' : 'example-no' : ''); + }, + selectArgument(argument) { + if (this.selected_frame_argument_id != argument.id) { + this.selected_frame_argument_id = argument.id; + this.selectedFrameArguments = [argument]; + } else { + this.selected_frame_argument_id = null; + this.selectedFrameArguments = []; + } + // const selectedArguments = this.frame_in_progress.arguments.filter(argument => argument.selected) + // this.$emit('frameSelectionChanged', selectedArguments); + }, + assign_schema() { + if (this.frame_in_progress && this.selected_schemata_position_id && this.selected_frame_argument_id) { + const data = { + 'frame_id': this.frame_in_progress.id, + 'argument_id': this.selected_frame_argument_id.split('-')[1], + 'schema_id': this.selectedSchemas[0].id, + 'schema_position_id': this.selected_schemata_position_id.split('-')[1] + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/attach_schema_to_argument/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + alert(gettext("Argument ramy zostaÅ‚ powiÄ…zany z tybranym argumentem schematu.")); + show_info('Argument ramy zostaÅ‚ powiÄ…zany z tybranym argumentem schematu.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } else { + alert(gettext("W celu powiÄ…zania schamatu oraz ramy zaznacz argument ramy oraz argument schematu.")); + } + }, + delete_schema_connections() { + if (this.frame_in_progress && this.selected_schemata_position_id && this.selected_frame_argument_id) { + const data = { + 'frame_id': this.frame_in_progress.id, + 'argument_id': this.selected_frame_argument_id.split('-')[1], + 'schema_id': this.selectedSchemas[0].id, + 'schema_position_id': this.selected_schemata_position_id.split('-')[1] + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/delete_schema_to_argument_connection/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + alert(gettext("PowiÄ…zanie pomiÄ™dzy argumentem ramy a argumentem schematu zostaÅ‚o usuniÄ™te.")); + show_info('PowiÄ…zanie pomiÄ™dzy argumentem ramy a argumentem schematu zostaÅ‚o usuniÄ™te.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } else { + alert(gettext("W celu usuniÄ™cia powiÄ…zania schamatu oraz ramy zaznacz argument ramy oraz argument schematu.")); + } + }, + finish_frame_building() { + if (this.frame_in_progress) { + const data = { + 'frame_id': this.frame_in_progress.id, + }; + $.ajax({ + type: 'post', + url: '/' + lang + '/freelus/finish_frame_processing/', + dataType: 'json', + data: data, + timeout: 60000, + success: function (response) { + alert(gettext("Rama zostaÅ‚a oznaczona jako gotowa.")); + show_info('Rama zostaÅ‚a oznaczona jako gotowa.'); + this.loadEntry(); + $.prompt.close(); + }.bind(this), + error: function (request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } else { + alert(gettext("W celu usuniÄ™cia powiÄ…zania schamatu oraz ramy zaznacz argument ramy oraz argument schematu.")); + } + } + }, + mounted() { + if (this.entryId) { + this.loadEntry(); + } + Split(['#semantics-frames-pane', '#free-lus-schemata-pane'], { + sizes: [60, 40], + minSize: 10, + gutterSize: 4, + elementStyle: (dimension, size, gutterSize) => { + return { + 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' + } + }, + }); + Split(['#free-lus-pane', '#free-lus-examples'], { + sizes: [60, 40], + direction: 'vertical', + gutterSize: 4, + minSize: 10, + }); } - }, - }); - Split(['#free-lus-pane', '#free-lus-examples'], { - sizes: [60, 40], - direction: 'vertical', - gutterSize: 4, - minSize: 10, - }); - } -}); - -export default FreeLuEdit; - + } </script> <template> <div class="col h-100 px-0 pt-0 pb-0 overflow-auto" id="semantics-frames-pane"> - <div id="free-lus-pane" class="col w-100 p-0 overflow-auto"> - <table class="table-button-menu sticky-top" cellspacing="1"> - <tr style="background-color: white;"> - <td id="create-new-frame" @click="create_new_slowal_frame()" style="padding: 10px 15px 10px 15px; color: #000000;">Nowa rama</td> - <td id="add-argument" @click="change_role(-1, 'add_argument_to_frame')" style="padding: 10px 15px 10px 15px; color: #000000;">Dodaj argument</td> - <td id="change-role" @click="change_role(selected_frame_argument_id ? selected_frame_argument_id.split('-')[1] : null, 'change_role')" style="padding: 10px 15px 10px 15px; color: #000000;">ZmieÅ„ rolÄ™</td> - <td id="assign-examples" @click="assign_examples()" style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz przykÅ‚ady</td> -<!-- <td id="add-arg" @click="create_hyponym_or_hyperonym_relation(true)" style="padding: 10px 15px 10px 15px; color: #000000;">Podrama</td>--> -<!-- <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="delete_hyponym_or_hyperonym_relation">UsuÅ„ powiÄ…zanie</td>--> -<!-- <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="goToEdit">Edytuj</td>--> - </tr> - </table> - - <spinner /> - <div align="center"> - - <div class="lu-table mt-3 mb-3"> - <table class="m-0 table-borderless text-dark"> - <tr><td> - <table class="m-0 border border-secondary text-dark"> - <tbody> - <tr> - <th scope="row" class="py-2 px-1 text-secondary">Jednostka leksykalna</th> - <th scope="row" class="py-2 px-1 text-secondary">Opinia</th> - <th scope="row" class="py-2 px-1 text-secondary">Status</th> - </tr> - <tr class="preferences py-0 px-0 border-top border-left border-secondary" - v-if="lexicalUnitsVisible" - v-for='lexical_unit in lexical_units' - > - <!-- <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> + <div id="free-lus-pane" class="col w-100 p-0 overflow-auto"> + <table class="table-button-menu sticky-top" cellspacing="1"> + <tr style="background-color: white;"> + <td id="create-new-frame" class="table-button-menu-td" @click="create_new_slowal_frame()" + style="padding: 10px 15px 10px 15px; color: #000000;">Nowa rama </td> - <td style="vertical-align: text-top; padding-left: 10px; padding-top: 8px; min-width: 50px;"> - <span class="cursor-pointer" @click.stop="hideLexicalUnits()" title="Ukryj jednostki leksykalne">▴</span> / - <span class="cursor-pointer" @click.stop="showLexicalUnits()" title="Pokaż jednostki leksykalne">▾</span></td> - </tr> - </table> - </div> - - <div class="lu-table mt-3 mb-3"> - <table class="m-0 table-borderless text-dark"> - <tr><td> - <table class="m-0 border border-secondary text-dark"> - <tbody> - <tr> - <th scope="row" class="py-2 px-1 text-secondary">Wolne jednostki leksykalne</th> - </tr> - <tr class="preferences py-0 px-0 border-top border-left border-secondary" - v-if="lexicalUnitsVisible" - v-for='lexical_unit in free_lexical_units' - > - <td class="argument py-2 px-1 border-top border-left border-secondary">{{ lexical_unit.display }}</td> - </tr> - </tbody> - </table> + <td id="add-argument" class="table-button-menu-td" @click="change_role(-1, 'add_argument_to_frame')" + style="padding: 10px 15px 10px 15px; color: #000000;">Dodaj argument </td> - <td style="vertical-align: text-top; padding-left: 10px; padding-top: 8px; min-width: 50px;"> - <span class="cursor-pointer" @click.stop="hideLexicalUnits()" title="Ukryj jednostki leksykalne">▴</span> / - <span class="cursor-pointer" @click.stop="showLexicalUnits()" title="Pokaż jednostki leksykalne">▾</span></td> - </tr> - </table> - </div> + <td id="change-role" class="table-button-menu-td" + @click="change_role(selected_frame_argument_id ? selected_frame_argument_id.split('-')[1] : null, 'change_role')" + style="padding: 10px 15px 10px 15px; color: #000000;">ZmieÅ„ rolÄ™ + </td> + <td id="assign-examples" class="table-button-menu-td" @click="attach_examples()" + style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz przykÅ‚ady + </td> + </tr> + <tr style="background-color: white;"> + <td id="assign-schema" class="table-button-menu-td" @click="assign_schema()" + style="padding: 10px 15px 10px 15px; color: #000000;">Podłącz schemat + </td> + <td id="delete-schema" class="table-button-menu-td" @click="delete_schema_connections()" + style="padding: 10px 15px 10px 15px; color: #000000;">Rozłącz schemat + </td> + <td id="finish-frame-building" class="table-button-menu-td" @click="finish_frame_building()" + style="padding: 10px 15px 10px 15px; color: #000000;">ZakoÅ„cz tworzenie nowej ramy + </td> + </tr> + </table> + <spinner/> + <div align="center"> + <div class="lu-table mt-3 mb-3"> + <table class="m-0 table-borderless text-dark"> + <tr> + <td> + <table class="m-0 border border-secondary text-dark"> + <tbody> + <tr> + <th scope="row" class="py-2 px-1 text-secondary">Jednostka leksykalna</th> + <th scope="row" class="py-2 px-1 text-secondary">Opinia</th> + <th scope="row" class="py-2 px-1 text-secondary">Status</th> + </tr> + <tr class="preferences py-0 px-0 border-top border-left border-secondary" + v-if="lexicalUnitsVisible" + 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> + <td class="argument py-2 px-1 border-top border-left border-secondary">[{{ + lexical_unit.frame_status }}] + </td> + </tr> + </tbody> + </table> + </td> + <td style="vertical-align: text-top; padding-left: 10px; padding-top: 8px; min-width: 50px;"> + <span class="cursor-pointer" @click.stop="hideLexicalUnits()" + title="Ukryj jednostki leksykalne">▴</span> / + <span class="cursor-pointer" @click.stop="showLexicalUnits()" + title="Pokaż jednostki leksykalne">▾</span></td> + </tr> + </table> + </div> + <div class="lu-table mt-3 mb-3"> + <table class="m-0 table-borderless text-dark"> + <tr> + <td> + <table class="m-0 border border-secondary text-dark"> + <tbody> + <tr> + <th scope="row" class="py-2 px-1 text-secondary">Wolne jednostki leksykalne</th> + </tr> + <tr class="preferences py-0 px-0 border-top border-left border-secondary" + v-if="lexicalUnitsVisible" + v-for='lexical_unit in free_lexical_units' + > + <td class="argument py-2 px-1 border-top border-left border-secondary">{{ + lexical_unit.display }} + </td> + </tr> + </tbody> + </table> + </td> + <td style="vertical-align: text-top; padding-left: 10px; padding-top: 8px; min-width: 50px;"> + <span class="cursor-pointer" @click.stop="hideLexicalUnits()" + title="Ukryj jednostki leksykalne">▴</span> / + <span class="cursor-pointer" @click.stop="showLexicalUnits()" + title="Pokaż jednostki leksykalne">▾</span></td> + </tr> + </table> + </div> - <div class="row pt-3" style="flex-wrap: nowrap;" v-if="frame_in_progress"> - <div class="col pl-5 pr-4"> - <div class="row"> - <div class="col frame px-0" id="lexical-unit-frame_in_progress"> - <meaning-component - :key="frame_in_progress.lexical_units" - :lexicalUnits="frame_in_progress.lexical_units" - :selectedExamples="selectedExamples" - @meaning-lu-selected="meaningLuSelected" - ></meaning-component> + <div id="semantics-frames-processing-head"> + <span class="font-weight-bold h4">Rama w opracowaniu</span> + </div> + + <div class="row pt-3" style="flex-wrap: nowrap;" v-if="frame_in_progress"> + <div class="col pl-5 pr-5"> + <div class="row"> + <div class="col frame px-0 text-left" id="lexical-unit-frame_in_progress"> + <meaning-component + :key="frame_in_progress.lexical_units" + :lexicalUnits="frame_in_progress.lexical_units" + :selectedExamples="selectedExamples" + @meaning-lu-selected="meaningLuSelected" + ></meaning-component> + </div> </div> - </div> - <div class="row"> - <div class="col px-0 frame mb-3 active"> - <table id="free-lus-frame" class="table m-0 table-borderless border border-secondary text-dark"> - <tbody> - <tr class="opinion-row"> - <th scope="row" class="py-2 px-1 text-secondary" style="width: 3em;">Opinia</th> - <td class="opinion-cell py-2 px-1" :colspan="frame_in_progress.arguments.length"> - <table class="table m-0 p-0 table-borderless"> - <tr> - <td class="opinion-cell p-0"> - <img :src="'/static/entries/img/' + frame_in_progress.opinion_key + '.svg'" :alt="frame_in_progress.opinion" - width="12" height="12"> {{frame_in_progress.opinion}} - </td> - </tr> - </table> - </td> - </tr> - <tr> - <th scope="row" class="py-2 px-1 text-secondary">Rola</th> - <template v-for="argument in frame_in_progress.arguments"> - <td class="argument py-2 px-1 border-top border-left border-secondary" - @mouseenter="argument.hover=true" - @mouseleave="argument.hover=false" - @click.stop="selectArgument(argument)" - :class="computeArgumentCSS(argument)" - > - {{argument.str}} + <div class="row"> + <div class="col px-0 frame mb-3 active"> + <table id="free-lus-frame" + class="table m-0 table-borderless border border-secondary text-dark"> + <tbody> + <tr class="opinion-row"> + <th scope="row" class="py-2 px-1 text-secondary" style="width: 3em;">Opinia</th> + <td class="opinion-cell py-2 px-1" + :colspan="frame_in_progress.arguments.length"> + <table class="table m-0 p-0 table-borderless"> + <tr> + <td class="opinion-cell p-0"> + <img :src="'/static/entries/img/' + frame_in_progress.opinion_key + '.svg'" + :alt="frame_in_progress.opinion" + width="12" height="12"> {{frame_in_progress.opinion}} + </td> + </tr> + </table> </td> - </template> - </tr> - </tbody> - </table> + </tr> + <tr> + <th scope="row" class="py-2 px-1 text-secondary">Rola</th> + <template v-for="argument in frame_in_progress.arguments"> + <td class="argument py-2 px-1 border-top border-left border-secondary" + @mouseenter="argument.hover=true" + @mouseleave="argument.hover=false" + @click.stop="selectArgument(argument)" + :class="computeArgumentCSS(argument)" + > + {{argument.str}} + </td> + </template> + </tr> + </tbody> + </table> + </div> </div> </div> </div> - </div> - - - - - -<!-- <div v-if="frame_in_progress" align="left" style="display: table;">--> -<!--<!– <div class="unifiedFrame mt-3" v-if="frame_in_progress" v-bind:data-frame_id="frame_in_progress.id" id="unified-frame-title"></div>–>--> -<!-- <table v-if="frame_in_progress.id" id="unified-frame-opac" class="table-borderless">--> -<!-- <tr><td>--> -<!-- <table id="unified-frame" class="m-0 table-borderless border border-secondary text-dark frame active">--> -<!-- <tbody>--> -<!-- <tr>--> -<!-- <th scope="row" class="py-2 px-1 text-secondary role-header">Role</th>--> - -<!-- <template v-for="argument in frame_in_progress_arguments">--> -<!-- <td--> -<!-- class="argument py-2 px-1 border-top border-left border-secondary role-column"--> -<!-- :class="getArgumentCSS(argument)"--> -<!-- @click="unifiedFrameArgumentSelected(argument)"--> -<!-- @mouseover="unifiedFrameArgumentHovered(argument)"--> -<!-- @mouseleave="unifiedFrameArgumentHovered(null)"--> -<!-- >--> -<!-- <span style="font-size: 0.8rem;">{{ roleStrMapping(argument.role_type) }}</span>--> -<!-- <div--> -<!-- v-if="argument.role"--> -<!-- >--> -<!-- [{{ argument.role.str }}]--> -<!-- </div>--> -<!-- <div v-else>--> -<!-- <ul class="ul-role">--> -<!-- <li v-for="proposed_role in argument.proposed_roles">--> -<!-- {{ proposed_role.str }}--> -<!-- </li>--> -<!-- </ul>--> -<!-- </div>--> -<!-- </td>--> -<!-- </template>--> - - -<!-- </tr>--> -<!-- </tbody>--> -<!-- </table>--> -<!-- </td></tr>--> -<!-- </table>--> -<!-- </div>--> + <div id="semantics-frames-head"> + <span class="font-weight-bold h4">Ramy Opracowane</span> + </div> - <div id="semantics-frames"> - <template v-for="frame in frames"> - <div class="row pt-3" style="flex-wrap: nowrap;"> - <div class="col pl-5 pr-4"> - <div class="row"> - <div class="col frame px-0" id="lexical-unit"> - <meaning-component - :key="frame.lexical_units" - :lexicalUnits="frame.lexical_units" - :selectedExamples="selectedExamples" - @meaning-lu-selected="meaningLuSelected" - ></meaning-component> + <div id="semantics-frames"> + <template v-for="frame in frames"> + <div class="row pt-3" style="flex-wrap: nowrap;"> + <div class="col pl-5 pr-5"> + <div class="row"> + <div class="col frame px-0" id="lexical-unit"> + <meaning-component + :key="frame.lexical_units" + :lexicalUnits="frame.lexical_units" + :selectedExamples="selectedExamples" + @meaning-lu-selected="meaningLuSelected" + ></meaning-component> + </div> </div> - </div> - <div class="row"> - <div class="col px-0 frame mb-3 active" - @mouseenter="frame.hover=true" - @mouseleave="frame.hover=false" - @click="slowalFrameSelected(frame)" - :class="frame === active_slowal_frame ? 'active-frame' : frame.hover ? 'bg-highlight' : ''" > - <slowal-frame-component - :frame="frame" - :key="frame" - :selectedExamples="selectedExamples" - @frame-selection-changed="insideFrameSelectionChanged" - /> + <div class="row"> + <div class="col px-0 frame mb-3 active" + @mouseenter="frame.hover=true" + @mouseleave="frame.hover=false" + @click="slowalFrameSelected(frame)" + :class="frame === active_slowal_frame ? 'active-frame' : frame.hover ? 'bg-highlight' : ''"> + <slowal-frame-component + :frame="frame" + :key="frame" + :selectedExamples="selectedExamples" + @frame-selection-changed="insideFrameSelectionChanged" + /> + </div> </div> </div> </div> -<!-- <div v-if="!readOnly && !isReadOnlyForSuperLeksykograf()" class="col pl-0 pt-4" style="max-width: 60px;">--> -<!-- <div class="row"></div>--> -<!-- <div class="row">--> -<!-- <div class="col">--> -<!--<!– <button v-if="!isFrameVerified(frame)"–>--> -<!--<!– class="btn btn-sm btn-dark px-2 py-0" role="button"–>--> -<!--<!– style="font-size: 20px; min-width: 35px"–>--> -<!--<!– @click="change_slowal2unified_frame_argument_mapping(frame)"–>--> -<!--<!– title="ZamieÅ„ wybrane argumenty ramy"–>--> -<!--<!– >Z</button>–>--> -<!-- </div>--> -<!-- </div>--> -<!-- <div class="row">--> -<!-- <div v-if="isFrameVerified(frame)" class="col pl-1" style="display: flex;">--> -<!-- <input--> -<!-- type="checkbox"--> -<!-- :checked="isFrameVerified(frame)"--> -<!-- class="custom-control custom-checkbox ok-checkbox"--> -<!-- >--> -<!-- </div>--> -<!-- </div>--> -<!-- </div>--> - </div> - </template> - </div> + </template> + </div> - </div> + </div> </div> <div id="free-lus-examples" class="col w-100 p-0 tab-pane overflow-auto"> - <examples-component v-if="examples" - :examples="examples" - :frame="active_slowal_frame" - :frame_arguments="selectedFrameArguments" - :frame_arguments_or_type="frame_arguments_or_type" - :lus="selectedLus" - :schemas="selectedSchemas" - :key="examples" - @example-selected="exampleSelected" + <examples-component v-if="examples" + :examples="examples" + :frame="active_slowal_frame" + :frame_arguments="selectedFrameArguments" + :frame_arguments_or_type="frame_arguments_or_type" + :lus="selectedLus" + :schemas="selectedSchemas" + :key="examples" + @example-selected="exampleSelected" /> </div> </div> - <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" style="padding-left: 0px!important; padding-right: 0px!important;" id="free-lus-schemata-pane"> - <ul class="nav nav-pills nav-justified p-1" id="entryTabs" role="tablist"> - <li - v-for="tab in right_pane_tabs" - class="btn btn-sm btn-outline-dark nav-link mx-1" - :class="right_pane_tab === tab.id && 'active'" - @click="right_pane_tab = tab.id" - > - {{ tab.label }} - </li> - </ul> - <div :class="right_pane_tab !== 'schemata' && 'd-none'"> - <semantics-schemata-component + <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" + style="padding-left: 0px!important; padding-right: 0px!important;" id="free-lus-schemata-pane"> + <semantics-schemata-component :subentries="subentries" :key="subentries" - :frame="active_slowal_frame" + :frame="frame_in_progress" :alternations="alternations" :realisation_phrases="realisation_phrases" :realisation_descriptions="realisation_descriptions" :selectedExamples="selectedExamples" @schemata-selected="schemataSelected" - /> - </div> + @schema-position-selected="selectSchemaPositionSelected" + /> </div> </template> diff --git a/frontend/src/components/unification/free_lu/FreeLuElement.vue b/frontend/src/components/unification/free_lu/FreeLuElement.vue deleted file mode 100644 index 5a2b4aa..0000000 --- a/frontend/src/components/unification/free_lu/FreeLuElement.vue +++ /dev/null @@ -1,188 +0,0 @@ -<script> - -export default { - name: 'FreeLuElement', - props: { - node: { - type: Object, - required: true - }, - spacing: { - type: Number, - default: 0 - }, - spacing_elem_type: String - }, - data() { - return { - showHyponyms: false, - showHypyronyms: false - } - }, - computed: { - nodeMargin() { - return { - 'margin-left': `${this.spacing}px` - } - }, - hasHyponyms() { - const {hyponyms} = this.node - return hyponyms && hyponyms.length > 0 - }, - hasHypyronyms() { - const {hypyronyms} = this.node - return hypyronyms && hypyronyms.length > 0 - }, - toggleChildrenIcon() { - return this.showHypyronyms ? 'fas fa-angle-down' : 'fas fa-angle-right' - }, - getSpacingElem() { - if(this.spacing_elem_type === "std") { - return "│ ├→ │"; - } else if(this.spacing_elem_type === "top_corner") { - return "        ┌→ │ │"; - } else if(this.spacing_elem_type === "down_corner") { - return "│ │ └→"; - } else { - return ""; - } - }, - }, - methods: { - loadChildren (children) { - for (let i in children) { - const hypyronym = children[i]; - if (hypyronym.hasChildrenLoaded !== true) { - $.ajax({ - type: 'post', - url: '/' + lang + '/unifier/get_hierarchy_hyperonyms/' + hypyronym.unified_frame_id + "/", - dataType: 'json', - timeout: 60000, - success: function (response) { - hypyronym.hypyronyms = response.hyperonyms; - }.bind(this), - error: function (request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - } - }); - $.ajax({ - type: 'post', - url: '/' + lang + '/unifier/get_hierarchy_hyponyms/' + hypyronym.unified_frame_id + "/", - dataType: 'json', - timeout: 60000, - success: function (response) { - hypyronym.hyponyms = response.hyponyms; - }.bind(this), - error: function (request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - } - }); - } - } - }, toggleHypyronyms() { - this.loadChildren(this.node.hypyronyms); - this.showHypyronyms = !this.showHypyronyms - }, - toggleHyponyms() { - this.loadChildren(this.node.hyponyms); - this.showHyponyms = !this.showHyponyms - } - } -} - -</script> - - -<template> - <div :style="nodeMargin" style="height: 100%"> - <div v-if="hasHypyronyms" v-show="showHypyronyms"> - <free-lu-element - v-for="(child, index) in node.hypyronyms" - :key="child.id" - :node="child" - :spacing_elem_type='index === 0 ? "top_corner" : "std"' - :spacing="spacing + 40" - /> - </div> - <div show class="d-flex justify-content-between mb-1"> - <div class="row"> - <div class="col" style="max-width: 10px" v-html="getSpacingElem"/> - <div class="col"> - <div class="row"> - <div class="col cursor-pointer" style="text-align: center; font-size: large"><span - v-if="hasHypyronyms" - :class="toggleChildrenIcon" - @click="toggleHypyronyms" - @keypress="toggleHypyronyms">▲</span></div> - </div> - <div class="row"> - <div class="col" align="left" style="display: table;"> - <div class="unifiedFrame" id="hierarchy-unified-frame-title" v-html="node.unified_frame.title"></div> - <table id="hierarchy-unified-frame" class="m-0 table-borderless border border-secondary text-dark frame active"> - <tbody> - <tr> - <template v-for="argument in node.unified_frame.arguments"> - <td - class="argument py-2 px-1 border-top border-left border-secondary role-column" - :class="argument.role ? argument.role.str + ' ' : ''" - > - {{ argument.role_type }} - - <div - v-if="argument.role" - > - [{{ argument.role.str }}] - </div> - <div v-else> - <ul class="ul-role"> - <li v-for="proposed_role in argument.proposed_roles"> - {{ proposed_role.str }} - </li> - </ul> - </div> - </td> - </template> - </tr> - <tr> - <td hidden class="preferences py-0 px-0 border-top border-left border-secondary role-column align-top" - v-for='argument in node.unified_frame.arguments' - :key='argument.id' - > - <ul class="ul-preference" v-if="argument.preferences.length > 0"> - <li v-for='preference in argument.preferences'> - <div - v-if="preference.url != null" - class="preference py-2 px-1 preference-bold" - > - <a class="synset-plwn" v-bind:href="preference.url" target="_blank">{{ preference.str }}</a> - </div> - <div v-else class="preference py-2 px-1 preference-bold">{{ preference.str }}</div> - </li> - </ul> - </td> - </tr> - </tbody> - </table> - </div> - </div> - <div class="row align-content-center"> - <div class="col cursor-pointer" style="text-align: center; font-size: large"><span - v-if="hasHyponyms" - :class="toggleChildrenIcon" - @click="toggleHyponyms" - @keypress="toggleHyponyms">▼</span></div> - </div> - </div> - </div> - </div> - <div v-if="hasHyponyms" v-show="showHyponyms"> - <free-lu-element - v-for="(child, index) in node.hyponyms" - :key="child.id" - :node="child" - :spacing_elem_type='index === node.hyponyms.length - 1 ? "down_corner" : "std"' - :spacing="spacing + 40" - /> - </div> - </div> -</template> diff --git a/frontend/src/components/unification/free_lu/FreeLuPreview.vue b/frontend/src/components/unification/free_lu/FreeLuPreview.vue deleted file mode 100644 index a88db17..0000000 --- a/frontend/src/components/unification/free_lu/FreeLuPreview.vue +++ /dev/null @@ -1,64 +0,0 @@ -<script> -import UnificationFramesList from "../Unification/UnificationFramesList.vue"; - -export default { - props: { - initialUnifiedFrameId: Number, - initialLexicalUnitId: Number, - forceRefresh: Number, - hierarchyEditComponent: Object, - }, - data () { - return { - unifiedFrameId: this.initialUnifiedFrameId - }; - }, - components: {UnificationFramesList}, - emits: ['changeFrame', 'refreshEntriesList'], - methods: { - unifiedFrameSelected (unifiedFrameId) { - this.$emit('changeFrame', unifiedFrameId); - }, - refreshEntriesList() { - this.$emit('refreshEntriesList') - }, - }, - mounted () { - Split(['#frame-preview-left-pane', '#frame-preview-right-pane'], { - sizes: [60, 40], - minSize: 20, - gutterSize: 4, - elementStyle: (dimension, size, gutterSize) => { - return { - 'flex-basis': 'calc(' + size + '% - ' + gutterSize + 'px)' - } - }, - }); - } -}; -</script> - -<template> - <div class="row h-100 overflow-hidden"> - <div :key="unifiedFrameId" class="col h-100 pr-0 pt-0 pb-0 overflow-auto" id="frame-preview-left-pane"> - <component v-bind:is="hierarchyEditComponent" - v-if="unifiedFrameId !== -1" - :readOnly="true" - :unifiedFrameId="unifiedFrameId" - :forceRefresh="forceRefresh" - @refresh-entries-list="refreshEntriesList" - /> - <div v-else class="h-100"> - Brak ramy do wyÅ›wietlenia - </div> - </div> - <div class="col h-100 pl-1 pt-0 pb-0 overflow-auto" id="frame-preview-right-pane"> -<!-- <unification-switchable-list--> -<!-- @unified-frame-selected="unifiedFrameSelected"--> -<!-- />--> - <unification-frames-list - @unified-frame-selected="unifiedFrameSelected" - /> - </div> - </div> -</template> diff --git a/frontend/src/components/unification/free_lu/FreeLuRightPane.vue b/frontend/src/components/unification/free_lu/FreeLuRightPane.vue deleted file mode 100644 index 0aa7d04..0000000 --- a/frontend/src/components/unification/free_lu/FreeLuRightPane.vue +++ /dev/null @@ -1,66 +0,0 @@ -<script> -import FreeLuEdit from './FreeLuEdit.vue'; - -export default { - components: {FreeLuEdit}, - props: { - entryId: Number, - lexicalUnitId: Number, - initialUnifiedFrameId: Number, - }, - emits: ['refreshEntriesList'], - data() { - return this.getInitialData(); - }, - methods: { - getInitialData() { - return { - key: this.lexicalUnitId, - entryIdLocal: this.entryId, - unifiedFrameId: this.initialUnifiedFrameId, - previewedUnifiedFrameId: -1 - }; - }, - goToDisplay() { - this.unifiedFrameId = null; - }, - refresh() { - this.key = null; - setTimeout(() => { - this.key = this.lexicalUnitId; - }, 0); - }, - swapFrames(previewedUnifiedFrameId) { - this.previewedUnifiedFrameId = this.unifiedFrameId; - this.unifiedFrameId = previewedUnifiedFrameId; - this.refresh(); - }, - refreshEntriesList() { - this.$emit('refreshEntriesList'); - } - }, - watch: { - lexicalUnitId() { - Object.assign(this, this.getInitialData()); - }, - initialUnifiedFrameId() { - Object.assign(this, this.getInitialData()); - } - }, -}; -</script> - -<template> - <div v-if="key || entryId" :key="(key, entryIdLocal, unifiedFrameId)" class="row h-100 m-0 p-0 overflow-auto" id="semantics-top-pane"> - <free-lu-edit - ref="hierarchyEdit" - v-if="entryId" - :key="entryId" - :readOnly="false" - :entryId="entryId" - @go-to-display="goToDisplay" - @swap-frames="swapFrames" - @refresh-entries-list="refreshEntriesList" - /> - </div> -</template> diff --git a/frontend/src/components/unification/free_lu/FreeLusList.vue b/frontend/src/components/unification/free_lu/FreeLusList.vue index 109bc9d..b2092c2 100644 --- a/frontend/src/components/unification/free_lu/FreeLusList.vue +++ b/frontend/src/components/unification/free_lu/FreeLusList.vue @@ -1,60 +1,58 @@ <script> -export default { - data() { - return { - gettext: window.gettext, - canViewAssignment: has_permission("users.view_assignment") - } - }, - methods: { - reset_list() { - this.$emit('unifiedFrameSelected', null); - setup_free_lus_list({ - table: this.$refs.framestable, - entrySelected: (entryId) => { - this.$emit('entrySelected', entryId); + export default { + data() { + return { + gettext: window.gettext, + canViewAssignment: has_permission("users.view_assignment") + } }, - selectEntryId: this.initialUnifiedFrameId, - }); - } - }, - watch: { - unificationEntriesListRefreshKey() { - // TODO: reload data and click in selected row - // this.datatableObject.ajax.reload(); - setup_free_lus_list({ - table: this.$refs.framestable, - entrySelected: (entryId) => { - this.$emit('entrySelected', entryId); + methods: { + reset_list() { + this.$emit('unifiedFrameSelected', null); + setup_free_lus_list({ + table: this.$refs.framestable, + entrySelected: (entryId) => { + this.$emit('entrySelected', entryId); + }, + selectEntryId: this.initialUnifiedFrameId, + }); + } }, - selectEntryId: this.initialUnifiedFrameId, - }); - } - }, - emits: ['entrySelected'], - mounted() { - this.$.appContext.config.globalProperties.$entries_list = this; - setup_free_lus_list({ - table: this.$refs.framestable, - entrySelected: (entryId) => { - this.$emit('entrySelected', entryId); - }, - selectEntryId: this.initialUnifiedFrameId, - }); - }, -}; + watch: { + unificationEntriesListRefreshKey() { + setup_free_lus_list({ + table: this.$refs.framestable, + entrySelected: (entryId) => { + this.$emit('entrySelected', entryId); + }, + selectEntryId: this.initialUnifiedFrameId, + }); + } + }, + emits: ['entrySelected'], + mounted() { + this.$.appContext.config.globalProperties.$entries_list = this; + setup_free_lus_list({ + table: this.$refs.framestable, + entrySelected: (entryId) => { + this.$emit('entrySelected', entryId); + }, + selectEntryId: this.initialUnifiedFrameId, + }); + }, + }; </script> <template> - <table ref="framestable" class="table table-sm table-hover text-dark"> - <thead> - <tr> - <th class="p-1">{{ gettext('HasÅ‚o') }}</th> - <th class="p-1">{{ gettext('Status') }}</th> - <th class="p-1" hidden="true">{{ gettext('Id') }}</th> - </tr> - </thead> - <tbody id="free-entries"> - </tbody> - </table> + <table ref="framestable" class="table table-sm table-hover text-dark"> + <thead> + <tr> + <th class="p-1">{{ gettext('HasÅ‚o') }}</th> + <th class="p-1">{{ gettext('Status') }}</th> + <th class="p-1" hidden="true">{{ gettext('Id') }}</th> + </tr> + </thead> + <tbody id="free-entries"> + </tbody> + </table> </template> diff --git a/frontend/src/components/unification/shared/frame-components/MeaningComponent.vue b/frontend/src/components/unification/shared/frame-components/MeaningComponent.vue index be1bdf6..1b0060a 100644 --- a/frontend/src/components/unification/shared/frame-components/MeaningComponent.vue +++ b/frontend/src/components/unification/shared/frame-components/MeaningComponent.vue @@ -36,7 +36,7 @@ export default { </script> <template> - <p class="mb-1"> + <p class="mb-1 text-left"> <template v-for="lexicalUnit in lexicalUnits"> <span @mouseenter="lexicalUnit.hover=true" diff --git a/frontend/src/components/unification/shared/frame-components/SemanticsSchemataComponent.vue b/frontend/src/components/unification/shared/frame-components/SemanticsSchemataComponent.vue index 3c5306c..3f89bcb 100644 --- a/frontend/src/components/unification/shared/frame-components/SemanticsSchemataComponent.vue +++ b/frontend/src/components/unification/shared/frame-components/SemanticsSchemataComponent.vue @@ -11,10 +11,11 @@ selectedExamples: Object }, components: {InfoTooltip}, - emits: ['schemataSelected'], + emits: ['schemataSelected', 'schemaPositionSelected'], data() { return { - img_prefix: window.STATIC_URL + img_prefix: window.STATIC_URL, + selected_schemata_position_id: null } }, methods: { @@ -36,7 +37,7 @@ }, getRealisationDescriptions(schema, alternation_id) { const alternationDescList = []; - if (this.alternations && this.frame) { + if (this.alternations && this.frame && this.realisation_descriptions && this.realisation_descriptions[this.frame.id] && this.realisation_descriptions[this.frame.id][schema.id]) { alternationDescList.push(this.realisation_descriptions[this.frame.id][schema.id][alternation_id]); } return '<i>' + alternationDescList + '</i>'; @@ -49,7 +50,7 @@ for (let arg_id in alternation) { const phrase_ids = alternation[arg_id]; phrase_ids.forEach(phrase_id => { - if (phrase_id.startsWith(position.id)) { + if (phrase_id.startsWith(position.id + '-')) { argumentIdSet.add(arg_id); } }); @@ -70,7 +71,7 @@ return styles; }, getAlternation(schema, alternation) { - const r = this.frame ? this.alternations[this.frame.id][schema.id][alternation] : null; + const r = this.frame && this.alternations ? this.alternations[this.frame.id][schema.id][alternation] : null; return r; }, getPositionPhrases(curr_alternations, index, curr_phrase_id) { @@ -101,12 +102,29 @@ }); }); this.$emit('schemataSelected', selected); - } + }, + selectSchemaPosition(schema, position) { + this.subentries.forEach(subentry => { + subentry.schemata.forEach(s => { + s.selected = false; + }); + }); + if(this.selected_schemata_position_id != position.id) { + this.selected_schemata_position_id = position.id; + this.$emit('schemaPositionSelected', this.selected_schemata_position_id); + this.$emit('schemataSelected', [schema]); + } else { + this.selected_schemata_position_id = null; + this.$emit('schemaPositionSelected', null); + this.$emit('schemataSelected', []); + } + }, + computePositionCSS(position) { + return position.id == this.selected_schemata_position_id ? 'active' : position.hover ? 'bg-highlight' : ''; + }, }, mounted() { this.img_prefix = window.STATIC_URL; - // let subentries = this.subentries; - // console.log("subentries.lenght: "+subentries.lenght); }, }; </script> @@ -123,7 +141,7 @@ @click="selectSchema(schema)" :class="(schema.selected ? 'active' : schema.hover ? 'bg-highlight' : '')" > - <table class="table m-0 table-borderless border border-secondary text-dark"> + <table id="schemata-positions-table" class="table m-0 table-borderless border border-secondary text-dark"> <tbody> <tr class="opinion-row"> <th scope="row" class="py-2 px-1 text-secondary" style="width: 3em;">Opinia</th> @@ -145,7 +163,7 @@ </tr> - <template v-if="this.frame" > + <template v-if="this.frame && this.alternations && this.alternations[this.frame.id] && this.alternations[this.frame.id][schema.id]" > <template v-for="(alternation, index) in this.alternations[this.frame.id][schema.id]"> <tr class="realisation-description"> <td class="px-1 py-2" :colspan="getSchemataPositionCnt(schema)" @@ -153,7 +171,11 @@ </tr> <tr class="phrase-types alt-0"> <th scope="row" class="py-0 px-1 text-secondary">Typy fraz</th> - <td v-for="position in schema.positions" class="px-0 py-0 border-top border-left border-secondary"> + <td v-for="position in schema.positions" class="px-0 py-0 border-top border-left border-secondary" + @click.stop="selectSchemaPosition(schema, position)" + @mouseenter="position.hover=true" + @mouseleave="position.hover=false" + :class="computePositionCSS(position)"> <template v-for="phrase in position.phrases"> <div class="phrase px-1 py-2" :class="getPhraseCss(position, alternation)"> @@ -171,7 +193,11 @@ </tr> <tr class="phrase-types alt-0"> <th scope="row" class="py-0 px-1 text-secondary">Typy fraz</th> - <td v-for="position in schema.positions" class="px-0 py-0 border-top border-left border-secondary"> + <td v-for="position in schema.positions" class="px-0 py-0 border-top border-left border-secondary" + @click.stop="selectSchemaPosition(schema, position)" + @mouseenter="position.hover=true" + @mouseleave="position.hover=false" + :class="computePositionCSS(position)"> <div v-for="phrase in position.phrases" class="phrase px-1 py-2" :class="getPhraseCss(position, null)"> <info-tooltip :text="phrase.desc" :visibleText="phrase.str"/> diff --git a/shellvalier/settings.py b/shellvalier/settings.py index 3374a76..0fff663 100644 --- a/shellvalier/settings.py +++ b/shellvalier/settings.py @@ -67,6 +67,7 @@ INSTALLED_APPS = [ 'django_vite', 'unifier.apps.UnifierConfig', 'financial_settlement.apps.FinStatementConfig', + 'freelus.apps.FreeLusConfig', ] CRISPY_TEMPLATE_PACK = 'bootstrap4' -- GitLab