Skip to content
Snippets Groups Projects
Commit 815e6b04 authored by dcz2's avatar dcz2 Committed by Piotr Bieńkowski
Browse files

Existing preferences popup tab

parent 6eff79b5
No related branches found
No related tags found
No related merge requests found
...@@ -3,6 +3,16 @@ var relations = []; ...@@ -3,6 +3,16 @@ var relations = [];
var synsets = []; var synsets = [];
var change = false; var change = false;
function existingSelect() {
let availablePreferencies = slowal_frames2selecional_preferencies(unified_frame_active_frame, unified_view_frame_content)[unified_frame_active_argument_id];
if (!availablePreferencies) {
return gettext('Brak preferencji selekcyjnych do wyboru.')
}
return availablePreferencies.map(preference => {
return `<label><input type="checkbox" name="existing" value="${preference.type}:${preference.id}" /> ${preference.str}</label><br />`;
}).join("");
}
function predefinedSelect() { function predefinedSelect() {
var display = ""; var display = "";
...@@ -251,7 +261,7 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) { ...@@ -251,7 +261,7 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) {
}, },
state4: { state4: {
title: 'Wybierz z istniejących', title: 'Wybierz z istniejących',
html: 'TODO', html: existingSelect(),
buttons: { Anuluj: -1, Zatwierdź: 1 }, buttons: { Anuluj: -1, Zatwierdź: 1 },
focus: 1, focus: 1,
submit: function(e,v,m,f){ submit: function(e,v,m,f){
...@@ -261,9 +271,17 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) { ...@@ -261,9 +271,17 @@ function addSelectivePreferenceBase(unified_frame, frame, complement_id) {
} }
if (v == 1) { if (v == 1) {
e.preventDefault(); e.preventDefault();
normalizeFormData(f.existing).map(choice => {
// TODO let [type, id] = choice.split(':');
switch (type) {
case 'meanings.Synset':
saveSynsetPreference(unified_frame_id, complement_id, id);
case 'semantics.PredefinedSelectionalPreference':
savePredefinedPreference(unified_frame_id, complement_id, id);
case 'semantics.RelationalSelectionalPreference':
saveRelationalSelectionalPreference(unified_frame_id, complement_id, null, null); // TODO
}
});
$.prompt.goToState('state0'); $.prompt.goToState('state0');
} }
} }
......
...@@ -298,8 +298,7 @@ function unifiedFrame2dom(unifiedFrame, slowal_frames) { ...@@ -298,8 +298,7 @@ function unifiedFrame2dom(unifiedFrame, slowal_frames) {
let selecional_preferencies_poposition = slowal_frames2selecional_preferencies_mapping[argument.id] let selecional_preferencies_poposition = slowal_frames2selecional_preferencies_mapping[argument.id]
if(selecional_preferencies_poposition != null) { if(selecional_preferencies_poposition != null) {
let selectional_preference_proposition_html = create_selectional_preference_html(selecional_preferencies_poposition, ''); preferences_html += create_selectional_preference_html(selecional_preferencies_poposition, '');
preferences_html += selectional_preference_proposition_html;
} }
// *** and we want to close the <td> here // *** and we want to close the <td> here
...@@ -314,7 +313,7 @@ function unifiedFrame2dom(unifiedFrame, slowal_frames) { ...@@ -314,7 +313,7 @@ function unifiedFrame2dom(unifiedFrame, slowal_frames) {
return div; return div;
} }
function create_selectional_preference_html(preferences, additioan_css_class) { function create_selectional_preference_html(preferences, additional_css_class) {
let preferences_html_local = ''; let preferences_html_local = '';
for (var j in preferences) { for (var j in preferences) {
var preference = preferences[j]; var preference = preferences[j];
...@@ -324,9 +323,9 @@ function create_selectional_preference_html(preferences, additioan_css_class) { ...@@ -324,9 +323,9 @@ function create_selectional_preference_html(preferences, additioan_css_class) {
} }
preferences_html_local += '<div class="preference py-2 px-1' + cls + '">'; preferences_html_local += '<div class="preference py-2 px-1' + cls + '">';
if (preference.url) { if (preference.url) {
preferences_html_local += ' <a class="synset-plwn '+additioan_css_class+'" href="' + preference.url + '" target="_blank">' + preference.str + '</a>'; preferences_html_local += ' <a class="synset-plwn '+additional_css_class+'" href="' + preference.url + '" target="_blank">' + preference.str + '</a>';
} else { } else {
preferences_html_local += ' <span class="'+additioan_css_class+'">' + preference.str +'</span>'; preferences_html_local += ' <span class="'+additional_css_class+'">' + preference.str +'</span>';
} }
if (preference.info) { if (preference.info) {
preferences_html_local += ' ' + tooltipped_info(preference.info); preferences_html_local += ' ' + tooltipped_info(preference.info);
......
...@@ -516,11 +516,15 @@ def get_synset_def(synset): ...@@ -516,11 +516,15 @@ def get_synset_def(synset):
def get_prefs_list(argument): def get_prefs_list(argument):
return sorted( return sorted(
({ ({
'id' : p.pk,
'type' : p._meta.label,
'str' : str(p), 'str' : str(p),
} for p in argument.predefined.all()), } for p in argument.predefined.all()),
key=lambda x: x['str'] key=lambda x: x['str']
) + sorted( ) + sorted(
({ ({
'id' : s.pk,
'type' : s._meta.label,
'str' : str(s), 'str' : str(s),
# can be a new synset # can be a new synset
'url' : None if s.id < 0 else 'http://plwordnet21.clarin-pl.eu/synset/{}'.format(s.id), 'url' : None if s.id < 0 else 'http://plwordnet21.clarin-pl.eu/synset/{}'.format(s.id),
...@@ -529,6 +533,8 @@ def get_prefs_list(argument): ...@@ -529,6 +533,8 @@ def get_prefs_list(argument):
key=lambda x: x['str'] key=lambda x: x['str']
) + sorted( ) + sorted(
({ ({
'id' : r.pk,
'type' : r._meta.label,
'str' : str(r), 'str' : str(r),
'info' : get_rel_pref_desc(r), 'info' : get_rel_pref_desc(r),
} for r in argument.relations.all()), } for r in argument.relations.all()),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment