Commit b898170b3487f95d1557af48786a0ae1825cf3fa
1 parent
9c1af653
Dwie role na jednej pozycji -- patch
Showing
2 changed files
with
18 additions
and
6 deletions
semantics/static/js/semantics_frames.js
... | ... | @@ -200,8 +200,10 @@ function removeFrame(frame_id) { |
200 | 200 | function roleFree(frame_id, field_ids) { |
201 | 201 | var i; |
202 | 202 | for (i = 0; i < field_ids.length; i++) { |
203 | - if (connected_reverse[field_ids[i]].indexOf('frame_' + frame_id + '_') >= 0) { | |
204 | - return false; | |
203 | + if (typeof(connected_reverse[field_ids[i]]) != 'undefined') { | |
204 | + if (connected_reverse[field_ids[i]].indexOf('frame_' + frame_id + '_') >= 0) { | |
205 | + return false; | |
206 | + } | |
205 | 207 | } |
206 | 208 | } |
207 | 209 | return true; |
... | ... | @@ -219,7 +221,10 @@ function addArgument(frame_id, field_ids, roles) { |
219 | 221 | connected['frame_' + frame_id + '_comp_' + free_complement_id + '_'] = field_ids; |
220 | 222 | |
221 | 223 | for(i = 0; i < field_ids.length; i++) { |
222 | - connected_reverse[field_ids[i]].append('frame_' + frame_id + '_'); | |
224 | + if (typeof(connected_reverse[field_ids[i]]) == 'undefined') { | |
225 | + connected_reverse[field_ids[i]] = []; | |
226 | + } | |
227 | + connected_reverse[field_ids[i]].push('frame_' + frame_id + '_'); | |
223 | 228 | } |
224 | 229 | |
225 | 230 | var complement_id = free_complement_id; |
... | ... | @@ -423,7 +428,7 @@ function saveFrames() { |
423 | 428 | $.getJSON(ajax_modify_frames, {"operations": JSON.stringify(frames_operations), "lemma_id": lemma_id}, function(data){ |
424 | 429 | getFrames(data.frames_display); |
425 | 430 | displayFrames(); |
426 | - memorizeConnections(data.connections.connected, data.connections.disconnected); | |
431 | + memorizeConnections(data.connections.connected, data.connections.connected_reverse); | |
427 | 432 | $("#semantic-frames-count").empty(); |
428 | 433 | $("#semantic-frames-count").append(data.frames_count); |
429 | 434 | }); |
... | ... |
semantics/static/js/semantics_view.js
... | ... | @@ -1050,10 +1050,11 @@ function schemaClick(class_id) { |
1050 | 1050 | return; |
1051 | 1051 | } else { |
1052 | 1052 | // arg = "frame_26_comp_36_" |
1053 | + var frame_id = parseInt(parseInt(arg.split('_')[1])); | |
1053 | 1054 | var i, j; |
1054 | - var can_connect = true; | |
1055 | + var can_connect = false; | |
1055 | 1056 | if (roleFree(frame_id, field_ids)) { |
1056 | - can_connect = false; | |
1057 | + can_connect = true; | |
1057 | 1058 | } |
1058 | 1059 | var connect = true; |
1059 | 1060 | for (i = 0; i < field_ids.length; i++) { |
... | ... | @@ -1071,6 +1072,8 @@ function schemaClick(class_id) { |
1071 | 1072 | j = connected[arg].indexOf(field_ids[i]) |
1072 | 1073 | if (j != -1) { |
1073 | 1074 | connected[arg].splice(j, 1); |
1075 | + j = connected_reverse[field_ids[i]].indexOf('frame_' + frame_id + '_') | |
1076 | + connected_reverse[field_ids[i]].splice(j, 1); | |
1074 | 1077 | frames_operations.push({operation: 'disconnect', arg: arg, connect: field_ids[i]}); |
1075 | 1078 | var a = arg; |
1076 | 1079 | frameClick(""); |
... | ... | @@ -1081,6 +1084,10 @@ function schemaClick(class_id) { |
1081 | 1084 | j = connected[arg].indexOf(field_ids[i]) |
1082 | 1085 | if (j == -1) { // redundant |
1083 | 1086 | connected[arg].push(field_ids[i]); |
1087 | + if (typeof(connected_reverse[field_ids[i]]) == 'undefined') { | |
1088 | + connected_reverse[field_ids[i]] = [] | |
1089 | + } | |
1090 | + connected_reverse[field_ids[i]].push('frame_' + frame_id + '_'); | |
1084 | 1091 | frames_operations.push({operation: 'connect', arg: arg, connect: field_ids[i]}); |
1085 | 1092 | var a = arg; |
1086 | 1093 | frameClick(""); |
... | ... |