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

New unified frame require title.

parent 269520f0
No related branches found
No related tags found
No related merge requests found
......@@ -31,11 +31,32 @@ export default {
goToEdit (unifiedFrameId, entryId, lexicalUnitId) {
window.location = `/${lang}/entries/unification?unified_frame_id=${unifiedFrameId}&entry_id=${entryId}&lexical_unit_id=${lexicalUnitId}`;
},
hasWhiteSpace(s) {
return /\s/g.test(s);
},
take () {
const create_title_popup = {
state0: {
title: 'Wprowadź nazwę ramy',
html: '<input type="text" size="32" name="title" />',
buttons: {Anuluj: 0, Zapisz: 1},
focus: -1,
submit: function (e, v, m, f) {
if (v == 0) {
$.prompt.close();
}
if (v === 1) {
e.preventDefault();
const title = f.title;
if (this.hasWhiteSpace(title) || title.length === 0) {
alert(gettext("Nazwa zunifikowanej ramy nie może być pusta oraz nie może zawierać białych znaków."));
} else {
const data = {'lu_id': this.lexicalUnitId, 'unified_frame_title': title};
$.ajax({
type : 'post',
url : `/${lang}/unifier/frame_assign/${this.lexicalUnitId}/`,
url : `/${lang}/unifier/frame_assign/`,
dataType : 'json',
data: data,
timeout : 60000,
success: function (response) {
show_info('Rama została stworzona oraz przypisana użytkownikowi.');
......@@ -45,6 +66,12 @@ export default {
show_error(errorType + ' (' + errorMessage + ')');
}
});
}
}
}.bind(this)
}
}
$.prompt(create_title_popup);
},
statusChange(api_method) {
$.ajax({
......
......@@ -22,7 +22,7 @@ urlpatterns = [
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'),
path('build_unified_frame_xml/', views.build_unified_frame_xml, name='build_unified_frame_xml'),
path('frame_assign/<int:lu_id>/', views.frame_assign, name='frame_assign'),
path('frame_assign/', views.frame_assign, name='frame_assign'),
path('delete_unified_frame/<int:unified_frame_id>/', views.delete_unified_frame, name='delete_unified_frame'),
]
......@@ -223,6 +223,7 @@ def get_unified_frame(request):
return JsonResponse({})
@ajax_required
@transaction.atomic
def extract_frames_to_new_frame(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
......@@ -239,6 +240,7 @@ def extract_frames_to_new_frame(request):
return JsonResponse({})
@ajax_required
@transaction.atomic
def remove_selectional_preference(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
......@@ -255,6 +257,7 @@ def remove_selectional_preference(request):
return JsonResponse({})
@ajax_required
@transaction.atomic
def duplicate_unified_frame(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
......@@ -266,6 +269,7 @@ def duplicate_unified_frame(request):
return JsonResponse({})
@ajax_required
@transaction.atomic
def change_slowal2unified_fram_argument_mapping(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
......@@ -302,6 +306,7 @@ def change_slowal2unified_fram_argument_mapping(request):
return JsonResponse({})
@ajax_required
@transaction.atomic
def change_slowal_frame_status(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
......@@ -454,7 +459,25 @@ def build_unified_frame_xml(request):
@ajax_required
@transaction.atomic
def frame_assign(request, lu_id):
def save_unified_frame_title(request):
if request.method == 'POST':
unified_frame_id = request.POST['unified_frame_id']
unified_frame_title = request.POST['unified_frame_title']
unifiedFrame = UnifiedFrame.objects.get(id=unified_frame_id)
if unifiedFrame:
unifiedFrame.title = unified_frame_title
unifiedFrame.save()
return JsonResponse({})
@ajax_required
@transaction.atomic
def frame_assign(request):
if request.method == 'POST':
lu_id = request.POST['lu_id']
unified_frame_title = request.POST['unified_frame_title']
unified_frame_pk = create_unified_frame(lu_id)
......@@ -462,6 +485,8 @@ def frame_assign(request, lu_id):
UnifiedFrame.objects,
pk=unified_frame_pk,
)
unifiedFrame.title = unified_frame_title
unifiedFrame.save()
slowal_frames = [connection.slowal_frame for connection in unifiedFrame.unified_frame_2_slowal_frame.all()]
......@@ -475,6 +500,7 @@ def frame_assign(request, lu_id):
}
return JsonResponse(ret)
return JsonResponse({})
def removeUnifiedFrameMappingsAndAssigments(unified_frame_id):
#odpianie z ramy zunifikowanej
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment