diff --git a/app/controllers/canvas_controller.rb b/app/controllers/canvas_controller.rb index c07e59ad3..7259ebe60 100644 --- a/app/controllers/canvas_controller.rb +++ b/app/controllers/canvas_controller.rb @@ -265,7 +265,7 @@ class CanvasController < ApplicationController end def check_edit_canvas - unless can_edit_canvas(@experiment) + unless can_edit_canvas(@project) render_403 and return end end diff --git a/app/controllers/experiments_controller.rb b/app/controllers/experiments_controller.rb index 55950c26c..1ca6f62e6 100644 --- a/app/controllers/experiments_controller.rb +++ b/app/controllers/experiments_controller.rb @@ -23,7 +23,8 @@ class ExperimentsController < ApplicationController end end - def edit + def canvas + @project = @experiment.project end def update diff --git a/app/helpers/permission_helper.rb b/app/helpers/permission_helper.rb index 798e5d779..6aa449422 100644 --- a/app/helpers/permission_helper.rb +++ b/app/helpers/permission_helper.rb @@ -323,8 +323,8 @@ module PermissionHelper # ---- WORKFLOW PERMISSIONS ---- - def can_edit_canvas(experiment) - is_user_or_higher_of_project(experiment.project) + def can_edit_canvas(project) + is_user_or_higher_of_project(project) end def can_reposition_modules(experiment) diff --git a/app/views/canvas/full_zoom/_my_module.html.erb b/app/views/canvas/full_zoom/_my_module.html.erb index 11c46ec2c..e9c985506 100644 --- a/app/views/canvas/full_zoom/_my_module.html.erb +++ b/app/views/canvas/full_zoom/_my_module.html.erb @@ -32,7 +32,7 @@
- <%= link_to_if can_edit_module(my_module), t("experiments.canvas.full_zoom.due_date"), due_date_my_module_path(my_module, format: :json), remote: true, class: "due-date-link" %> + <%= link_to_if can_edit_module(my_module), t("projects.canvas.full_zoom.due_date"), due_date_my_module_path(my_module, format: :json), remote: true, class: "due-date-link" %>
<% if can_edit_module(my_module) %> diff --git a/app/views/experiments/canvas.html.erb b/app/views/experiments/canvas.html.erb new file mode 100644 index 000000000..c8885e52e --- /dev/null +++ b/app/views/experiments/canvas.html.erb @@ -0,0 +1,39 @@ +<% provide(:head_title, raw(t("projects.canvas.head_title", project: @project.name))) %> +<%= render partial: "shared/sidebar" %> +<%= render partial: "shared/secondary_navigation" %> + +
+ <% if can_edit_canvas(@project) %> + <%=link_to t("projects.canvas.canvas_edit"), canvas_edit_experiment_url(@experiment), remote: true, type: "button", id: "edit-canvas-button", class: "ajax btn btn-default", "data-action" => "edit" %> + <% end %> +
+ <%=link_to canvas_full_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary active", "data-action" => "full_zoom", "data-toggle" => "button", "aria-pressed" => true do %> + + <% end %> + <%=link_to canvas_medium_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "medium_zoom" do %> + + <% end %> + <%=link_to canvas_small_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "small_zoom" do %> + + <% end %> +
+
+
+ <%= render partial: 'canvas/full_zoom', locals: { project: @project, experiment: @experiment, my_modules: @experiment.active_modules } %> +
+ + +<%= render partial: "my_modules/modals/manage_module_tags_modal", locals: { my_module: nil } %> + + +<%= javascript_include_tag("jsPlumb-2.0.4-min") %> +<%= javascript_include_tag("jsnetworkx") %> +<%= javascript_include_tag("eventPause-min") %> + +<%= javascript_include_tag("projects/canvas") %> diff --git a/app/views/shared/_sidebar.html.erb b/app/views/shared/_sidebar.html.erb index 8d7d4e779..5d510b825 100644 --- a/app/views/shared/_sidebar.html.erb +++ b/app/views/shared/_sidebar.html.erb @@ -23,9 +23,14 @@ <%= @project.name %> <% end %> - <% @experiments.each do |experiment| %> - <%= render 'shared/sidebar_elements' %> - <% end %> +
    +
  • + + + <%= @experiment.name %> + + <%= render 'shared/sidebar_elements' %> +
  • New experiment... diff --git a/app/views/shared/_sidebar_elements.html.erb b/app/views/shared/_sidebar_elements.html.erb index 19441126f..06fab15a8 100644 --- a/app/views/shared/_sidebar_elements.html.erb +++ b/app/views/shared/_sidebar_elements.html.erb @@ -1,6 +1,6 @@ -<% if experiment.active_modules.present? then %> +<% if @experiment.active_modules.present? then %>
      - <% experiment.active_module_groups.each do |my_module_group| %> + <% @experiment.active_module_groups.each do |my_module_group| %>
    • @@ -35,7 +35,7 @@ <% end %>
    • <% end %> - <% modules_without_group = experiment.modules_without_group %> + <% modules_without_group = @experiment.modules_without_group %> <% if modules_without_group.present? then %>
    • diff --git a/config/locales/en.yml b/config/locales/en.yml index 4dabda6ce..01181d3b6 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -376,8 +376,6 @@ en: restore_option: "Restore" archived_on: "Archived on" archived_on_title: "Task archived on %{date} at %{time}." - - experiments: canvas: head_title: "%{project} | Overview" canvas_edit: "Edit workflow" diff --git a/config/routes.rb b/config/routes.rb index 11b5c2db5..9ec7bbcbe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -88,13 +88,18 @@ Rails.application.routes.draw do post 'destroy', as: :destroy # Destroy multiple entries at once end end + resources :experiments, only: [:new, :create, :edit, :update, :archive] + resources :experiments, shallow: true, only: [:show] do + member do + get 'canvas' # Overview/structure for single project + get 'canvas/edit', to: 'canvas#edit' # AJAX-loaded canvas edit mode (from canvas) + get 'canvas/full_zoom', to: 'canvas#full_zoom' # AJAX-loaded canvas zoom + get 'canvas/medium_zoom', to: 'canvas#medium_zoom' # AJAX-loaded canvas zoom + get 'canvas/small_zoom', to: 'canvas#small_zoom' # AJAX-loaded canvas zoom + post 'canvas', to: 'canvas#update' # Save updated canvas action + end + end member do - get 'canvas' # Overview/structure for single project - get 'canvas/edit', to: 'canvas#edit' # AJAX-loaded canvas edit mode (from canvas) - get 'canvas/full_zoom', to: 'canvas#full_zoom' # AJAX-loaded canvas zoom - get 'canvas/medium_zoom', to: 'canvas#medium_zoom' # AJAX-loaded canvas zoom - get 'canvas/small_zoom', to: 'canvas#small_zoom' # AJAX-loaded canvas zoom - post 'canvas', to: 'canvas#update' # Save updated canvas action get 'notifications' # Notifications popup for individual project in projects index get 'samples' # Samples for single project get 'module_archive' # Module archive for single project @@ -106,8 +111,6 @@ Rails.application.routes.draw do get 'users/edit', to: 'user_projects#index_edit' end - resources :experiments, only: [:show] - # Show action is a popup (JSON) for individual module in full-zoom canvas, # as well as "module info" page for single module (HTML) resources :my_modules, path: "/modules", only: [:show, :edit, :update, :destroy] do