diff --git a/entries/static/entries/js/components/LexicalUnitEdit.js b/entries/static/entries/js/components/LexicalUnitEdit.js index 507a781f7d0a31d61d44c2e343e05c333f7bcaa1..a8aeeb8a826e584247f6fa8659eac419e6912948 100644 --- a/entries/static/entries/js/components/LexicalUnitEdit.js +++ b/entries/static/entries/js/components/LexicalUnitEdit.js @@ -447,6 +447,7 @@ export default { data: data, timeout: 60000, success: function (response) { + show_info('Argumenty w ramie zostały zmienione'); this.loadFrame(); }.bind(this), error: function (request, errorType, errorMessage) { @@ -456,8 +457,6 @@ export default { } }, change_slowal2unified_mapping_verification(slowal_frame_id, verified) { - // check_import_status(); - // show_entry_spinners(); var data = { 'unified_frame_id': this.unified_frame.id, 'slowal_frame_id': slowal_frame_id, @@ -470,13 +469,85 @@ export default { data: data, timeout: 60000, success: function (response) { - this.loadFrame(); + show_info('Status ramy został zmieniony'); + this.loadFrame(); }.bind(this), error: function (request, errorType, errorMessage) { show_error(errorType + ' (' + errorMessage + ')'); } }); }, + slowalFrameSelected(frame) { + if (this.active_slowal_frame === frame) { + this.active_slowal_frame = null; + } else { + this.active_slowal_frame = frame; + } + }, + extract_frames_to_new_frame() { + + var existingSelect = function () { + return this.frames.map(frame => { + return `<label><input type="checkbox" name="frames" value="${frame.id}" /> ${lexical_units2dom(frame.lexical_units)}</label><br />`; + }).join(""); + }.bind(this); + + var extract_frames_to_new_frame_popup = { + state0: { + title: 'Podaj nazwę zduplikowanej ramy', + html: existingSelect, + buttons: {Anuluj: 0, Wydziel: 1}, + focus: -1, + submit: function (e, v, m, f) { + if (v == 0) { + e.preventDefault(); + $.prompt.close(); + } + if (v === 1) { + e.preventDefault(); + let frame_ids = normalizeFormData(f.frames); + var data = { 'unified_frame_id' : this.unified_frame.id, 'slowal_frame_ids' : JSON.stringify(frame_ids), + 'target_unified_frame_id': ''}; + $.ajax({ + type : 'post', + url : '/' + lang + '/unifier/extract_frames_to_new_frame/', + dataType : 'json', + data : data, + timeout : 60000, + success : function(response) { + show_info('Ramy zostały wydzielone do nowej ramy zunifikowanej.'); + this.loadFrame(); + $.prompt.close(); + }.bind(this), + error: function(request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + $.prompt.close(); + } + }); + } + }.bind(this) + } + } + $.prompt(extract_frames_to_new_frame_popup); + }, + extract_frames_to_frame(target_unified_frame_id) { + var data = { 'unified_frame_id' : this.unified_frame.id, 'slowal_frame_ids' : JSON.stringify([this.active_slowal_frame.id]), + 'target_unified_frame_id': target_unified_frame_id }; + $.ajax({ + type : 'post', + url : '/' + lang + '/unifier/extract_frames_to_new_frame/', + dataType : 'json', + data : data, + timeout : 60000, + success : function(response) { + show_info('Zaznaczona rama została przeniosiona.'); + this.loadFrame(); + }, + error: function(request, errorType, errorMessage) { + show_error(errorType + ' (' + errorMessage + ')'); + } + }); + } }, mounted() { Split(['#semantics-frames-pane', '#semantics-schemata-pane'], { @@ -596,7 +667,7 @@ export default { <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)" + @click="extract_frames_to_new_frame()" > Rozdziel </td> @@ -609,7 +680,7 @@ export default { 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)"> + @click="extract_frames_to_frame(1)"> Przerzuć </td> <td id="show-slowal-frame" style="padding: 10px 15px 10px 15px; color: #000000;"> @@ -630,7 +701,7 @@ export default { <tbody> <tr> <th scope="row"> - <div v-html="slowal_frame_html(frame)"></div> + <div v-html="slowal_frame_html(frame)" @click="slowalFrameSelected(frame)"></div> </th> <th scope="row"> <div> diff --git a/entries/static/entries/js/unification.js b/entries/static/entries/js/unification.js index b6e95745fa0636c6d7614b7665148bc394022821..be5e65ca9c6f6a43473297ccb4192391eb2590b9 100644 --- a/entries/static/entries/js/unification.js +++ b/entries/static/entries/js/unification.js @@ -108,25 +108,3 @@ function frames2lexical_units(frames) { } return lexical_units; } - -function extract_frames_to_new_frame(unified_frame_id, slowal_frame_ids, target_unified_frame_id) { - check_import_status(); - clear_entry(); - show_entry_spinners(); - var data = { 'unified_frame_id' : unified_frame_id, 'slowal_frame_ids' : JSON.stringify(slowal_frame_ids), - 'target_unified_frame_id': target_unified_frame_id }; - $.ajax({ - type : 'post', - url : '/' + lang + '/unifier/extract_frames_to_new_frame/', - dataType : 'json', - data : data, - timeout : 60000, - success : function(response) { - unified_frame_id = response.unified_frame_id; - - }, - error: function(request, errorType, errorMessage) { - show_error(errorType + ' (' + errorMessage + ')'); - } - }); -} diff --git a/unifier/models.py b/unifier/models.py index 5b0c636fb2e55d755044eab1ff11e367a8c814a9..7890f771889ac48af297d659f7e7201519919df5 100644 --- a/unifier/models.py +++ b/unifier/models.py @@ -121,6 +121,7 @@ class UnifiedRelationalSelectionalPreference(models.Model): class UnifiedFrame2SlowalFrameMapping(models.Model): verified = models.BooleanField(default=False) + removed = models.BooleanField(default=False) unified_frame = models.ForeignKey(UnifiedFrame, related_name='unified_frame_2_slowal_frame', on_delete=models.PROTECT) slowal_frame = models.OneToOneField(Frame, related_name='slowal_frame_2_unified_frame', on_delete=models.PROTECT)