From 202ba334a682f14015d3a6d06f330c1d2f378219 Mon Sep 17 00:00:00 2001
From: dcz <dcz@ipipan.waw.pl>
Date: Wed, 13 Jul 2022 21:07:43 +0200
Subject: [PATCH] Slowal frame argument mapping change bugfix.

---
 .../entries/js/components/LexicalUnitEdit.js  | 24 ++++---------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js
index a24251f..fd19ca0 100644
--- a/entries/static/entries/js/components/LexicalUnitEdit.js
+++ b/entries/static/entries/js/components/LexicalUnitEdit.js
@@ -581,26 +581,12 @@ Object.assign(LexicalUnitEdit, {
         }
       }
     },
-    change_slowal2unified_frame_argument_mapping(slowal_frame_id) {
-      const argument_ids = [];
-      $('.argument.active').each(function() {
-        const id = $(this).data('argument_id').split('-')[1];
-        if(id.startsWith('_')) {
-          id = -parseInt(id.split('_')[1])
-        } else {
-          id = parseInt(id)
-        }
-        argument_ids.push(id);
-      });
-      let choosed_slowal_frame_id = null;
-      $('.frame.active').each(function() {
-        choosed_slowal_frame_id = $(this).data('frame_id');
-      });
-      if(choosed_slowal_frame_id == slowal_frame_id && argument_ids.length == 2) {
+    change_slowal2unified_frame_argument_mapping(slowal_frame) {
+      if(slowal_frame === this.active_slowal_frame && this.selectedFrameArguments && this.selectedFrameArguments.length == 2) {
         const data = {
           'unified_frame_id': this.unified_frame.id,
-          'slowal_frame_id': choosed_slowal_frame_id,
-          'slowal_frame_selected_arguments': JSON.stringify(argument_ids)
+          'slowal_frame_id': slowal_frame.id,
+          'slowal_frame_selected_arguments': JSON.stringify(this.selectedFrameArguments.map(arg => arg.argument_id))
         };
         $.ajax({
           type: 'post',
@@ -1036,7 +1022,7 @@ Object.assign(LexicalUnitEdit, {
                       <br><br>
                       <button v-if="!isFrameVerified(frame)"
                         class="btn btn-sm btn-dark" role="button" 
-                        @click="change_slowal2unified_frame_argument_mapping(frame.id)"
+                        @click="change_slowal2unified_frame_argument_mapping(frame)"
                         >Z</button>
                     </div>
                   </th>
-- 
GitLab