Commit 75c149a85f2279cc8dbe45f523b9d283f72dd604

Authored by Tomasz Bartosiak
1 parent 83ceb233

rzeczowniki -- zmainy wstępne

semantics/sem_urls.py
@@ -26,4 +26,5 @@ SEMANTIC_PATTERNS = patterns('semantics.views', @@ -26,4 +26,5 @@ SEMANTIC_PATTERNS = patterns('semantics.views',
26 url(r'^ajax/synset_preference_form/$', 'synset_preference_form'), 26 url(r'^ajax/synset_preference_form/$', 'synset_preference_form'),
27 url(r'^ajax/relational_preference_form/$', 'relational_preference_form'), 27 url(r'^ajax/relational_preference_form/$', 'relational_preference_form'),
28 url(r'^ajax/get_mwe_list/$', 'ajax_get_mwes'), 28 url(r'^ajax/get_mwe_list/$', 'ajax_get_mwes'),
  29 + url(r'^ajax/connected/$', 'ajax_connected'),
29 ) 30 )
semantics/static/js/semantics_frames.js
@@ -4,6 +4,12 @@ var free_complement_id = -1; @@ -4,6 +4,12 @@ var free_complement_id = -1;
4 var free_frame_id = -1; 4 var free_frame_id = -1;
5 var free_preference_id = -1; 5 var free_preference_id = -1;
6 var semantic_opinion_vals = []; 6 var semantic_opinion_vals = [];
  7 +var connected = []
  8 +
  9 +
  10 +function getConnected(entries) {
  11 + connected = entries;
  12 +}
7 13
8 function selectedFrame() { 14 function selectedFrame() {
9 return "frame_" + highlighted_id + "_"; 15 return "frame_" + highlighted_id + "_";
@@ -506,3 +512,5 @@ function saveFrames() { @@ -506,3 +512,5 @@ function saveFrames() {
506 frames_operations = []; 512 frames_operations = [];
507 } 513 }
508 } 514 }
  515 +
  516 +
semantics/static/js/semantics_view.js
@@ -864,6 +864,44 @@ function removeFromFrame() { @@ -864,6 +864,44 @@ function removeFromFrame() {
864 } 864 }
865 } 865 }
866 866
  867 +///////////////////////// Frame Sharing /////////////////////////
  868 +
  869 +function sharableFrames() {
  870 + result = '<ul>\n';
  871 + for (var i = 0; i < connected.length; i++) {
  872 + result += '<li>';
  873 + resilt += connected[i];
  874 + result += '</li>\n';
  875 + }
  876 + result += '</ul>\n';
  877 + return result;
  878 +}
  879 +
  880 +function shareFrame() {
  881 +
  882 + var share_frame = {
  883 + state0: {
  884 + title: 'Współdzielona rama',
  885 + html: sharableFrames(),
  886 + buttons: { Anuluj: -1, Zatwierdź: 1 },
  887 + focus: 1,
  888 + submit: function(e,v,m,f) {
  889 + if (v == -1) {
  890 + e.preventDefault();
  891 + e.prompt.close();
  892 + }
  893 + if (v == 1) {
  894 + e.preventDefault();
  895 + e.prompt.close();
  896 + }
  897 + }
  898 + },
  899 + };
  900 +
  901 + $.prompt(share_frame);
  902 +
  903 +}
  904 +
867 //////////////////////////// Display //////////////////////////// 905 //////////////////////////// Display ////////////////////////////
868 906
869 function frameClick(clicked_id) { 907 function frameClick(clicked_id) {
semantics/templates/semantics.html
@@ -46,6 +46,9 @@ @@ -46,6 +46,9 @@
46 $("#semantic-frames-count").empty(); 46 $("#semantic-frames-count").empty();
47 $("#semantic-frames-count").append(data.frames_count); 47 $("#semantic-frames-count").append(data.frames_count);
48 }); 48 });
  49 + $.getJSON(ajax_connected, {lemma_id: {{ lemma.id }}}, function(data){
  50 + getConnected(data.entries);
  51 + });
49 }); 52 });
50 }); 53 });
51 54
@@ -90,8 +93,9 @@ @@ -90,8 +93,9 @@
90 <div id="control" class="semantics-control-tabs" style="overflow: auto;"> 93 <div id="control" class="semantics-control-tabs" style="overflow: auto;">
91 <ul> 94 <ul>
92 <li><a href="#select_meanings">Znaczenia</a></li> 95 <li><a href="#select_meanings">Znaczenia</a></li>
93 - <li><a href="#select_creating">Tworzenie</a></li>  
94 - </ul> 96 + <li><a href="#select_creating">Tworzenie</a></li>
  97 + <li><a href="#select_connected">Powiązane</a></li>
  98 + </ul>
95 <div id="select_meanings"> 99 <div id="select_meanings">
96 <button type="button" onclick="openMeaningsMenu()" id="create">Modyfikuj</button> 100 <button type="button" onclick="openMeaningsMenu()" id="create">Modyfikuj</button>
97 </div> 101 </div>
@@ -107,6 +111,9 @@ @@ -107,6 +111,9 @@
107 <br/> 111 <br/>
108 <button type="button" onclick="saveFrames()" id="save_frames">Zapisz</button> 112 <button type="button" onclick="saveFrames()" id="save_frames">Zapisz</button>
109 </div> 113 </div>
  114 + <div id="select_connected" style="overflow: auto;">
  115 + <button type="button" onclick="shareFrame()" id="share_frames">Kopiuj</button>
  116 + </div>
110 </div> 117 </div>
111 {% endif %} 118 {% endif %}
112 119
semantics/views.py
@@ -49,6 +49,7 @@ def ajax_semantics(request, id): @@ -49,6 +49,7 @@ def ajax_semantics(request, id):
49 'ajax_predefined_preferences': reverse('ajax_predefined_preferences'), 49 'ajax_predefined_preferences': reverse('ajax_predefined_preferences'),
50 'ajax_plWN_context_lookup': reverse('ajax_plWN_context_lookup'), 50 'ajax_plWN_context_lookup': reverse('ajax_plWN_context_lookup'),
51 'ajax_get_mwes': reverse('ajax_get_mwes'), 51 'ajax_get_mwes': reverse('ajax_get_mwes'),
  52 + 'ajax_connected': reverse('ajax_connected'),
52 } 53 }
53 return context 54 return context
54 55
@@ -249,6 +250,23 @@ def create_frames_context(lemma_id, user): @@ -249,6 +250,23 @@ def create_frames_context(lemma_id, user):
249 250
250 return context 251 return context
251 252
  253 +
  254 +@render('connected.json')
  255 +@ajax(method='get', encode_result=False)
  256 +def ajax_connected(request, lemma_id):
  257 + context = create_connected_context(lemma_id)
  258 + return context
  259 +
  260 +def create_connected_context(lemma_id):
  261 + lemma = Lemma.objects.get(id=lemma_id)
  262 + connected = lemma.entry_obj.rel_entries.all()
  263 +
  264 + context = {
  265 + 'entries': [{"lemma": conn.name} for conn in connected]
  266 + }
  267 + return context
  268 +
  269 +
252 @render('units.json') 270 @render('units.json')
253 @ajax(method='get', encode_result=False) 271 @ajax(method='get', encode_result=False)
254 def ajax_units(request, lemma_id): 272 def ajax_units(request, lemma_id):