diff --git a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb index fe52c6e..ec133aa 100644 --- a/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb +++ b/plugins/dspace/controllers/dspace_plugin_myprofile_controller.rb @@ -1,7 +1,7 @@ class DspacePluginMyprofileController < CmsController append_view_path File.join(File.dirname(__FILE__) + '/../views') - def new_dspace_content + def new @success_back_to = params[:success_back_to] diff --git a/plugins/dspace/public/javascripts/dspace_plugin.js b/plugins/dspace/public/javascripts/dspace_plugin.js index 7f5f8b0..6ff6bfe 100644 --- a/plugins/dspace/public/javascripts/dspace_plugin.js +++ b/plugins/dspace/public/javascripts/dspace_plugin.js @@ -20,3 +20,13 @@ function selectCollection(element, collection_slug) { jQuery(hidden_field).insertAfter(element); } +jQuery(document).ready(function() { + url_base = window.location.protocol + '//' + window.location.host; + forms = jQuery('form'); + forms.each( function(f) { + url_action = forms[f].action; + if (url_action.indexOf("/cms/new") > -1) { + forms[f].action = url_action.replace("/cms/new", "/plugin/dspace/new").replace(url_base,''); + } + }); +}); diff --git a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb index 730cb27..d4b1d20 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_collection.html.erb @@ -1,8 +1,4 @@ -

<%= _('DSpace Collection') %>

- -<%#= required_fields_message %> - -<%#= required f.text_field('name', :size => '64', :maxlength => 150) %> +

<%= _('DSpace Collections') %>

<%= hidden_field_tag 'article[parent_id]', @article.parent_id %> @@ -12,27 +8,31 @@ <% community_id = @article.parent.dspace_community_id %> -<% #dspace_client = Dspace::Client.new(dspace_server_url) %> - <% collections = Dspace::Community.get_all_collections_from( dspace_server_url, community_id ).map { |collection| item = [_(collection.name), collection.id] } %> - - - - +
<%= check_box_tag "article[dspace_collection_id]", true %><%= _('DSpace Collection') %>
+ + + + + <% dspace_collections_ids = DspacePlugin::Collection.find(:all, :conditions => { :parent_id => @article.parent_id}).map { |collection| ids = collection.dspace_collection_id.to_i } %> + <% collections.each do |collection| %> + - + <% if dspace_collections_ids.include? collection[1] %> + + <% else %> + + <% end %> + <% end %> +
 <%= _('Collection name') %>
<%= check_box_tag "article[dspace_collection_id][]", collection[1] %> <%= check_box_tag "article[dspace_collections_ids][]", collection[1], true, :disabled => 'disabled', :onclick => "selectCollection(this,'#{collection[0]}')" %> <%= check_box_tag "article[dspace_collections_ids][]", collection[1], false, :onclick => "selectCollection(this,'#{collection[0]}')" %> - <%= hidden_field_tag "article[dspace_collection_name][]", collection[0].to_slug %> <%= collection[0] %>
-<%#= labelled_form_field(_('Collections:'), - select(:article, - :dspace_collection_id, - options_for_select_with_title(collections))) %> +<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %> diff --git a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb index de3ef1a..ef3ecd8 100644 --- a/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb +++ b/plugins/dspace/views/cms/dspace_plugin/_communityy.html.erb @@ -1,18 +1,34 @@ -

<%= _('DSpace Community') %>

- -<%= required_fields_message %> - -<%= required f.text_field('name', :size => '64', :maxlength => 150) %> +

<%= _('DSpace Communities') %>

<%= hidden_field_tag 'article[parent_id]', @article.parent_id %> <% dspace_server_url = @article.parent.dspace_server_url %> -<% dspace_client = Dspace::Client.new(dspace_server_url) %> +<% communities = Dspace::Community.get_all_communities_from(dspace_server_url).map { |community| item = [_(community.name), community.id] } %> + + + + + + + + <% dspace_communities_ids = DspacePlugin::Communityy.find(:all, :conditions => { :parent_id => @article.parent_id }).map { |community| ids = community.dspace_community_id.to_i } %> + + <% communities.each do |community| %> + + + <% if dspace_communities_ids.include? community[1] %> + + <% else %> + + <% end %> + + + + <% end %> -<% communities = dspace_client.get_communities.map { |community| item = [_(community.name), community.id] } %> +
 <%= _('Community name') %>
<%= check_box_tag "article[dspace_communities_ids][]", community[1], true, :disabled => 'disabled', :onclick => "selectCommunity(this,'#{community[0]}')" %> <%= check_box_tag "article[dspace_communities_ids][]", community[1], false, :onclick => "selectCommunity(this,'#{community[0]}')" %> + <%= community[0] %> +
-<%= labelled_form_field(_('Communities:'), - select(:article, - :dspace_community_id, - options_for_select_with_title(communities))) %> +<%= javascript_include_tag 'plugins/dspace/javascripts/dspace_plugin' %> diff --git a/plugins/dspace/views/content_viewer/community.html.erb b/plugins/dspace/views/content_viewer/community.html.erb index e85faa5..4049eb4 100644 --- a/plugins/dspace/views/content_viewer/community.html.erb +++ b/plugins/dspace/views/content_viewer/community.html.erb @@ -6,7 +6,7 @@ <% if dspace_community.allow_create?(user) %>
- <%= 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 %> + <%= 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 %> <%= _("Add a %s") % DspacePlugin::Collection.short_description %> <% end %>
diff --git a/plugins/dspace/views/content_viewer/library.html.erb b/plugins/dspace/views/content_viewer/library.html.erb index 3305f88..0800839 100644 --- a/plugins/dspace/views/content_viewer/library.html.erb +++ b/plugins/dspace/views/content_viewer/library.html.erb @@ -3,7 +3,7 @@ <% if dspace_library.allow_create?(user) %>
- <%= 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 %> + <%= 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 %> <%= _("Add a %s") % DspacePlugin::Communityy.short_description %> <% end %>
-- libgit2 0.21.2