Commit 51ea425feec53e8dc9b2fd263b3127e417a2f315
1 parent
9365fa9e
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
dspace_plugin : improve ui navigation
Showing
12 changed files
with
83 additions
and
23 deletions
Show diff stats
plugins/dspace/lib/dspace/client.rb
| 1 | 1 | class Dspace::Client |
| 2 | 2 | |
| 3 | - def initialize(dspace_server_url) | |
| 3 | + def initialize(server_url) | |
| 4 | + @server_url = server_url | |
| 4 | 5 | end |
| 5 | 6 | |
| 6 | 7 | def get_collections |
| 7 | - Dspace::Collection.find(:all) | |
| 8 | + Dspace::Collection.get_all_collections_from @server_url | |
| 8 | 9 | end |
| 9 | 10 | |
| 10 | 11 | def get_communities | ... | ... |
plugins/dspace/lib/dspace/collection.rb
| 1 | 1 | class Dspace::Collection < Dspace::Resource |
| 2 | - self.site = "http://dev.maljr.net:8080/rest/" | |
| 3 | 2 | |
| 4 | - def self.get_items(collection_id) | |
| 3 | + def self.get_all_items_from(dspace_server, collection_id) | |
| 4 | + self.site = dspace_server | |
| 5 | 5 | result = self.find collection_id, :params => { :expand => 'items' } |
| 6 | + | |
| 7 | + #if result.items.count > 0 | |
| 8 | + | |
| 9 | + # result.items.each { |item| | |
| 10 | + | |
| 11 | + # item_metadata = Dspace::Item.get_all_item_metadata_from dspace_server, item.id | |
| 12 | + #raise item_metadata.count.inspect | |
| 13 | + # raise item_metadata.inspect | |
| 14 | + | |
| 15 | + # } | |
| 16 | + #end | |
| 17 | + | |
| 6 | 18 | result.items |
| 7 | 19 | end |
| 8 | 20 | |
| 21 | + def self.get_all_collections_from(dspace_server) | |
| 22 | + self.site = dspace_server | |
| 23 | + self.find(:all) | |
| 24 | + end | |
| 25 | + | |
| 9 | 26 | end | ... | ... |
plugins/dspace/lib/dspace_plugin.rb
plugins/dspace/lib/dspace_plugin/collection.rb
plugins/dspace/lib/dspace_plugin/library.rb
plugins/dspace/views/cms/dspace_plugin/_collection.html.erb
| ... | ... | @@ -6,19 +6,17 @@ |
| 6 | 6 | |
| 7 | 7 | <%= hidden_field_tag 'article[parent_id]', @article.parent_id %> |
| 8 | 8 | |
| 9 | -<% dspace_client = Dspace::Client.new('') %> | |
| 9 | +<% dspace_server_url = @article.parent.server_url %> | |
| 10 | 10 | |
| 11 | -<% collections = dspace_client.get_collections %> | |
| 11 | +<%#= hidden_field_tag 'article[server_url]', dspace_server_url %> | |
| 12 | 12 | |
| 13 | -<% | |
| 14 | -collections_2 = collections.map { |collection| | |
| 15 | - item = [_(collection.name), collection.id] | |
| 16 | -} | |
| 17 | -%> | |
| 13 | +<% dspace_client = Dspace::Client.new(dspace_server_url) %> | |
| 14 | + | |
| 15 | +<% collections = dspace_client.get_collections.map { |collection| item = [_(collection.name), collection.id] } %> | |
| 18 | 16 | |
| 19 | 17 | <%= labelled_form_field(_('Collections:'), |
| 20 | 18 | select(:article, |
| 21 | 19 | :dspace_collection_id, |
| 22 | - options_for_select_with_title(collections_2))) %> | |
| 20 | + options_for_select_with_title(collections))) %> | |
| 23 | 21 | |
| 24 | 22 | <% #raise collections_2.inspect %> | ... | ... |
plugins/dspace/views/content_viewer/_collection_item.html.erb
0 → 100644
plugins/dspace/views/content_viewer/collection.html.erb
| 1 | -<% dspace_collection_id = 7 %> | |
| 1 | +<% collection_id = dspace_collection.dspace_collection_id %> | |
| 2 | +<% dspace_server = dspace_collection.parent.server_url %> | |
| 2 | 3 | |
| 3 | -<% dspace_items_from_collection = Dspace::Collection.get_items(dspace_collection_id) %> | |
| 4 | - | |
| 5 | -<% dspace_items_from_collection.each { |item| %> | |
| 6 | -<br /> | |
| 7 | -<%= item.name %> | |
| 8 | -<br /> | |
| 9 | -<% } %> | |
| 4 | +<div id="dspace_library"> | |
| 5 | + <div id="dspace_collection"> | |
| 6 | + <ul id="items_list" class="items_list"> | |
| 7 | + <%= render :partial => 'item', :collection => dspace_collection.items(dspace_server, collection_id) %> | |
| 8 | + </ul> | |
| 9 | + </div> | |
| 10 | +</div> | ... | ... |
plugins/dspace/views/content_viewer/library.html.erb
| ... | ... | @@ -2,6 +2,8 @@ |
| 2 | 2 | |
| 3 | 3 | <%= content_tag 'div', dspace_library.body %> |
| 4 | 4 | |
| 5 | + <% if dspace_library.gather_option == "communities" %> | |
| 6 | + | |
| 5 | 7 | <h3><%= _("Communities") %></h3> |
| 6 | 8 | |
| 7 | 9 | <% if true %> |
| ... | ... | @@ -18,10 +20,13 @@ |
| 18 | 20 | <%= render :partial => 'community_item', :collection => dspace_library.communities %> |
| 19 | 21 | </ul> |
| 20 | 22 | |
| 23 | + <% end %> | |
| 24 | + | |
| 25 | + <% if dspace_library.gather_option == "collections" %> | |
| 21 | 26 | |
| 22 | 27 | <h3><%= _("Collections") %></h3> |
| 23 | 28 | |
| 24 | - <% if true %> | |
| 29 | + <% if true %> | |
| 25 | 30 | |
| 26 | 31 | <div class="library_actions"> |
| 27 | 32 | <%= content_tag('a', :href => url_for({:controller => 'cms', :action => 'new', :type => "DspacePlugin::Collection", :parent_id => dspace_library.id}), :class => 'button with-text icon-add') do %> |
| ... | ... | @@ -29,6 +34,12 @@ |
| 29 | 34 | <% end %> |
| 30 | 35 | </div> |
| 31 | 36 | |
| 37 | + <% end %> | |
| 38 | + | |
| 39 | + <ul id="collections_list" class="collections_list"> | |
| 40 | + <%= render :partial => 'collection_item', :collection => dspace_library.collections %> | |
| 41 | + </ul> | |
| 42 | + | |
| 32 | 43 | <% end %> |
| 33 | 44 | |
| 34 | 45 | </div> | ... | ... |