Skip to content
Snippets Groups Projects
Commit fbf55b9a authored by dcz's avatar dcz
Browse files

Removeing preference.

parent ce8faaf3
Branches
Tags
No related merge requests found
...@@ -192,7 +192,7 @@ Object.assign(LexicalUnitEdit, { ...@@ -192,7 +192,7 @@ Object.assign(LexicalUnitEdit, {
show_info(gettext('Kliknij, aby wybrać kolumnę do edycji.')); show_info(gettext('Kliknij, aby wybrać kolumnę do edycji.'));
} }
}, },
addSelectivePreference() { addSelectivePreference () {
if (!this.active_unified_frame_argument) { if (!this.active_unified_frame_argument) {
alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję.")); alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję."));
} else { } else {
...@@ -201,6 +201,58 @@ Object.assign(LexicalUnitEdit, { ...@@ -201,6 +201,58 @@ Object.assign(LexicalUnitEdit, {
}.bind(this)); }.bind(this));
} }
}, },
removeSelectionalPreference () {
if (!this.active_unified_frame_argument) {
alert(gettext("Zaznacz argument, do którego chcesz dodać preferencję."));
} else {
var existingPreferencies = function () {
return this.active_unified_frame_argument.preferences.map(preference => {
return `<label><input type="checkbox" name="preference" value="${preference.id}" /> ${preference.str}</label><br />`;
}).join("");
}.bind(this);
var remove_preference_popup = {
state0: {
title: 'Wybierz preferencje do usunięcia',
html: existingPreferencies,
buttons: {Anuluj: 0, Usuń: 1},
focus: -1,
submit: function (e, v, m, f) {
if (v == 0) {
e.preventDefault();
$.prompt.close();
}
if (v === 1) {
e.preventDefault();
let preference_ids = normalizeFormData(f.preference);
var data = {
'unified_frame_id': this.unified_frame.id,
'argument_id': this.active_unified_frame_argument.id,
'preference_ids': JSON.stringify(preference_ids)
};
$.ajax({
type: 'post',
url: '/' + lang + '/unifier/remove_selectional_preference/',
dataType: 'json',
data: data,
timeout: 60000,
success: function (response) {
show_info('Wybrane preferencje zostału usunięte.');
this.loadFrame();
$.prompt.close();
}.bind(this),
error: function (request, errorType, errorMessage) {
show_error(errorType + ' (' + errorMessage + ')');
$.prompt.close();
}
});
}
}.bind(this)
}
}
$.prompt(remove_preference_popup);
}
},
changeTitle() { changeTitle() {
let title = this.unified_frame.title != null ? this.unified_frame.title : ''; let title = this.unified_frame.title != null ? this.unified_frame.title : '';
var change_title_popup = { var change_title_popup = {
...@@ -755,6 +807,7 @@ Object.assign(LexicalUnitEdit, { ...@@ -755,6 +807,7 @@ Object.assign(LexicalUnitEdit, {
<tr style="background-color: white;"> <tr style="background-color: white;">
<td id="change-role" @click="changeRole" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień rolę</td> <td id="change-role" @click="changeRole" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień rolę</td>
<td id="remove-arg" @click="removeArgument" style="padding: 10px 15px 10px 15px; color: #000000;">Usuń argum.</td> <td id="remove-arg" @click="removeArgument" style="padding: 10px 15px 10px 15px; color: #000000;">Usuń argum.</td>
<td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="removeSelectionalPreference">Usuń prefer.</td>
<td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="swapUnifiedFrames">Zamień okna</td> <td id="change-windows" style="padding: 10px 15px 10px 15px; color: #000000;" @click="swapUnifiedFrames">Zamień okna</td>
<td id="duplicates" @click="duplicate" style="padding: 10px 15px 10px 15px; color: #000000;">Duplikuj</td> <td id="duplicates" @click="duplicate" style="padding: 10px 15px 10px 15px; color: #000000;">Duplikuj</td>
</tr> </tr>
......
...@@ -20,5 +20,6 @@ urlpatterns = [ ...@@ -20,5 +20,6 @@ urlpatterns = [
path('remove_argument/', views.remove_argument, name='remove_argument'), path('remove_argument/', views.remove_argument, name='remove_argument'),
path('duplicate_unified_frame/', views.duplicate_unified_frame, name='duplicate_unified_frame'), path('duplicate_unified_frame/', views.duplicate_unified_frame, name='duplicate_unified_frame'),
path('change_unified_frame_status_to_ready/', views.change_unified_frame_status_to_ready, name='change_unified_frame_status_to_ready'), path('change_unified_frame_status_to_ready/', views.change_unified_frame_status_to_ready, name='change_unified_frame_status_to_ready'),
path('remove_selectional_preference/', views.remove_selectional_preference, name='remove_selectional_preference'),
] ]
...@@ -227,6 +227,22 @@ def extract_frames_to_new_frame(request): ...@@ -227,6 +227,22 @@ def extract_frames_to_new_frame(request):
return JsonResponse(get_unified_frame_json(new_frame_fullfiled_and_saved, request)) return JsonResponse(get_unified_frame_json(new_frame_fullfiled_and_saved, request))
return JsonResponse({}) return JsonResponse({})
@ajax_required
def remove_selectional_preference(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
argument_id = request.POST['argument_id']
preference_ids = json.loads(request.POST['preference_ids'])
unified_frame_argument = UnifiedFrameArgument.objects.get(id=argument_id, unified_frame=unified_frame_id)
unified_frame_argument.predefined.set(unified_frame_argument.predefined.exclude(id__in=preference_ids))
unified_frame_argument.synsets.set(unified_frame_argument.synsets.exclude(id__in=preference_ids))
unified_frame_argument.relations.set(unified_frame_argument.relations.exclude(id__in=preference_ids))
unified_frame_argument.save()
return JsonResponse({})
return JsonResponse({})
@ajax_required @ajax_required
def duplicate_unified_frame(request): def duplicate_unified_frame(request):
if request.method == 'POST': if request.method == 'POST':
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment