Commit fa3df1e7148975fa76f32d64fba3963146de151d
1 parent
fc1168b8
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
virtuoso: change add triple feature ui to colorbox
Showing
5 changed files
with
74 additions
and
36 deletions
Show diff stats
plugins/virtuoso/controllers/virtuoso_plugin_admin_controller.rb
| ... | ... | @@ -57,10 +57,7 @@ class VirtuosoPluginAdminController < AdminController |
| 57 | 57 | triples_management = VirtuosoPlugin::TriplesManagement.new(environment) |
| 58 | 58 | triples_management.add_triple(triple) |
| 59 | 59 | |
| 60 | - @triples = [] | |
| 61 | - | |
| 62 | - session[:notice] = _('Triple succesfully added.') | |
| 63 | - render :action => :triple_management | |
| 60 | + render json: { :ok => true, :message => _('Triple succesfully added.') } | |
| 64 | 61 | end |
| 65 | 62 | end |
| 66 | 63 | ... | ... |
plugins/virtuoso/public/style.css
| ... | ... | @@ -2,7 +2,8 @@ |
| 2 | 2 | margin: 10px 0; |
| 3 | 3 | } |
| 4 | 4 | |
| 5 | -#virtuoso-triples-management input[type="text"] { | |
| 5 | +#virtuoso-triples-management input[type="text"], | |
| 6 | +#virtuoso-triples-management-add-triple input[type="text"] { | |
| 6 | 7 | width: 100% |
| 7 | 8 | } |
| 8 | 9 | |
| ... | ... | @@ -10,7 +11,8 @@ |
| 10 | 11 | width: 99%; |
| 11 | 12 | } |
| 12 | 13 | |
| 13 | -#virtuoso-triples-management ul { | |
| 14 | +#virtuoso-triples-management ul, | |
| 15 | +#virtuoso-triples-management-add-triple ul { | |
| 14 | 16 | list-style-type: none; |
| 15 | 17 | padding: 0; |
| 16 | 18 | } |
| ... | ... | @@ -29,3 +31,8 @@ |
| 29 | 31 | #virtuoso-triples-management #triples-list .triple-actions { |
| 30 | 32 | text-align: right; |
| 31 | 33 | } |
| 34 | + | |
| 35 | +#virtuoso-triples-management-add-triple { | |
| 36 | + width: 500px; | |
| 37 | + border: 1px solid white; | |
| 38 | +} | ... | ... |
plugins/virtuoso/public/triples_management.js
| 1 | +function add_triple() { | |
| 2 | + graph = jQuery("input#triple_graph").val(); | |
| 3 | + subject = jQuery("input#triple_subject").val(); | |
| 4 | + predicate = jQuery("input#triple_predicate").val(); | |
| 5 | + object = jQuery("input#triple_object").val(); | |
| 6 | + | |
| 7 | + var formData = { triple: { graph: graph, subject: subject, predicate: predicate, object: object } } | |
| 8 | + | |
| 9 | + jQuery.ajax({ | |
| 10 | + cache: false, | |
| 11 | + type: 'POST', | |
| 12 | + url: '/admin/plugin/virtuoso/add_triple', | |
| 13 | + data: formData, | |
| 14 | + dataType: 'json', | |
| 15 | + success: function(data, status, ajax){ | |
| 16 | + if ( !data.ok ) { | |
| 17 | + display_notice(data.error.message); | |
| 18 | + jQuery.colorbox.close(); | |
| 19 | + } | |
| 20 | + else { | |
| 21 | + display_notice(data.message); | |
| 22 | + jQuery.colorbox.close(); | |
| 23 | + } | |
| 24 | + }, | |
| 25 | + error: function(ajax, status, errorThrown) { | |
| 26 | + alert('Send request - HTTP '+status+': '+errorThrown); | |
| 27 | + } | |
| 28 | + }); | |
| 29 | + | |
| 30 | + return false; | |
| 31 | +} | |
| 32 | + | |
| 1 | 33 | function remove_triple(triple_id) { |
| 2 | 34 | graph = jQuery("input#graph_uri").val(); |
| 3 | 35 | subject = jQuery("input#triples_triple" + triple_id + "_from_subject").val(); |
| ... | ... | @@ -7,31 +39,31 @@ function remove_triple(triple_id) { |
| 7 | 39 | var formData = { triple: { graph: graph, subject: subject, predicate: predicate, object: object } } |
| 8 | 40 | |
| 9 | 41 | jQuery.ajax({ |
| 10 | - cache: false, | |
| 11 | - type: 'POST', | |
| 12 | - url: '/admin/plugin/virtuoso/remove_triple', | |
| 13 | - data: formData, | |
| 14 | - dataType: 'json', | |
| 15 | - success: function(data, status, ajax){ | |
| 16 | - if ( !data.ok ) { | |
| 17 | - display_notice(data.error.message); | |
| 18 | - } | |
| 19 | - else { | |
| 20 | - display_notice(data.message); | |
| 21 | - jQuery("li#triple-" + triple_id).fadeOut(700, function() { | |
| 22 | - if (jQuery("ul#triples-list > li").length == 1) { | |
| 23 | - jQuery("form#form-triples-edit").remove(); | |
| 24 | - } | |
| 25 | - else { | |
| 26 | - jQuery("li#triple-" + triple_id).remove(); | |
| 27 | - } | |
| 28 | - }); | |
| 29 | - } | |
| 30 | - }, | |
| 31 | - error: function(ajax, status, errorThrown) { | |
| 32 | - alert('Send request - HTTP '+status+': '+errorThrown); | |
| 42 | + cache: false, | |
| 43 | + type: 'POST', | |
| 44 | + url: '/admin/plugin/virtuoso/remove_triple', | |
| 45 | + data: formData, | |
| 46 | + dataType: 'json', | |
| 47 | + success: function(data, status, ajax){ | |
| 48 | + if ( !data.ok ) { | |
| 49 | + display_notice(data.error.message); | |
| 50 | + } | |
| 51 | + else { | |
| 52 | + display_notice(data.message); | |
| 53 | + jQuery("li#triple-" + triple_id).fadeOut(700, function() { | |
| 54 | + if (jQuery("ul#triples-list > li").length == 1) { | |
| 55 | + jQuery("form#form-triples-edit").remove(); | |
| 56 | + } | |
| 57 | + else { | |
| 58 | + jQuery("li#triple-" + triple_id).remove(); | |
| 59 | + } | |
| 60 | + }); | |
| 33 | 61 | } |
| 34 | - }); | |
| 62 | + }, | |
| 63 | + error: function(ajax, status, errorThrown) { | |
| 64 | + alert('Send request - HTTP '+status+': '+errorThrown); | |
| 65 | + } | |
| 66 | + }); | |
| 35 | 67 | |
| 36 | - return false; | |
| 68 | + return false; | |
| 37 | 69 | } | ... | ... |
plugins/virtuoso/views/virtuoso_plugin_admin/add_triple.html.erb
| 1 | -<div id="virtuoso-triples-management"> | |
| 2 | - <h1><%= _('Virtuoso settings » Triples Management » Add Triple')%></h1> | |
| 1 | +<div id="virtuoso-triples-management-add-triple"> | |
| 3 | 2 | |
| 4 | - <%= form_tag('/admin/plugin/virtuoso/add_triple', :method => 'post') do %> | |
| 3 | + <h3><%= _('Add Triple')%></h3> | |
| 4 | + | |
| 5 | + <%= form_tag do %> | |
| 5 | 6 | |
| 6 | 7 | <ul> |
| 7 | 8 | <li> |
| ... | ... | @@ -19,7 +20,8 @@ |
| 19 | 20 | </ul> |
| 20 | 21 | |
| 21 | 22 | <% button_bar do %> |
| 22 | - <%= submit_button(:save, _('Save')) %> | |
| 23 | + <%= button :add, _('Add'), {}, :href => '#', :onclick => "add_triple(); return false;" %> | |
| 24 | + <%= colorbox_close_button(_('Close')) %> | |
| 23 | 25 | <% end %> |
| 24 | 26 | |
| 25 | 27 | <% end %> | ... | ... |
plugins/virtuoso/views/virtuoso_plugin_admin/triple_management.html.erb
| ... | ... | @@ -6,7 +6,7 @@ |
| 6 | 6 | <%= labelled_form_field(_('Query SPARQL:'), text_area_tag(:query, @query, :rows => 7)) %> |
| 7 | 7 | <% button_bar do %> |
| 8 | 8 | <%= submit_button(:search, _('Search triples')) %> |
| 9 | - <%= button :add, _('Add triple'), :action => :add_triple %> | |
| 9 | + <%= colorbox_button('add', _('Add a triple'), { :action => 'add_triple' }) %> | |
| 10 | 10 | <% end %> |
| 11 | 11 | <% end %> |
| 12 | 12 | ... | ... |