diff --git a/app/assets/javascripts/shared/async_dropdown.js b/app/assets/javascripts/shared/async_dropdown.js new file mode 100644 index 000000000..87711b783 --- /dev/null +++ b/app/assets/javascripts/shared/async_dropdown.js @@ -0,0 +1,7 @@ +$(document).on('click', '.dropdown-async button', function(e) { + var $parent = $(e.currentTarget).parent(); + + $.get($parent.data('dropdown-url'), function(data) { + $parent.find('ul').replaceWith(data.html); + }); +}); diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1b608219d..37dbde62a 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -12,9 +12,9 @@ class ProjectsController < ApplicationController helper_method :current_folder before_action :switch_team_with_param, only: :index - before_action :load_vars, only: %i(show edit update notifications sidebar experiments_cards view_type) + before_action :load_vars, only: %i(show edit update notifications sidebar experiments_cards view_type actions_dropdown) before_action :load_current_folder, only: %i(index cards new show) - before_action :check_view_permissions, only: %i(show notifications sidebar experiments_cards view_type) + before_action :check_view_permissions, only: %i(show notifications sidebar experiments_cards view_type actions_dropdown) before_action :check_create_permissions, only: %i(new create) before_action :check_manage_permissions, only: :edit before_action :load_exp_sort_var, only: :show @@ -339,6 +339,19 @@ class ProjectsController < ApplicationController render json: { cards_view_type_class: cards_view_type_class(view_type_params) }, status: :ok end + def actions_dropdown + respond_to do |format| + format.json do + render json: { + html: render_to_string( + partial: 'projects/index/project_actions_dropdown.html.erb', + locals: { project: @project, view: @project.current_view_state(current_user) } + ) + } + end + end + end + private def project_params diff --git a/app/views/projects/index/_project_actions_dropdown.html.erb b/app/views/projects/index/_project_actions_dropdown.html.erb index b62e95b49..0912d3e7b 100644 --- a/app/views/projects/index/_project_actions_dropdown.html.erb +++ b/app/views/projects/index/_project_actions_dropdown.html.erb @@ -1,84 +1,79 @@ <% cache [current_user, project] do %> - + <% end %> + + <% if can_read_project?(project) %> +
  • + <%= link_to can_manage_project_users?(project) ? edit_access_permissions_project_path(project) : access_permissions_project_path(project), + class: 'btn btn-light', + data: { action: 'remote-modal'} do %> + + <%= I18n.t('projects.index.project_members_access') %> + <% end %> +
  • + <% end %> + +
  • + + + + <%= t('projects.index.comments_option', comments_count: project.comments.count) %> + + +
  • + +
  • + + + <%= t('projects.index.activities_option') %> + +
  • + <% end %> diff --git a/app/views/projects/index/_project_card.html.erb b/app/views/projects/index/_project_card.html.erb index 2beb628fe..f13ccb631 100644 --- a/app/views/projects/index/_project_card.html.erb +++ b/app/views/projects/index/_project_card.html.erb @@ -27,7 +27,14 @@ <% end %>
    - <%= render partial: 'projects/index/project_actions_dropdown.html.erb', locals: { project: project, view: 'cards' } %> +
    diff --git a/config/routes.rb b/config/routes.rb index e7c808ff0..722c885b1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -302,6 +302,7 @@ Rails.application.routes.draw do get 'notifications' get 'experiments_cards' get 'sidebar' + get 'actions_dropdown' put 'view_type' end