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

Change title popup.

parent 24a43057
Branches
Tags
No related merge requests found
......@@ -9,6 +9,7 @@ export default {
return {
gettext: window.gettext,
unified_frame: Object,
unified_frame_title: Object,
unified_frame_arguments: [],
active_unified_frame_argument: null,
slowal_frames2selecional_preferencies_mapping: {},
......@@ -38,13 +39,14 @@ export default {
this.img_prefix = window.STATIC_URL;
this.lexical_units = frames2lexical_units(response.frames);
this.unified_frame = response.unified_frame;
this.unified_frame_title = this.unified_frame.title || lexical_units2dom(this.lexical_units)
this.unified_frame_arguments = this.unified_frame.arguments;
this.frames = response.frames;
this.lexical_units = frames2lexical_units(response.frames);
$('#lexical-unit').html(this.unified_frame.title || lexical_units2dom(this.lexical_units));
// $('#lexical-unit').html(this.unified_frame_title);
this.slowal_frames2selecional_preferencies_mapping = slowal_frames2selecional_preferencies(this.unified_frame, response.frames);
......@@ -103,7 +105,45 @@ export default {
} else {
window.addSelectivePreference(this.unified_frame, this.active_unified_frame_argument.id, this.frames);
}
}
},
changeTitle() {
let title = this.unified_frame.title != null ? this.unified_frame.title : '';
var change_title_popup = {
state0: {
title: 'Zmiana nazwy ramy',
html: '<input type="text" size="32" value="' + title + '" 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();
var title = f.title;
var data = { 'unified_frame_id' : this.unified_frame.id, 'unified_frame_title' : title };
$.ajax({
type : 'post',
url : '/' + lang + '/unifier/save_unified_frame_title/',
dataType : 'json',
data : data,
timeout : 60000,
success : function(response) {
show_info('Tytuł ramy zosał zapisany');
$.prompt.close();
this.loadFrame();
}.bind(this),
error: function(request, errorType, errorMessage) {
show_error(errorType + ' (' + errorMessage + ')');
$.prompt.close();
}
});
}
}.bind(this)
}
}
$.prompt(change_title_popup);
}
},
mounted () {
Split(['#semantics-frames-pane', '#semantics-schemata-pane'], {
......@@ -122,7 +162,7 @@ export default {
<div class="col h-100 px-1 pt-0 pb-0 overflow-auto" id="semantics-frames-pane">
<table class="table-button-menu" cellspacing="1">
<tr style="background-color: white;">
<td id="change-title" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień nazwę</td>
<td id="change-title" @click="changeTitle" style="padding: 10px 15px 10px 15px; color: #000000;">Zmień nazwę</td>
<td id="add-arg" style="padding: 10px 15px 10px 15px; color: #000000;">Dodaj argum.</td>
<td style="padding: 10px 15px 10px 15px; color: #000000;" @click="addSelectivePreference">Dodaj prefer.</td>
<td id="merge" style="padding: 10px 15px 10px 15px; color: #000000;">Scal</td>
......@@ -137,7 +177,7 @@ export default {
</tr>
</table>
<spinner />
<div class="unifiedFrame mt-3" v-bind:data-frame_id="unified_frame.id" id="lexical-unit"></div>
<div class="unifiedFrame mt-3" v-bind:data-frame_id="unified_frame.id" id="lexical-unit" v-html="unified_frame_title"></div>
<table v-if="unified_frame.id" id="unified-frame" class="table m-0 table-borderless border border-secondary text-dark">
<tbody>
<tr>
......
......@@ -13,6 +13,6 @@ urlpatterns = [
path('extract_frames_to_new_frame/', views.extract_frames_to_new_frame, name='extract_frames_to_new_frame'),
path('change_slowal2unified_fram_argument_mapping/', views.change_slowal2unified_fram_argument_mapping, name='change_slowal2unified_fram_argument_mapping'),
path('change_slowal2unified_mapping_verification/', views.change_slowal2unified_mapping_verification, name='change_slowal2unified_mapping_verification'),
path('save_unified_frame_title/', views.save_unified_frame_title, name='save_unified_frame_title'),
]
......@@ -266,3 +266,17 @@ def change_slowal2unified_mapping_verification(request):
unifiedFrame2SlowalFrameMapping.save()
return JsonResponse({})
return JsonResponse({})
@ajax_required
@transaction.atomic
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({})
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