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

Role type selection.

parent 8caf4974
No related branches found
No related tags found
No related merge requests found
......@@ -265,7 +265,14 @@ Object.assign(LexicalUnitEdit, {
let attributesHTML = role_attributes.map(attribute => {
return `<label><input type="radio" name="attribute" value="${attribute.id}" /> ${attribute.attribute}</label><br />`;
}).join("");
return '<div class="row"><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>';
const roleTypeHTML = ['role', 'modifier'].map(type => {
return `<label><input type="radio" name="role_type" value="${type}" /> ${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>';
}.bind(this);
let change_role_popup = {
......@@ -343,13 +350,15 @@ Object.assign(LexicalUnitEdit, {
e.preventDefault();
var role_id = normalizeFormData(f.role)[0];
var role_type = normalizeFormData(f.role_type)[0];
if (role_id != null) {
if (role_id != null && role_type != null) {
var attribute_id = normalizeFormData(f.attribute)[0];
var data = {
'unified_frame_id': this.unified_frame.id,
'complement_id': this.active_unified_frame_argument.id,
'role_type': role_type,
'role_id': role_id,
'attribute_id': attribute_id
};
......@@ -369,7 +378,7 @@ Object.assign(LexicalUnitEdit, {
}
});
} else {
alert(gettext("Musisz wybrać pzynajmniej rolę."));
alert(gettext("Musisz wybrać typ oraz rolę."));
}
}
}.bind(this)
......
......@@ -6,7 +6,7 @@ from django.http import JsonResponse
from common.decorators import ajax_required
from entries.polish_strings import EXAMPLE_SOURCE, EXAMPLE_OPINION
from entries.views import get_scroller_params, get_alternations, get_prefs_list, schema2dict, frame2dict
from semantics.models import Frame, ArgumentRole, SemanticRole, RoleAttribute
from semantics.models import Frame, ArgumentRole, SemanticRole, RoleAttribute, RoleType
from syntax.models import Schema
from unifier.models import UnifiedFrameArgument, UnifiedRelationalSelectionalPreference, UnifiedFrame, \
UnifiedFrame2SlowalFrameMapping, UnifiedFrameArgumentSlowalFrameMapping
......@@ -321,6 +321,7 @@ def save_new_role(request):
unified_frame_id = request.POST['unified_frame_id']
complement_id = request.POST['complement_id']
role_id = request.POST['role_id']
role_type = request.POST['role_type']
attribute_id = request.POST.get('attribute_id', None)
argumentRole = ArgumentRole.objects.filter(role_id=role_id, attribute_id=attribute_id).first()
......@@ -330,6 +331,7 @@ def save_new_role(request):
unifiedFrameArgument = UnifiedFrameArgument.objects.get(unified_frame_id=unified_frame_id, id=complement_id)
unifiedFrameArgument.role = argumentRole
unifiedFrameArgument.role_type = RoleType.objects.get(type=role_type)
unifiedFrameArgument.save()
return JsonResponse({})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment