mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
added canvas under experiments
This commit is contained in:
parent
a17106b883
commit
54c4051906
9 changed files with 67 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -23,7 +23,8 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
def canvas
|
||||
@project = @experiment.project
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<%= 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" %>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<% if can_edit_module(my_module) %>
|
||||
|
|
39
app/views/experiments/canvas.html.erb
Normal file
39
app/views/experiments/canvas.html.erb
Normal file
|
@ -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" %>
|
||||
|
||||
<div id="diagram-buttons" data-intro="<%=t ('tutorial.canvas_click_edit_workflow_html') %>" data-step="5" data-position="left">
|
||||
<% 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 %>
|
||||
<div id="zoom-level-buttons" class="btn-group" data-toggle="buttons">
|
||||
<%=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 %>
|
||||
<span class="glyphicon glyphicon-th-large" aria-hidden="true" ></span>
|
||||
<% end %>
|
||||
<%=link_to canvas_medium_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "medium_zoom" do %>
|
||||
<span class="glyphicon glyphicon-th-list" aria-hidden="true"></span>
|
||||
<% end %>
|
||||
<%=link_to canvas_small_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "small_zoom" do %>
|
||||
<span class="glyphicon glyphicon-th" aria-hidden="true"></span>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>"
|
||||
data-step="4" data-position='left'
|
||||
data-intro="<%=t 'tutorial.canvas_overview_html' %>"
|
||||
data-sidebar-step-text="<%=t 'tutorial.sidebar_html' %>"
|
||||
data-sidebar-click-module-step-text="<%=t 'tutorial.sidebar_click_module_html' %>"
|
||||
data-edit-workflow-step-text="<%=t 'tutorial.edit_workflow_html' %>"
|
||||
data-edit-workflow-click-save-step-text="<%=t 'tutorial.edit_workflow_click_save_html' %>">
|
||||
<%= render partial: 'canvas/full_zoom', locals: { project: @project, experiment: @experiment, my_modules: @experiment.active_modules } %>
|
||||
</div>
|
||||
|
||||
<!-- Manage tags modal -->
|
||||
<%= render partial: "my_modules/modals/manage_module_tags_modal", locals: { my_module: nil } %>
|
||||
|
||||
<!-- Include all the neccesary JS libraries -->
|
||||
<%= javascript_include_tag("jsPlumb-2.0.4-min") %>
|
||||
<%= javascript_include_tag("jsnetworkx") %>
|
||||
<%= javascript_include_tag("eventPause-min") %>
|
||||
|
||||
<%= javascript_include_tag("projects/canvas") %>
|
|
@ -23,9 +23,14 @@
|
|||
<span title="<%= @project.name %>"><%= @project.name %></span>
|
||||
<% end %>
|
||||
</span>
|
||||
<% @experiments.each do |experiment| %>
|
||||
<%= render 'shared/sidebar_elements' %>
|
||||
<% end %>
|
||||
<ul>
|
||||
<li class="<%= 'active' if not is_module_page? %>" >
|
||||
<span class="tree-link line-wrap">
|
||||
<i></i>
|
||||
<span title="<%= @experiment.name %>"><%= @experiment.name %></span>
|
||||
</span>
|
||||
<%= render 'shared/sidebar_elements' %>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#"><span class="glyphicon glyphicon-plus"></span> <i>New experiment...</i></a>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% if experiment.active_modules.present? then %>
|
||||
<% if @experiment.active_modules.present? then %>
|
||||
<ul>
|
||||
<% experiment.active_module_groups.each do |my_module_group| %>
|
||||
<% @experiment.active_module_groups.each do |my_module_group| %>
|
||||
<li data-module-group="<%= my_module_group.id %>">
|
||||
<span>
|
||||
<i></i>
|
||||
|
@ -35,7 +35,7 @@
|
|||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
<% modules_without_group = experiment.modules_without_group %>
|
||||
<% modules_without_group = @experiment.modules_without_group %>
|
||||
<% if modules_without_group.present? then %>
|
||||
<li>
|
||||
<span>
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue