Commit f31d0ef4c229c1371af7fc105696791de431fcc2

Authored by Francisco Júnior
1 parent 29f9c094

dspace_plugin : updating views

plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb
1 class DspacePluginMyprofileController < CmsController 1 class DspacePluginMyprofileController < CmsController
2 append_view_path File.join(File.dirname(__FILE__) + '/../views') 2 append_view_path File.join(File.dirname(__FILE__) + '/../views')
3 3
4 - def new_dspace_content 4 + def new
5 5
6 @success_back_to = params[:success_back_to] 6 @success_back_to = params[:success_back_to]
7 7
plugins/dspace/public/javascripts/dspace_plugin.js
@@ -20,3 +20,13 @@ function selectCollection(element, collection_slug) { @@ -20,3 +20,13 @@ function selectCollection(element, collection_slug) {
20 jQuery(hidden_field).insertAfter(element); 20 jQuery(hidden_field).insertAfter(element);
21 } 21 }
22 22
  23 +jQuery(document).ready(function() {
  24 + url_base = window.location.protocol + '//' + window.location.host;
  25 + forms = jQuery('form');
  26 + forms.each( function(f) {
  27 + url_action = forms[f].action;
  28 + if (url_action.indexOf("/cms/new") > -1) {
  29 + forms[f].action = url_action.replace("/cms/new", "/plugin/dspace/new").replace(url_base,'');
  30 + }
  31 + });
  32 +});
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
1 -<h1><%= _('DSpace Collection') %></h1>  
2 -  
3 -<%#= required_fields_message %>  
4 -  
5 -<%#= required f.text_field('name', :size => '64', :maxlength => 150) %> 1 +<h1><%= _('DSpace Collections') %></h1>
6 2
7 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> 3 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
8 4
@@ -12,27 +8,31 @@ @@ -12,27 +8,31 @@
12 8
13 <% community_id = @article.parent.dspace_community_id %> 9 <% community_id = @article.parent.dspace_community_id %>
14 10
15 -<% #dspace_client = Dspace::Client.new(dspace_server_url) %>  
16 -  
17 <% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %> 11 <% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %>
18 12
19 -<table border="0">  
20 - <tr>  
21 - <th><%= check_box_tag "article[dspace_collection_id]", true %></th>  
22 - <th align="left"><%= _('DSpace Collection') %></th> 13 +<table border="0" style="border-bottom: 1px solid #c0c0c0;">
  14 + <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
  15 + <th style="border-bottom: none;">&nbsp;</th>
  16 + <th style="border-bottom: none;" align="left"><%= _('Collection name') %></th>
23 </tr> 17 </tr>
  18 +
  19 + <% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %>
  20 +
24 <% collections.each do |collection| %> 21 <% collections.each do |collection| %>
  22 +
25 <tr> 23 <tr>
26 - <td align="center"><%= check_box_tag "article[dspace_collection_id][]", collection[1] %> </td> 24 + <% if dspace_collections_ids.include? collection[1] %>
  25 + <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
  26 + <% else %>
  27 + <td align="center"><%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> </td>
  28 + <% end %>
27 <td> 29 <td>
28 - <%= hidden_field_tag "article[dspace_collection_name][]", collection[0].to_slug %>  
29 <%= collection[0] %> 30 <%= collection[0] %>
30 </td> 31 </td>
31 </tr> 32 </tr>
  33 +
32 <% end %> 34 <% end %>
  35 +
33 </table> 36 </table>
34 37
35 -<%#= labelled_form_field(_('Collections:'),  
36 - select(:article,  
37 - :dspace_collection_id,  
38 - options_for_select_with_title(collections))) %> 38 +<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %>
plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb
1 -<h1><%= _('DSpace Community') %></h1>  
2 -  
3 -<%= required_fields_message %>  
4 -  
5 -<%= required f.text_field('name', :size => '64', :maxlength => 150) %> 1 +<h1><%= _('DSpace Communities') %></h1>
6 2
7 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> 3 <%= hidden_field_tag 'article[parent_id]', @article.parent_id %>
8 4
9 <% dspace_server_url = @article.parent.dspace_server_url %> 5 <% dspace_server_url = @article.parent.dspace_server_url %>
10 6
11 -<% dspace_client = Dspace::Client.new(dspace_server_url) %> 7 +<% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %>
  8 +
  9 +<table border="0" style="border-bottom: 1px solid #c0c0c0;">
  10 + <tr style="background-color: #f0f0f0; border-bottom: 1px solid #c0c0c0;">
  11 + <th style="border-bottom: none;">&nbsp;</th>
  12 + <th style="border-bottom: none;" align="left"><%= _('Community name') %></th>
  13 + </tr>
  14 +
  15 + <% dspace_communities_ids = DspacePlugin::Communityy.find(:all, :conditions => { :parent_id => @article.parent_id }).map { |community| ids = community.dspace_community_id.to_i } %>
  16 +
  17 + <% communities.each do |community| %>
  18 +
  19 + <tr>
  20 + <% if dspace_communities_ids.include? community[1] %>
  21 + <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
  22 + <% else %>
  23 + <td align="center"><%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> </td>
  24 + <% end %>
  25 + <td>
  26 + <%= community[0] %>
  27 + </td>
  28 + </tr>
  29 +
  30 + <% end %>
12 31
13 -<% communities = dspace_client.get_communities.map { |community| item = [_(community.name), community.id] } %> 32 +</table>
14 33
15 -<%= labelled_form_field(_('Communities:'),  
16 - select(:article,  
17 - :dspace_community_id,  
18 - options_for_select_with_title(communities))) %> 34 +<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %>
plugins/dspace/views/content_viewer/community.html.erb
@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 <% if dspace_community.allow_create?(user) %> 6 <% if dspace_community.allow_create?(user) %>
7 7
8 <div id="actions"> 8 <div id="actions">
9 - <%= content_tag('a', :href => url_for({:controller => 'dspace_plugin_myprofile', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_community.id}), :class => 'button with-text icon-add') do %> 9 + <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_community.id}), :class => 'button with-text icon-add') do %>
10 <%= _("Add a %s") % DspacePlugin::Collection.short_description %> 10 <%= _("Add a %s") % DspacePlugin::Collection.short_description %>
11 <% end %> 11 <% end %>
12 </div> 12 </div>
plugins/dspace/views/content_viewer/library.html.erb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 <% if dspace_library.allow_create?(user) %> 3 <% if dspace_library.allow_create?(user) %>
4 4
5 <div id="actions"> 5 <div id="actions">
6 - <%= content_tag('a', :href => url_for({:controller => 'dspace_plugin_myprofile', :action => 'new', :type => "DspacePlugin::Communityy", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %> 6 + <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Communityy", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %>
7 <%= _("Add a %s") % DspacePlugin::Communityy.short_description %> 7 <%= _("Add a %s") % DspacePlugin::Communityy.short_description %>
8 <% end %> 8 <% end %>
9 </div> 9 </div>