From 03e23b19116f887ec85cbb5b55d51c56fbc0dc60 Mon Sep 17 00:00:00 2001
From: dcz2 <dcz@ipipan.waw.pl>
Date: Mon, 20 Jun 2022 22:29:04 +0200
Subject: [PATCH] Improve the edit view

---
 .../entries/js/components/InfoTooltip.js      |  26 ++
 .../js/components/LexicalUnitDisplay.js       |   5 +-
 .../entries/js/components/LexicalUnitEdit.js  | 373 ++++++++----------
 entries/static/entries/js/components/main.js  |   5 +-
 .../entries/js/selectional_preference.js      |  37 +-
 .../unification_lexical_unit_display.html     |   2 +-
 6 files changed, 212 insertions(+), 236 deletions(-)
 create mode 100644 entries/static/entries/js/components/InfoTooltip.js

diff --git a/entries/static/entries/js/components/InfoTooltip.js b/entries/static/entries/js/components/InfoTooltip.js
new file mode 100644
index 0000000..01f3bcc
--- /dev/null
+++ b/entries/static/entries/js/components/InfoTooltip.js
@@ -0,0 +1,26 @@
+export default {
+  props: { text: String },
+  data () {
+    return {
+      iconUrl: window.STATIC_URL + 'common/img/info.svg'
+    }
+  },
+  computed: {
+    quotedText () {
+      return this.text.replace(/"/g, '&quot;');
+    }
+  },
+  created () {
+    $("[data-toggle='tooltip']").tooltip();
+  },
+  template: `
+    <span
+      data-toggle="tooltip"
+      data-placement="bottom"
+      data-html="true"
+      :title="quotedText"
+    >
+      <img :src="iconUrl" alt="info" width="14" height="14" />
+    </span>
+  `
+}
diff --git a/entries/static/entries/js/components/LexicalUnitDisplay.js b/entries/static/entries/js/components/LexicalUnitDisplay.js
index b4b55a4..7559c61 100644
--- a/entries/static/entries/js/components/LexicalUnitDisplay.js
+++ b/entries/static/entries/js/components/LexicalUnitDisplay.js
@@ -1,7 +1,7 @@
 import Spinner from './Spinner.js';
 
 export default {
-  components: {Spinner},
+  components: { Spinner },
   props: {
     entryId: Number,
     lexicalUnitId: Number
@@ -93,5 +93,8 @@ export default {
       </div>
       <div id="lexical-unit-notes"></div>
     </div>
+    <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-schemata-pane">
+      <div id="semantics-schemata"></div>
+    </div>
   `
 }
diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js
index a81b1e8..611e808 100644
--- a/entries/static/entries/js/components/LexicalUnitEdit.js
+++ b/entries/static/entries/js/components/LexicalUnitEdit.js
@@ -1,3 +1,5 @@
+import InfoTooltip from "./InfoTooltip.js";
+import Spinner from "./Spinner.js";
 
 export default {
   props: {
@@ -5,47 +7,44 @@ export default {
   },
   data() {
     return {
-      count: 0,
+      gettext: window.gettext,
       unified_frame: Object,
       unified_frame_arguments: [],
-      title_str: Object,
+      active_unified_frame_argument: null,
       slowal_frames2selecional_preferencies_mapping: {},
       lexical_units: [],
-      img_prefix: String
+      img_prefix: String,
+      frames: []
     }
   },
+  components: { InfoTooltip, Spinner },
+  emits: ['goToDisplay', 'refresh'],
   watch: {
-    unifiedFrameId: function() {
+    unifiedFrameId: function () {
       this.loadFrame();
     }
   },
   methods: {
-    async loadFrame () {
+    async loadFrame() {
       try {
-        var data = { 'unified_frame_id' : this.unifiedFrameId};
+        var data = {'unified_frame_id': this.unifiedFrameId};
         $.ajax({
-          type     : 'post',
-          url      : '/' + lang + '/unifier/get_unified_frame/',
-          dataType : 'json',
-          data     : data,
-          timeout  : 60000,
-          success  : function(response) {
+          type: 'post',
+          url: '/' + lang + '/unifier/get_unified_frame/',
+          dataType: 'json',
+          data: data,
+          timeout: 60000,
+          success: function (response) {
 
             this.img_prefix = window.STATIC_URL;
 
             this.unified_frame = response.unified_frame;
             this.unified_frame_arguments = this.unified_frame.arguments;
-
-            this.count = this.count + 100;
+            this.frames = response.frames;
 
             this.lexical_units = frames2lexical_units(response.frames);
 
-            this.title_str = this.unified_frame.title;
-            if(this.title_str == null) {
-              //title as list of lexical units from all slowal frames
-              var lexical_units_html = lexical_units2dom(this.lexical_units);
-              this.title_str = lexical_units_html;
-            }
+            $('#lexical-unit').html(this.unified_frame.title || lexical_units2dom(this.lexical_units));
 
             this.slowal_frames2selecional_preferencies_mapping = slowal_frames2selecional_preferencies(this.unified_frame, response.frames);
 
@@ -62,7 +61,7 @@ export default {
               curr_examples_by_id[curr_examples[i].id] = curr_examples[i];
             }
             // show_syntax(response.subentries);
-            show_unified_frame(response.unified_frame, response.frames)
+            // show_unified_frame(response.unified_frame, response.frames)
             show_unified_frame_lexical_units(response.frames)
             fulfill_slowal_frames_arguments_with_empty_elems(response.unified_frame, response.frames)
             show_semantics_unified_view(response.frames, response.subentries);
@@ -72,220 +71,174 @@ export default {
             activate_tooltips($('#semantics-frames-pane'));
             update_last_visited(response.last_visited);
           }.bind(this),
-          error: function(request, errorType, errorMessage) {
+          error: function (request, errorType, errorMessage) {
             show_error(errorType + ' (' + errorMessage + ')');
           }
         });
 
-      }
-      catch (error) {
+      } catch (error) {
         console.log(error);
       }
+    },
+    unifiedFrameArgumentSelected (argument) {
+      if (this.active_unified_frame_argument === argument) {
+        this.active_unified_frame_argument = null;
+      } else {
+        this.active_unified_frame_argument = argument;
+      }
+    },
+    addSelectivePreference () {
+      if (!this.active_unified_frame_argument) {
+        alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję."));
+      } else {
+        window.addSelectivePreference(this.unified_frame, this.active_unified_frame_argument.id, this.frames);
+      }
     }
   },
-  created () {
+  created() {
     this.loadFrame();
   },
   template: `
-<!--{% load i18n %}-->
-
-    <div class="col h-100 w-100 p-0 tab-pane show active" id="semantics" role="tabpanel" aria-labelledby="semantics-tab">
-        <div class="row m-0 p-0" id="semantics-top-pane">
-            <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-frames-pane">
-                <table class="table-button-menu" cellspacing="1">
-                    <tr style="background-color: white;">
-                        <td id="change-title" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Zmień nazwę
-                        </td>
-                        <td id="add-arg" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Dodaj argum.
-                        </td>
-                        <td id="add-pref" style="padding: 10px 15px 10px 15px; color: #000000;"
-                            onclick="addSelectivePreference()">
-                            Dodaj prefer.
-                        </td>
-                        <td id="merge" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Scal
-                        </td>
-                        <td id="ready" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Gotowe
-                        </td>
-                    </tr>
-                    <tr style="background-color: white;">
-                        <td id="change-role" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Zmień rolę
-                        </td>
-                        <td id="remove-arg" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Usuń argum.
-                        </td>
-                        <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Zamień okna
-                        </td>
-                        <td id="duplicates" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Duplikuj
-                        </td>
-                        <td id="save-changes" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Zapisz
-                        </td>
-                    </tr>
-                </table>
-                <br>
-                <div class="unifiedFrame mb-3" data-frame_id="3"><p class="mb-1"><span class="lexical-unit">{{ title_str }}</span></p>
-    <table class="table m-0 table-borderless border border-secondary text-dark">
+    <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-frames-pane">
+      <table class="table-button-menu" cellspacing="1">
+        <tr style="background-color: white;">
+          <td id="change-title" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień nazwę</td>
+          <td id="add-arg" style="padding: 10px 15px 10px 15px; color: #000000;">Dodaj argum.</td>
+          <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="addSelectivePreference">Dodaj prefer.</td>
+          <td id="merge" style="padding: 10px 15px 10px 15px; color: #000000;">Scal</td>
+          <td style="padding: 10px 15px 10px 15px; color: #000000;" @click="$emit('goToDisplay')">Gotowe</td>
+        </tr>
+        <tr style="background-color: white;">
+          <td id="change-role" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień rolę</td>
+          <td id="remove-arg" style="padding: 10px 15px 10px 15px; color: #000000;">Usuń argum.</td>
+          <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;">Zamień okna</td>
+          <td id="duplicates" style="padding: 10px 15px 10px 15px; color: #000000;">Duplikuj</td>
+          <td id="save-changes" style="padding: 10px 15px 10px 15px; color: #000000;">Zapisz</td>
+        </tr>
+      </table>
+      <spinner />
+      <div class="unifiedFrame mt-3" v-bind:data-frame_id="unified_frame.id" id="lexical-unit"></div>
+      <table v-if="unified_frame.id" id="unified-frame" class="table m-0 table-borderless border border-secondary text-dark">
         <tbody>
-        <tr>
+          <tr>
             <th scope="row" class="py-2 px-1 text-secondary">Role</th>
-            <td class="argument py-2 px-1 border-top border-left border-secondary role"
-                    v-for="argument in unified_frame_arguments"
-                    :key="argument.id"
-            >{{ argument.role_type }}
-                <ul>
-                  <li
-                          v-for='proposed_role in argument.proposed_roles'
-                  >
-                      {{ proposed_role.role }}
-                  </li>
-                </ul>
+            <td
+              class="argument py-2 px-1 border-top border-left border-secondary role"
+              :class="argument == active_unified_frame_argument && 'active'"
+              v-for="argument in unified_frame_arguments"
+              :key="argument.id"
+              @click="unifiedFrameArgumentSelected(argument)"
+            >
+              {{ argument.role_type }}
+              <ul>
+                <li v-for="proposed_role in argument.proposed_roles">
+                  {{ proposed_role.role }}
+                </li>
+              </ul>
             </td>
-        </tr>
-        <tr>
+          </tr>
+          <tr>
             <th scope="row" class="py-0 px-1 text-secondary">Selectional preferences</th>
-
             <td class="preferences py-0 px-0 border-top border-left border-secondary"
                 v-for='argument in unified_frame_arguments'
                 :key='argument.id'
             >
-            <ul>
-                <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>
+              <ul>
+                <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>
-                <ul>
-                <li
-                        v-for='preference in slowal_frames2selecional_preferencies_mapping[argument.id]'
-                >
-                    <div v-if="preference.url != null" class="preference py-2 px-1"><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.str }}</div>
+              </ul>
+              <ul>
+                <li v-for="preference in slowal_frames2selecional_preferencies_mapping[argument.id]">
+                  <span v-if="preference.url != null" class="preference py-2 px-1">
+                    <a class="synset-plwn" v-bind:href="preference.url" target="_blank">{{ preference.str }}</a>
+                  </span>
+                  <span v-else class="preference py-2 px-1">{{ preference.str }}</span>
+                  <info-tooltip v-if="preference.info" :text="preference.info" />
                 </li>
-                </ul>
+              </ul>
             </td>
-        </tr>
+          </tr>
         </tbody>
-    </table>
-</div>
-
-
-<div class="frame mb-3">
-    <table class="table m-0 table-borderless 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">Opinion</th>
-        </tr>
-
-        <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">
+      </table>
+
+      <div v-if="unified_frame.id" class="frame mt-3 mb-3">
+        <table class="table m-0 table-borderless 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">Opinion</th>
+            </tr>
+            <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>
+              </td>
+            </tr>
+          </tbody>
+        </table>
+      </div>
+
+      <table v-if="unified_frame.id" class="table-button-menu" cellspacing="1">
+        <tr style="background-color: white;">
+          <td id="wrong-frame" style="padding: 10px 15px 10px 15px; color: #000000;">Błędna</td>
+          <td
+            style="padding: 10px 15px 10px 15px; color: #000000;"
+            onclick="extract_frames_to_new_frame(1, [104274,104238], null)"
+          >
+            Rozdziel
+          </td>
+          <td id="hide-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">Ukryj</td>
+          <td id="ready-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">Gotowe</td>
+          <td id="filter-slowal-frames" style="padding: 10px 15px 10px 15px; color: #000000;">Filtruj</td>
         </tr>
-        </tbody>
-    </table>
-</div>
-
-                
-<!--                <div id="unified-frame"></div>-->
-<!--                <div id="unified-frame-lexical-units"></div>-->
-                <br>
-                <table class="table-button-menu" cellspacing="1">
-                    <tr style="background-color: white;">
-                        <td id="wrong-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Błędna
-                        </td>
-                        <td id="extract-frame" style="padding: 10px 15px 10px 15px; color: #000000;"
-                            onclick="extract_frames_to_new_frame(1, [104274,104238], null)">
-                            Rozdziel
-                        </td>
-                        <td id="hide-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Ukryj
-                        </td>
-                        <td id="ready-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Gotowe
-                        </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;">
-                            NiepasujÄ…ca
-                        </td>
-                        <td id="move-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;"
-                            onclick="extract_frames_to_new_frame(3, [104274], 1)">
-                            Przerzuć
-                        </td>
-                        <td id="show-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Pokaż
-                        </td>
-                        <td id="reollback-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
-                            Przywróć
-                        </td>
-                        <td id="empty" style="padding: 10px 15px 10px 15px; color: #000000;">
-
-                        </td>
-                    </tr>
-                </table>
-                <br>
-                <div id="semantics-frames"></div>
-            </div>
-            <div class="gutter gutter-horizontal" style="width: 4px;"></div>
-            <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-schemata-pane">
-                <ul class="nav nav-pills nav-justified p-1" id="entryTabs" role="tablist">
-                    <li class="nav-item mr-1">
-                        <a class="btn btn-sm btn-outline-dark nav-link active" id="unified-frame-semantics-tab" data-toggle="tab" href="#semantics" role="tab" aria-controls="semantics" aria-selected="true">
-                            {% trans "Schematy" %}
-                        </a>
-                    </li>
-                    <li class="nav-item mr-1">
-                        <a class="btn btn-sm btn-outline-dark nav-link" id="unified-frame-view2-tab" data-toggle="tab" href="#syntax" role="tab" aria-controls="syntax" aria-selected="false">
-                            {% trans "PodglÄ…d ram" %}
-                        </a>
-                    </li>
-                    <li class="nav-item mr-0">
-                        <a class="btn btn-sm btn-outline-dark nav-link" id="unified-frame-notes-tab" data-toggle="tab" href="#examples" role="tab" aria-controls="examples" aria-selected="false">
-                            {% trans "Notatki" %}
-                        </a>
-                    </li>
-                </ul>
-                <div id="semantics-schemata"></div>
-            </div>
-        </div>
-        <div class="row m-0 p-0 overflow-auto" id="semantics-examples-pane">
-            <table id="semantics-examples" class="table table-sm table-hover">
-                <thead>
-                <tr>
-                    <th scope="col">{% trans "Przykład" %}<i id="examples-argument"></i><i id="examples-lu"></i><i id="examples-schema"></i></th>
-                    <th scope="col">{% trans "Źródło" %}</th>
-                    <th scope="col">{% trans "Opinia" %}</th>
-                </tr>
-                </thead>
-                <tbody id="semantics-examples-list">
-                </tbody>
-            </table>
-            <p class="mx-1 my-1" id="semantics-no-examples">{% trans "Brak przykładów" %}</p>
-        </div>
+        <tr style="background-color: white;">
+          <td id="inccorect-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
+              NiepasujÄ…ca
+          </td>
+          <td id="move-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;"
+              onclick="extract_frames_to_new_frame(3, [104274], 1)">
+              Przerzuć
+          </td>
+          <td id="show-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
+              Pokaż
+          </td>
+          <td id="reollback-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;">
+              Przywróć
+          </td>
+          <td id="empty" style="padding: 10px 15px 10px 15px; color: #000000;"></td>
+        </tr>
+      </table>
+      <div id="semantics-frames"></div>
     </div>
-
-
-`
+    <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-schemata-pane">
+      <ul class="nav nav-pills nav-justified p-1" id="entryTabs" role="tablist">
+        <li class="nav-item mr-1">
+            <a class="btn btn-sm btn-outline-dark nav-link active" id="unified-frame-semantics-tab" data-toggle="tab" href="#semantics" role="tab" aria-controls="semantics" aria-selected="true">
+                {{ gettext('Schematy') }}
+            </a>
+        </li>
+        <li class="nav-item mr-1">
+            <a class="btn btn-sm btn-outline-dark nav-link" id="unified-frame-view2-tab" data-toggle="tab" href="#syntax" role="tab" aria-controls="syntax" aria-selected="false">
+                {{ gettext('PodglÄ…d ram') }}
+            </a>
+        </li>
+        <li class="nav-item mr-0">
+            <a class="btn btn-sm btn-outline-dark nav-link" id="unified-frame-notes-tab" data-toggle="tab" href="#examples" role="tab" aria-controls="examples" aria-selected="false">
+                {{ gettext('Notatki') }}
+            </a>
+        </li>
+      </ul>
+      <div id="semantics-schemata"></div>
+    </div>
+  `
 }
diff --git a/entries/static/entries/js/components/main.js b/entries/static/entries/js/components/main.js
index 0b9e964..27b5abd 100644
--- a/entries/static/entries/js/components/main.js
+++ b/entries/static/entries/js/components/main.js
@@ -38,7 +38,7 @@ export default {
     }
   },
   template: `
-    <div v-if="key" :key="key">
+    <div v-if="key" :key="key" class="row m-0 p-0 overflow-auto" id="semantics-top-pane">
       <lexical-unit-display
         v-if="lexicalUnitId && !isEdit"
         :entryId="entryId"
@@ -52,8 +52,5 @@ export default {
         @go-to-display="goToDisplay"
       />
     </div>
-    <div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-schemata-pane">
-      <div id="semantics-schemata"></div>
-    </div>
   `
 }
diff --git a/entries/static/entries/js/selectional_preference.js b/entries/static/entries/js/selectional_preference.js
index a8ef088..acb0bf2 100644
--- a/entries/static/entries/js/selectional_preference.js
+++ b/entries/static/entries/js/selectional_preference.js
@@ -3,16 +3,6 @@ var relations = [];
 var synsets = [];
 var change = false;
 
-function existingSelect() {
-    let availablePreferencies = slowal_frames2selecional_preferencies(unified_frame_active_frame, unified_view_frame_content)[unified_frame_active_argument_id];
-    if (!availablePreferencies) {
-        return gettext('Brak preferencji selekcyjnych do wyboru.')
-    }
-    return availablePreferencies.map(preference => {
-        return `<label><input type="checkbox" name="existing" value="${preference.type}:${preference.id}" /> ${preference.str}</label><br />`;
-    }).join("");
-}
-
 function predefinedSelect() {
     var display = "";
 
@@ -55,8 +45,8 @@ function argumentSelect(frame, complement_id) {
 
     var i;
     for (i = 0; i < frame.arguments.length; i++) {
-        var local_complement_id = parseInt(frame.arguments[i].id.split('-')[1]);
-        if (local_complement_id != complement_id) {
+        var local_complement_id = frame.arguments[i].argument_id;
+        if (local_complement_id && local_complement_id !== String(complement_id)) {
             // var list = frame_content[unified_frame_id].display.roles[i].argument;
             //
             // var text = [];
@@ -129,15 +119,12 @@ function attachPlWNContextAutocomplete() {
     });
 }
 
-function addSelectivePreference() {
-    if (!unified_frame_active_argument_id) {
-        alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję."));
-        return;
-    }
-    addSelectivePreferenceBase(unified_frame_active_frame, unified_view_frame_content[0], unified_frame_active_argument_id);
+function addSelectivePreference(unified_frame, unified_frame_active_argument_id, frames) {
+    if (!unified_frame_active_argument_id) return;
+    addSelectivePreferenceBase(unified_frame, frames, unified_frame_active_argument_id);
 }
 
-function addSelectivePreferenceBase(unified_frame, frame, complement_id) {
+function addSelectivePreferenceBase(unified_frame, frames, complement_id) {
     let unified_frame_id = unified_frame.id;
 
     var submitSynsetSelection = function(e,v,m,f){
@@ -157,6 +144,16 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) {
         }
     }
 
+    var existingSelect = function () {
+        let availablePreferencies = slowal_frames2selecional_preferencies(unified_frame, frames)[complement_id];
+        if (!availablePreferencies) {
+            return gettext('Brak preferencji selekcyjnych do wyboru.')
+        }
+        return availablePreferencies.map(preference => {
+            return `<label><input type="checkbox" name="existing" value="${preference.type}:${preference.id}" /> ${preference.str}</label><br />`;
+        }).join("");
+    };
+
     var select_preference = {
         state0: {
             title: 'Typ preferencji selekcyjnej',
@@ -233,7 +230,7 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) {
         },
         state3: {
             title: 'Wybierz relacjÄ™ i argument',
-            html: relationArgument(frame, complement_id),
+            html: relationArgument(unified_frame, complement_id),
             buttons: { Anuluj: -1, Zatwierdź: 1 },
             focus: 1,
             submit: function(e,v,m,f){
diff --git a/entries/templates/unification_lexical_unit_display.html b/entries/templates/unification_lexical_unit_display.html
index fbf28ae..1a4ebf3 100644
--- a/entries/templates/unification_lexical_unit_display.html
+++ b/entries/templates/unification_lexical_unit_display.html
@@ -6,7 +6,7 @@
     <div class="col h-100 w-100 p-0 tab-pane show active" id="semantics" role="tabpanel" aria-labelledby="semantics-tab">
         <!-- Vue.js app -->
         <script src="https://unpkg.com/vue@3"></script>
-        <div class="row m-0 p-0 overflow-auto" id="semantics-top-pane"></div>
+        <div id="semantics-top-pane" class="overflow-auto"></div>
         <script type="module" src="{% static 'entries/js/unification_index.js' %}"></script>
         <!-- Vue.js app -->
 
-- 
GitLab