diff --git a/app/helpers/my_projects_overviews_helper.rb b/app/helpers/my_projects_overviews_helper.rb index ac18dd67f1..99d50de4a7 100644 --- a/app/helpers/my_projects_overviews_helper.rb +++ b/app/helpers/my_projects_overviews_helper.rb @@ -48,13 +48,22 @@ module MyProjectsOverviewsHelper :'ajax-url' => ajax_url(name), position: name } + construct_blocks(name: name, css_classes: css_classes, data: data) + end + + def rendered_field(name) + construct_blocks(name: name, css_classes: Array(name)) + end + + protected + + def construct_blocks(opts = {}) + name, css_classes, data = [:name, :css_classes, :data].map { |sym| opts.fetch sym, '' } content_tag :div, id: "list-#{name}", class: css_classes, data: data do ActiveSupport::SafeBuffer.new(blocks[name].map { |b| construct b }.join) end end - protected - def block_available?(block) controller.class.available_blocks.keys.include? block end diff --git a/app/views/my_projects_overviews/index.html.erb b/app/views/my_projects_overviews/index.html.erb index 1b7861f107..8d697b13cb 100644 --- a/app/views/my_projects_overviews/index.html.erb +++ b/app/views/my_projects_overviews/index.html.erb @@ -19,49 +19,46 @@ See doc/COPYRIGHT.md for more details. ++#%> -<% content_for :action_menu_specific do %> - <%= - context_links = [] - if User.current.allowed_to?(:add_subprojects, project) - context_links << link_to(l(:label_subproject_new), - { :controller => 'projects', - :action => 'new', - :parent_id => project }, - :class => 'icon icon-add') - end - if User.current.allowed_to?(:edit_project, project) - context_links << link_to(l(:label_personalize_page), - { :action => 'page_layout' }, - :class => 'icon icon-edit', - :accesskey => accesskey(:edit)) - end - context_links.join("   ").html_safe - %> +<% content_for :header_tags do %> + <%= javascript_include_tag "my_project_page/my_project_page" %> + <%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %> + <%= stylesheet_link_tag "my_project_page/my_projects_overview", :media => 'all' %> <% end %> +<% html_title(l(:label_overview)) -%> +

<%=l(:label_overview)%>

-<%= render :partial => 'layouts/action_menu_specific' %> +<% content_for :toolbar do %> + <% if User.current.allowed_to?(:add_subprojects, project) %> +
  • + <%= link_to new_project_path(parent_id: project), class: 'button -highlight' do %> + <%= l(:label_subproject_new) %> + <% end %> +
  • + <% end %> + <% if User.current.allowed_to?(:edit_project, project) %> +
  • + <%= link_to my_projects_overview_path(project), class: 'button', accesskey: accesskey(:edit) do %> + <%= l(:label_personalize_page) %> + <% end %> +
  • + <% end %> +<% end %> +<%= render :partial => 'layouts/toolbar' %> -<% ['top', 'left', 'right'].each do |position| %> -
    - <% blocks[position].each do |b| %> -
    -
    - <% if MyProjectsOverviewsController.available_blocks.keys.include? b %> - <%= render :partial => "my_projects_overviews/blocks/#{b}" %> - <% elsif b.respond_to? :to_ary %> - <%= render :partial => "textilizable", - :locals => { :project => project, - :user => user, - :block_title => b[1], - :textile => b.last } %> - <% end %> -
    -
    - <% end if blocks[position] %> +
    +
    + <% top_fields.each do |f| %> + <%= rendered_field f %> + <% end %>
    -<% end %> +
    + <% middle_fields.each do |f| %> + <%= rendered_field f %> + <% end %> +
    +
    <% content_for :sidebar do %> <% if total_hours.present? %> @@ -78,11 +75,3 @@ See doc/COPYRIGHT.md for more details. <% end %> <%= call_hook(:view_projects_show_sidebar_bottom, :project => project) %> <% end %> - -<% content_for :header_tags do %> - <%= javascript_include_tag "my_project_page/my_project_page" %> - <%= auto_discovery_link_tag(:atom, {:controller => 'activities', :action => 'index', :id => @project, :format => 'atom', :key => User.current.rss_key}) %> - <%= stylesheet_link_tag "my_project_page/my_projects_overview", :media => 'all' %> -<% end %> - -<% html_title(l(:label_overview)) -%> diff --git a/config/routes.rb b/config/routes.rb index c16dac582d..e97349800c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -28,7 +28,7 @@ OpenProject::Application.routes.draw do - get 'my_projects_overview/:id/page_layout', to: "my_projects_overviews#page_layout" + get 'my_projects_overview/:id/page_layout', to: "my_projects_overviews#page_layout", as: :my_projects_overview post 'my_projects_overview/:id/page_layout/order_blocks', to: "my_projects_overviews#order_blocks" post 'my_projects_overview/:id/page_layout/remove_block', to: "my_projects_overviews#remove_block" post 'my_projects_overview/:id/page_layout/add_block', to: "my_projects_overviews#add_block"