Merge pull request #37 from ZmagoD/zd_SCI_37

Fixing canvas, sidebar, add experiments actions
This commit is contained in:
Luka Murn 2016-07-29 09:33:54 +02:00 committed by GitHub
commit 55db93fcc1
36 changed files with 450 additions and 248 deletions

View file

@ -0,0 +1,29 @@
// Place all the behaviors and hooks related to the matching controller here.
// All this logic will automatically be available in application.js.
(function(){
// Initialize new experiment form
function initializeNewExperimentModal(){
$("#new-experiment")
.on("ajax:beforeSend", function(){
animateSpinner();
})
.on("ajax:success", function(e, data){
$('body').append($.parseHTML(data.html));
$('#new-experiment-modal').modal('show',{
backdrop: true,
keyboard: false,
});
})
.on("ajax:error", function() {
animateSpinner(null, false);
// TODO
})
.on("ajax:complete", function(){
animateSpinner(null, false);
});
}
initializeNewExperimentModal();
})();

View file

@ -0,0 +1,85 @@
class ExperimentsController < ApplicationController
include PermissionHelper
before_action :set_experiment, except: [:new, :create]
before_action :set_project, only: [:new, :create]
# except parameter could be used but it is not working.
layout :choose_layout
def new
@experiment = Experiment.new
respond_to do |format|
format.json {
render json:{
html: render_to_string( {
partial: "new_modal.html.erb"
})
}
}
end
end
def create
@experiment = Experiment.new(experiment_params)
@experiment.created_by = current_user
@experiment.last_modified_by = current_user
@experiment.project = @project
if @experiment.save
flash[:success] = t('experiments.create.success_flash', experiment: @experiment.name)
# have to change to experiments path
redirect_to root_path
else
flash[:alert] = t('experiments.create.error_flash')
redirect_to :back
end
end
def canvas
@project = @experiment.project
end
def update
@experiment.update_attributes(experiment_params)
@experiment.last_modified_by = current_user
if @experiment.save
flash[:success] = t('experiments.update.success_flash', experiment: @experiment.name)
# have to change to experiments path
redirect_to root_path
else
flash[:alert] = t('experiments.update.error_flash')
redirect_to :back
end
end
def archive_experiment
@experiment.archived = true
@experiment.archived_by = current_user
@experiment.archived_on = DateTime.now
if @experiment.save
flash[:success] = t('experiments.archive.success_flash', experiment: @experiment.name)
# have to change to experiments path
redirect_to root_path
else
flash[:alert] = t('experiments.archive.error_flash')
redirect_to :back
end
end
private
def set_experiment
@experiment = Experiment.find_by_id(params[:id])
end
def set_project
@project = Project.find_by_id(params[:project_id])
end
def experiment_params
params.require(:experiment).permit(:name, :description)
end
def choose_layout
action_name.in?(['index', 'archive']) ? 'main' : 'fluid'
end
end

View file

@ -8,7 +8,7 @@ class MyModuleTagsController < ApplicationController
@my_module_tags = @my_module.my_module_tags
@unassigned_tags = @my_module.unassigned_tags
@new_mmt = MyModuleTag.new(my_module: @my_module)
@new_tag = Tag.new(project: @my_module.project)
@new_tag = Tag.new(project: @my_module.experiment.project)
respond_to do |format|
format.json {

View file

@ -147,7 +147,7 @@ class MyModulesController < ApplicationController
# Currently not in use
Activity.create(
type_of: :archive_module,
project: @my_module.project,
project: @my_module.experiment.project,
my_module: @my_module,
user: current_user,
message: t(
@ -162,7 +162,7 @@ class MyModulesController < ApplicationController
if saved
Activity.create(
type_of: :restore_module,
project: @my_module.project,
project: @my_module.experiment.project,
my_module: @my_module,
user: current_user,
message: t(
@ -178,7 +178,7 @@ class MyModulesController < ApplicationController
if saved and description_changed then
Activity.create(
type_of: :change_module_description,
project: @my_module.project,
project: @my_module.experiment.project,
my_module: @my_module,
user: current_user,
message: t(
@ -240,7 +240,7 @@ class MyModulesController < ApplicationController
def samples
@samples_index_link = samples_index_my_module_path(@my_module, format: :json)
@organization = @my_module.project.organization
@organization = @my_module.experiment.project.organization
end
def archive
@ -293,7 +293,7 @@ class MyModulesController < ApplicationController
# AJAX actions
def samples_index
@organization = @my_module.project.organization
@organization = @my_module.experiment.project.organization
respond_to do |format|
format.html
@ -309,7 +309,7 @@ class MyModulesController < ApplicationController
@direct_upload = ENV['PAPERCLIP_DIRECT_UPLOAD'] == "true"
@my_module = MyModule.find_by_id(params[:id])
if @my_module
@project = @my_module.project
@project = @my_module.experiment.project
else
render_404
end

View file

@ -12,7 +12,6 @@ class ProjectsController < ApplicationController
before_action :check_view_notifications_permissions, only: [ :notifications ]
before_action :check_edit_permissions, only: [ :edit ]
before_action :check_module_archive_permissions, only: [:module_archive]
before_action :check_canvas_permissions, only: [:workflow]
filter_by_archived = false
@ -311,13 +310,6 @@ class ProjectsController < ApplicationController
end
end
def check_canvas_permissions
@project = Project.find_by_id(wf_params[:id])
unless can_edit_canvas(@project)
render_403
end
end
def check_module_archive_permissions
unless can_restore_archived_modules(@project)
render_403

View file

@ -366,7 +366,7 @@ module PermissionHelper
end
def can_archive_module(my_module)
is_user_or_higher_of_project(my_module.project)
is_user_or_higher_of_project(my_module.experiment.project)
end
def can_restore_module(my_module)
@ -378,11 +378,11 @@ module PermissionHelper
end
def can_add_tag_to_module(my_module)
is_user_or_higher_of_project(my_module.project)
is_user_or_higher_of_project(my_module.experiment.project)
end
def can_remove_tag_from_module(my_module)
is_user_or_higher_of_project(my_module.project)
is_user_or_higher_of_project(my_module.experiment.project)
end
def can_view_module_info(my_module)

View file

@ -15,7 +15,7 @@ module SidebarHelper
when "archive"
return module_archive_project_url(project)
else
return canvas_project_path(project)
return project_path(project)
end
end

View file

@ -131,7 +131,7 @@ class Experiment < ActiveRecord::Base
Activity.create(
type_of: :create_module,
user: current_user,
project: selfproject,
project: self.project,
my_module: m,
message: I18n.t(
"activities.create_module",
@ -489,7 +489,7 @@ class Experiment < ActiveRecord::Base
if w.length > 1
group = MyModuleGroup.new(
name: wf_names[i],
project: self,
experiment: self,
my_modules: MyModule.find(w))
group.created_by = current_user
group.save!

View file

@ -25,12 +25,12 @@ class DelayedUploaderTutorial
temp_result.save
temp_asset.save
temp_asset.post_process_file(my_module.project.organization)
temp_asset.post_process_file(my_module.experiment.project.organization)
# Create result activity
Activity.create(
type_of: :add_result,
project: my_module.project,
project: my_module.experiment.project,
my_module: my_module,
user: current_user,
created_at: temp_result.created_at,
@ -46,6 +46,6 @@ class DelayedUploaderTutorial
def self.add_step_asset(step:, current_user:, file_name:)
temp_asset = DelayedUploaderTutorial.get_asset(current_user, file_name)
step.assets << temp_asset
temp_asset.post_process_file(step.my_module.project.organization)
temp_asset.post_process_file(step.my_module.experiment.project.organization)
end
end

View file

@ -862,7 +862,7 @@ module FirstTimeDataGenerator
# Create activity
Activity.create(
type_of: :create_step,
project: my_module.project,
project: my_module.experiment.project,
my_module: my_module,
user: step.user,
created_at: created_at,
@ -876,7 +876,7 @@ module FirstTimeDataGenerator
if completed then
Activity.create(
type_of: :complete_step,
project: my_module.project,
project: my_module.experiment.project,
my_module: my_module,
user: step.user,
created_at: completed_on,
@ -907,7 +907,7 @@ module FirstTimeDataGenerator
)
Activity.create(
type_of: :add_comment_to_step,
project: my_module.project,
project: my_module.experiment.project,
my_module: my_module,
user: @user,
created_at: commented_on,

View file

@ -8,13 +8,13 @@
data-can-edit-connections="<%= can_edit_connections(@experiment) ? "yes" : "no" %>"
data-unsaved-work-text="<%=t "experiments.canvas.edit.unsaved_work" %>"
>
<%= bootstrap_form_tag url: canvas_project_url, method: "post" do |f| %>
<%= bootstrap_form_tag url: canvas_experiment_url, method: "post" do |f| %>
<div class="btn-group" role="group">
<%= f.submit class: "btn btn-primary", id: "canvas-save" do %>
<span class="visibile-xs"><%= t("experiments.canvas.edit.save_short") %></span>
<span class="hidden-xs"><%= t("experiments.canvas.edit.save") %></span>
<% end %>
<%= link_to canvas_project_path(@project), type: "button", class: "btn btn-default cancel-edit-canvas" do %>
<%= link_to canvas_experiment_path(@experiment), type: "button", class: "btn btn-default cancel-edit-canvas" do %>
<span class="hidden-xs"><%= t("experiments.canvas.edit.cancel") %></span>
<span class="glyphicon glyphicon-remove visible-xs" style="height: 16px;margin-top: 4px;">&nbsp;</span>
<% end %>

View file

@ -0,0 +1,20 @@
<!-- Edit experiment modal -->
<div class="modal" id="edit-experiment-modal" tabindex="-1" role="dialog" aria-labelledby="edit-experiment-modal-label">
<%= bootstrap_form_for [@project, @experiment], remote: true do |f| %>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="edit-eperiment-modal-label"><%= t("experiments.edit.modal_title", experiment: @experiment.name ) %></h4>
</div>
<div class="modal-body">
<%= render partial: "form.html.erb", locals: { form: f } %>
</div>
<div class="modal-footer">
<%= f.submit t("experiments.edit.modal_create"), class: "btn btn-primary" %>
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
</div>
</div>
</div>
<% end %>
</div>

View file

@ -0,0 +1,15 @@
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<%= form.text_field :name, label: t("experiments.new.name"), autofocus: true, placeholder: t("experiments.new.name_placeholder") %>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="form-group">
<%= form.text_area :description, label: t('experiments.new.description') %>
</div>
</div>
</div>

View file

@ -0,0 +1,20 @@
<!-- New experiment modal -->
<div class="modal" id="new-experiment-modal" tabindex="-1" role="dialog" aria-labelledby="new-experiment-modal-label">
<%= bootstrap_form_for [@project, @experiment] do |f| %>
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="new-eperiment-modal-label"><%= t("experiments.new.modal_title") %></h4>
</div>
<div class="modal-body">
<%= render partial: "form.html.erb", locals: { form: f } %>
</div>
<div class="modal-footer">
<%= f.submit t("experiments.new.modal_create"), class: "btn btn-primary" %>
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.cancel" %></button>
</div>
</div>
</div>
<% end %>
</div>

View file

@ -1,19 +1,19 @@
<% provide(:head_title, raw(t("projects.canvas.head_title", project: @project.name))) %>
<% provide(:head_title, raw(t("experiments.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_project_url(@project), remote: true, type: "button", id: "edit-canvas-button", class: "ajax btn btn-default", "data-action" => "edit" %>
<% if can_edit_canvas(@experiment) %>
<%=link_to t("experiments.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_project_path(@project), remote: true, type: "button", class: "ajax btn btn-primary active", "data-action" => "full_zoom", "data-toggle" => "button", "aria-pressed" => true do %>
<%=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_project_path(@project), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "medium_zoom" do %>
<%=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_project_path(@project), remote: true, type: "button", class: "ajax btn btn-primary", "data-action" => "small_zoom" do %>
<%=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>
@ -25,7 +25,7 @@
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, my_modules: @project.active_modules } %>
<%= render partial: 'canvas/full_zoom', locals: { experiment: @experiment, my_modules: @experiment.active_modules } %>
</div>
<!-- Manage tags modal -->
@ -37,3 +37,4 @@
<%= javascript_include_tag("eventPause-min") %>
<%= javascript_include_tag("projects/canvas") %>
<%= javascript_include_tag("experiments/index") %>

View file

@ -1,15 +1,15 @@
<h5 class="text-center"><%= t('projects.canvas.popups.comments_tab') %></h5>
<h5 class="text-center"><%= t('experiments.canvas.popups.comments_tab') %></h5>
<hr>
<ul class="no-style double-line content-comments">
<% if @comments.size == 0 then %>
<li class="no-comments"><em><%= t 'projects.canvas.popups.no_comments' %></em></li>
<li class="no-comments"><em><%= t 'experiments.canvas.popups.no_comments' %></em></li>
<% else %>
<%= render 'my_module_comments/list.html.erb', comments: @comments %>
<% end %>
<% if @comments.length == @per_page %>
<li class="text-center">
<a class="btn btn-default btn-more-comments" href="<%= more_comments_url %>" data-remote="true">
<%=t "projects.canvas.popups.more_comments" %>
<%=t "experiments.canvas.popups.more_comments" %>
</a>
</li>
<% end %>
@ -19,7 +19,7 @@
<li>
<hr>
<%= bootstrap_form_for :comment, url: { format: :json }, method: :post, remote: true do |f| %>
<%= f.text_field :message, hide_label: true, placeholder: t("projects.canvas.popups.comment_placeholder"), append: f.submit("+"), help: '.' %>
<%= f.text_field :message, hide_label: true, placeholder: t("experiments.canvas.popups.comment_placeholder"), append: f.submit("+"), help: '.' %>
<% end %>
</li>
</ul>

View file

@ -1,6 +1,6 @@
<h5><%=t "projects.canvas.modal_manage_tags.subtitle", module: @my_module.name %></h5>
<h5><%=t "experiments.canvas.modal_manage_tags.subtitle", module: @my_module.name %></h5>
<% if @my_module_tags.size == 0 then %>
<div class="row"><div class="col-xs-4"><em><%= t 'projects.canvas.modal_manage_tags.no_tags' %></em></div></div>
<div class="row"><div class="col-xs-4"><em><%= t 'experiments.canvas.modal_manage_tags.no_tags' %></em></div></div>
<% else %>
<ul class="list-group">
<% @my_module_tags.each_with_index do |mmt, i| tag = mmt.tag %>
@ -11,20 +11,20 @@
<h4><%= tag.name %></h4>
</div>
<div class="pull-right">
<% if can_edit_tag(@my_module.project) then %>
<%= link_to "", remote: true, class: 'btn btn-link edit-tag-link', title: t("projects.canvas.modal_manage_tags.edit_tag") do %>
<% if can_edit_tag(@my_module.experiment.project) then %>
<%= link_to "", remote: true, class: 'btn btn-link edit-tag-link', title: t("experiments.canvas.modal_manage_tags.edit_tag") do %>
<span class="glyphicon glyphicon-adjust"></span>
<% end %>
<% end %>
<% if can_remove_tag_from_module(@my_module) then %>
<%= link_to my_module_my_module_tag_path(@my_module, mmt, format: :json), method: :delete, remote: true, class: 'btn btn-link remove-tag-link', title: t("projects.canvas.modal_manage_tags.remove_tag", module: @my_module.name) do %>
<%= link_to my_module_my_module_tag_path(@my_module, mmt, format: :json), method: :delete, remote: true, class: 'btn btn-link remove-tag-link', title: t("experiments.canvas.modal_manage_tags.remove_tag", module: @my_module.name) do %>
<span class="glyphicon glyphicon-remove"></span>
<% end %>
<% end %>
<% if can_delete_tag(@my_module.project) then %>
<%= bootstrap_form_for tag, remote: true, url: project_tag_path(@my_module.project, tag, format: :json), method: :delete, html: { class: "delete-tag-form"} do |f| %>
<% if can_delete_tag(@my_module.experiment.project) then %>
<%= bootstrap_form_for tag, remote: true, url: project_tag_path(@my_module.experiment.project, tag, format: :json), method: :delete, html: { class: "delete-tag-form"} do |f| %>
<%= hidden_field_tag :my_module_id, @my_module.id %>
<%= f.button class: 'btn btn-link delete-tag-link', title: t("projects.canvas.modal_manage_tags.delete_tag") do %>
<%= f.button class: 'btn btn-link delete-tag-link', title: t("experiments.canvas.modal_manage_tags.delete_tag") do %>
<span class="glyphicon glyphicon-trash"></span>
<% end %>
<% end %>
@ -32,19 +32,19 @@
</div>
</div>
<% if can_edit_tag(@my_module.project) %>
<% if can_edit_tag(@my_module.experiment.project) %>
<div class="row tag-edit" style="display: none;">
<%= bootstrap_form_for tag, remote: true, url: project_tag_path(@my_module.project, tag, format: :json), method: :put, html: { class: "edit-tag-form" } do |f| %>
<%= bootstrap_form_for tag, remote: true, url: project_tag_path(@my_module.experiment.project, tag, format: :json), method: :put, html: { class: "edit-tag-form" } do |f| %>
<%= hidden_field_tag :my_module_id, @my_module.id %>
<div class="col-xs-7">
<%= f.text_field :name, hide_label: true %>
</div>
<div class="pull-right">
<%= f.color_picker_select :color, TAG_COLORS, class: "edit-tag-color" %>
<%= f.button class: "btn btn-link save-tag-link", title: t("projects.canvas.modal_manage_tags.save_tag") do %>
<%= f.button class: "btn btn-link save-tag-link", title: t("experiments.canvas.modal_manage_tags.save_tag") do %>
<span class="glyphicon glyphicon-ok"></span>
<% end %>
<%= link_to "", remote: true, class: 'btn btn-link cancel-tag-link', title: t("projects.canvas.modal_manage_tags.cancel_tag") do %>
<%= link_to "", remote: true, class: 'btn btn-link cancel-tag-link', title: t("experiments.canvas.modal_manage_tags.cancel_tag") do %>
<span class="glyphicon glyphicon-remove"></span>
<% end %>
</div>
@ -66,22 +66,22 @@
<%= collection_select(:my_module_tag, :tag_id, @unassigned_tags, :id, :name, {}, { class: 'selectpicker' }) %>
<%= f.button class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs"><%= t("projects.canvas.modal_manage_tags.create") %></span>
<span class="hidden-xs"><%= t("experiments.canvas.modal_manage_tags.create") %></span>
<% end %>
</div>
</div>
<% end %>
<% end %>
<% if can_create_new_tag(@my_module.project) then %>
<% if can_create_new_tag(@my_module.experiment.project) then %>
<div class="pull-right create-new-tag-btn">
<%= bootstrap_form_for [@my_module.project, @new_tag], remote: true, format: :json, html: { class: 'add-tag-form' } do |f| %>
<%= bootstrap_form_for [@my_module.experiment.project, @new_tag], remote: true, format: :json, html: { class: 'add-tag-form' } do |f| %>
<%= hidden_field_tag :my_module_id, @my_module.id %>
<%= f.hidden_field :project_id, :value => @my_module.project.id %>
<%= f.hidden_field :project_id, :value => @my_module.experiment.project.id %>
<%= f.hidden_field :name, :value => t("tags.create.new_name") %>
<%= f.hidden_field :color, :value => TAG_COLORS[0] %>
<%= f.button class: "btn btn-primary" do %>
<span class="glyphicon glyphicon-tag"></span>
<span class="hidden-xs"><%=t "projects.canvas.modal_manage_tags.create_new" %></span>
<span class="hidden-xs"><%=t "experiments.canvas.modal_manage_tags.create_new" %></span>
<% end %>
<% end %>
</div>

View file

@ -1,8 +1,8 @@
<h5 class="text-center"><%= t("projects.canvas.popups.activities_tab") %></h5>
<h5 class="text-center"><%= t("experiments.canvas.popups.activities_tab") %></h5>
<hr>
<ul class="no-style double-line content-activities">
<% if @activities.size == 0 then %>
<li><em><%= t 'projects.canvas.popups.no_activities' %></em></li>
<li><em><%= t 'experiments.canvas.popups.no_activities' %></em></li>
<% else %>
<% @activities.each do |activity| %>
<li><span class="text-muted"><%=l activity.created_at, format: :full %></span>
@ -11,5 +11,5 @@
<% end %>
<% end %>
<hr>
<li><%= link_to t("projects.canvas.popups.more_activities"), activities_my_module_path(@my_module) %></li>
<li><%= link_to t("experiments.canvas.popups.more_activities"), activities_my_module_path(@my_module) %></li>
</ul>

View file

@ -1,5 +1,5 @@
<% if @my_module.description.blank? %>
<em><%=t "projects.canvas.popups.no_description" %></em>
<em><%=t "experiments.canvas.popups.no_description" %></em>
<% else %>
<%= @my_module.description %>
<% end %>

View file

@ -4,5 +4,5 @@
<span class="glyphicon glyphicon-alert"></span>
<% end %>
<% else %>
<em><%=t "projects.canvas.full_zoom.no_due_date" %></em>
<em><%=t "experiments.canvas.full_zoom.no_due_date" %></em>
<% end %>

View file

@ -1,5 +1,5 @@
<% if @my_module.due_date.blank? %>
<em><%=t "projects.canvas.full_zoom.no_due_date" %></em>
<em><%=t "experiments.canvas.full_zoom.no_due_date" %></em>
<% else %>
<strong><%= l(@my_module.due_date, format: :full) %></strong>
<% end %>

View file

@ -1,4 +1,4 @@
<h5 class="text-center"><%=t "projects.canvas.popups.info_tab" %></h5>
<h5 class="text-center"><%=t "experiments.canvas.popups.info_tab" %></h5>
<hr>
<ul class="no-style content-module-info">
<li>
@ -9,7 +9,7 @@
<% if can_edit_module(@my_module) %>
<hr>
<li>
<%= link_to t("projects.canvas.popups.full_info"), description_my_module_path(@my_module, format: :json), class: "description-link", remote: true %>
<%= link_to t("experiments.canvas.popups.full_info"), description_my_module_path(@my_module, format: :json), class: "description-link", remote: true %>
</li>
<% end %>
</ul>

View file

@ -3,7 +3,7 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="manage-module-tags-modal-label"><%= t("projects.canvas.modal_manage_tags.head_title") %> <span id="manage-module-tags-modal-module"></span></h4>
<h4 class="modal-title" id="manage-module-tags-modal-label"><%= t("experiments.canvas.modal_manage_tags.head_title") %> <span id="manage-module-tags-modal-module"></span></h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">

View file

@ -3,16 +3,16 @@
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="manage-module-users-modal-label"><%= t("projects.canvas.full_zoom.modal_manage_users.modal_title") %> <span id="manage-module-users-modal-module"></span></h4>
<h4 class="modal-title" id="manage-module-users-modal-label"><%= t("experiments.canvas.full_zoom.modal_manage_users.modal_title") %> <span id="manage-module-users-modal-module"></span></h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<span class="pull-left">
<% if is_admin_of_organization(@project.organization) %>
<%= link_to t("projects.canvas.full_zoom.modal_manage_users.invite_users_link"), organization_path(organization_id: @project.organization.id) %>
<span><%=t "projects.canvas.full_zoom.modal_manage_users.invite_users_details", organization: @project.organization.name %></span>
<% if is_admin_of_organization(@experiment.project.organization) %>
<%= link_to t("experiments.canvas.full_zoom.modal_manage_users.invite_users_link"), organization_path(organization_id: @experiment.project.organization.id) %>
<span><%=t "experiments.canvas.full_zoom.modal_manage_users.invite_users_details", organization: @experiment.project.organization.name %></span>
<% else %>
<i><%=t "projects.canvas.full_zoom.modal_manage_users.contact_admins", organization: @project.organization.name %></i>
<i><%=t "experiments.canvas.full_zoom.modal_manage_users.contact_admins", organization: @experiment.project.organization.name %></i>
<% end %>
</span>
<button type="button" class="btn btn-default" data-dismiss="modal"><%=t "general.close" %></button>

View file

@ -13,4 +13,4 @@
</div>
</div>
<%= form.enum_btn_group :visibility, label: t("projects.index.modal_new_project.visibility"), btn_names: { hidden: t("projects.index.modal_new_project.visibility_hidden"), visible: t("projects.index.modal_new_project.visibility_visible") } %>
<%= form.enum_btn_group :visibility, label: t("projects.index.modal_new_project.visibility"), btn_names: { hidden: t("projects.index.modal_new_project.visibility_hidden"), visible: t("projects.index.modal_new_project.visibility_visible") } %>

View file

@ -33,7 +33,7 @@ data-project-users-tab-url="<%= url_for project_user_projects_path(project_id: p
<span class="glyphicon glyphicon-eye-open" aria-hidden="true" title="<%=t "projects.index.visibility_public" %>"></span>
<% end %>
<% if can_view_project(project) then %>
<%= link_to project.name, canvas_project_path(project), id: "#{project.id}-project-canvas-link" %>
<%= link_to project.name, project_path(project), id: "#{project.id}-project-canvas-link" %>
<% else %>
<%= project.name %>
<% end %>

View file

@ -1,3 +1,5 @@
<% provide(:head_title, raw(t("projects.show.head_title", project: @project.name))) %>
<%= render partial: "shared/sidebar" %>
<%= render partial: "shared/secondary_navigation" %>
TODO

View file

@ -1,13 +1,13 @@
<h5 class="text-center"><%= t('projects.canvas.popups.samples_tab') %></h5>
<h5 class="text-center"><%= t('experiments.canvas.popups.samples_tab') %></h5>
<hr>
<ul class="no-style double-line">
<% if @number_of_samples == 0 then %>
<li><em><%= t 'projects.canvas.popups.no_samples' %></em></li>
<li><em><%= t 'experiments.canvas.popups.no_samples' %></em></li>
<% else %>
<% @samples.each do |sample| %>
<li><span class="text-muted glyphicon glyphicon-triangle-right"></span><span><%= sample.name %></span></li>
<% end %>
<% end %>
<hr>
<li><%= link_to t("projects.canvas.popups.manage_samples"), samples_my_module_url(id: @my_module.id) %></li>
<li><%= link_to t("experiments.canvas.popups.manage_samples"), samples_my_module_url(id: @my_module.id) %></li>
</ul>

View file

@ -17,7 +17,7 @@
<li>
<% end %>
<% if can_view_project(@project) %>
<a href="<%= canvas_project_url(@project) %>">
<a href="<%= canvas_experiment_url(@experiment) %>">
<% end %>
<%= @project.name %>
<% if can_view_project(@project) %>
@ -150,7 +150,7 @@
<li>
<% end %>
<% if can_view_project(@project) %>
<a href="<%= canvas_project_url(@project) %>">
<a href="<%= canvas_experiment_url(@experiment) %>">
<% end %>
<%= truncate( @project.name, length: 20 ) %>
<% if can_view_project(@project) %>

View file

@ -1,4 +1,4 @@
<% content_for :sidebar do %>
<%= content_for :sidebar do %>
<div id="slide-panel" class="visible">
<div class="sidebar-header">
@ -23,69 +23,18 @@
<span title="<%= @project.name %>"><%= @project.name %></span>
<% end %>
</span>
<% if @project.active_modules.present? then %>
<ul>
<% @project.active_module_groups.each do |my_module_group| %>
<li data-module-group="<%= my_module_group.id %>">
<span>
<i></i>
<span class="line-wrap short" title="<%= my_module_group.name %>">
<%= my_module_group.name %>
</span>
<% if is_canvas? %>
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
<% if my_module_group.my_modules.present? then %>
<ul>
<% my_module_group.my_modules.sort_by{|m| m.workflow_order}.each do |my_module| %>
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
<span class="tree-link">
<% if currently_active? my_module %>
<%= my_module.name %>
<% else %>
<% if can_view_module(my_module) then %>
<%= link_to my_module.name, module_action_to_link_to(my_module), class: "module-link" %>
<% else %>
<%= my_module.name %>
<% end %>
<% end %>
<% if is_canvas? %>
<a href="#" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
</li>
<% end %>
</ul>
<% end %>
</li>
<% end %>
<% modules_without_group = @project.modules_without_group %>
<% if modules_without_group.present? then %>
<li>
<span>
<i></i>
<span class='sidebar-no-module-group'><%= t("sidebar.no_module_group") %></span>
</span>
<ul>
<% modules_without_group.each do |my_module| %>
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
<span class="tree-link">
<% if currently_active? my_module %>
<%= my_module.name %>
<% else %>
<%= link_to my_module.name, module_action_to_link_to(my_module) %>
<% end %>
<% if is_canvas? %>
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>
<ul>
<li>
<span class="tree-link line-wrap">
<i></i>
<span title="<%= @experiment.name %>"><%= @experiment.name %></span>
</span>
<%= render 'shared/sidebar_elements' %>
</ul>
</li>
<li>
<%= link_to new_project_experiment_path(@project), id: 'new-experiment', remote: true do %>
<span class="glyphicon glyphicon-plus"></span> <i><%= t('experiments.new.create') %></i></a>
<% end %>
</li>
</ul>

View file

@ -0,0 +1,64 @@
<% if @experiment.active_modules.present? then %>
<ul>
<% @experiment.active_module_groups.each do |my_module_group| %>
<li data-module-group="<%= my_module_group.id %>">
<span>
<i></i>
<span class="line-wrap short" title="<%= my_module_group.name %>">
<%= my_module_group.name %>
</span>
<% if is_canvas? %>
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
<% if my_module_group.my_modules.present? then %>
<ul>
<% my_module_group.my_modules.sort_by{|m| m.workflow_order}.each do |my_module| %>
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
<span class="tree-link">
<% if currently_active? my_module %>
<%= my_module.name %>
<% else %>
<% if can_view_module(my_module) then %>
<%= link_to my_module.name, module_action_to_link_to(my_module), class: "module-link" %>
<% else %>
<%= my_module.name %>
<% end %>
<% end %>
<% if is_canvas? %>
<a href="#" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
</li>
<% end %>
</ul>
<% end %>
</li>
<% end %>
<% modules_without_group = @experiment.modules_without_group %>
<% if modules_without_group.present? then %>
<li>
<span>
<i></i>
<span class='sidebar-no-module-group'><%= t("sidebar.no_module_group") %></span>
</span>
<ul>
<% modules_without_group.each do |my_module| %>
<li class="leaf <%= "active" if currently_active? my_module %>" data-module-id="<%= my_module.id %>">
<span class="tree-link">
<% if currently_active? my_module %>
<%= my_module.name %>
<% else %>
<%= link_to my_module.name, module_action_to_link_to(my_module) %>
<% end %>
<% if is_canvas? %>
<a href="" class="canvas-center-on"><span class="glyphicon glyphicon-map-marker"></span></a>
<% end %>
</span>
</li>
<% end %>
</ul>
</li>
<% end %>
</ul>
<% end %>

View file

@ -1,8 +1,8 @@
<h5 class="text-center"><%=t "projects.canvas.popups.users_tab" %></h5>
<h5 class="text-center"><%=t "experiments.canvas.popups.users_tab" %></h5>
<hr>
<ul class="no-style content-users">
<% if @user_my_modules.size == 0 then %>
<li><em><%= t "projects.canvas.popups.no_users" %></em></li>
<li><em><%= t "experiments.canvas.popups.no_users" %></em></li>
<% else %>
<% @user_my_modules.each_with_index do |user_my_module, i| %>
<% user = user_my_module.user %>
@ -14,9 +14,9 @@
</div>
<div class="col-xs-10">
<span><%= user.full_name %></span><br>
<span class="text-muted" title="<%=t "projects.canvas.popups.module_user_join_full", user: user.full_name, date: l(user_my_module.created_at, format: :full_date), time: l(user_my_module.created_at, format: :time) %>">
<span class="text-muted" title="<%=t "experiments.canvas.popups.module_user_join_full", user: user.full_name, date: l(user_my_module.created_at, format: :full_date), time: l(user_my_module.created_at, format: :time) %>">
<em>
<%=t "projects.canvas.popups.module_user_join", date: l(user_my_module.created_at, format: :full_date) %>
<%=t "experiments.canvas.popups.module_user_join", date: l(user_my_module.created_at, format: :full_date) %>
</em>
</span>
</div>
@ -28,6 +28,6 @@
<% if can_edit_users_on_module(@my_module) then %>
<p>
<hr>
<%= link_to t('projects.canvas.popups.manage_users'), my_module_users_edit_path(@my_module, format: :json), remote: true, class: "manage-users-link" %>
<%= link_to t('experiments.canvas.popups.manage_users'), my_module_users_edit_path(@my_module, format: :json), remote: true, class: "manage-users-link" %>
</p>
<% end %>

View file

@ -1,7 +1,7 @@
<ul class="no-style">
<% if @user_my_modules.size == 0 then %>
<li><em><%= t 'projects.canvas.full_zoom.modal_manage_users.no_users' %></em></li>
<li><em><%= t 'experiments.canvas.full_zoom.modal_manage_users.no_users' %></em></li>
<% else %>
<% @user_my_modules.each_with_index do |umm, i| user = umm.user %>
<li>
@ -14,8 +14,8 @@
<div class="col-xs-4">
<span><%= user.full_name %></span>
<br><span class="text-muted" title="<%=t "projects.canvas.full_zoom.modal_manage_users.user_join_full", user: user.full_name, date: l(umm.created_at, format: :full_date), time: l(umm.created_at, format: :time) %>">
<em><%=t "projects.canvas.full_zoom.modal_manage_users.user_join", date: l(umm.created_at, format: :full_date) %></em>
<br><span class="text-muted" title="<%=t "experiments.canvas.full_zoom.modal_manage_users.user_join_full", user: user.full_name, date: l(umm.created_at, format: :full_date), time: l(umm.created_at, format: :time) %>">
<em><%=t "experiments.canvas.full_zoom.modal_manage_users.user_join", date: l(umm.created_at, format: :full_date) %></em>
</span>
</div>
@ -43,7 +43,7 @@
<div class="col-xs-2">
<%= f.button class: 'btn btn-primary' do %>
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs"><%= t("projects.canvas.full_zoom.modal_manage_users.create") %></span>
<span class="hidden-xs"><%= t("experiments.canvas.full_zoom.modal_manage_users.create") %></span>
<% end %>
</div>
<% end %>

View file

@ -35,6 +35,7 @@ Rails.application.config.assets.precompile += %w( samples/sample_datatable.js )
Rails.application.config.assets.precompile += %w( projects/index.js )
Rails.application.config.assets.precompile += %w( samples/samples_importer.js )
Rails.application.config.assets.precompile += %w( projects/canvas.js )
Rails.application.config.assets.precompile += %w( experiments/index.js )
Rails.application.config.assets.precompile += %w( reports/index.js )
Rails.application.config.assets.precompile += %w( reports/new.js )
Rails.application.config.assets.precompile += %w( protocols/index.js )

View file

@ -377,95 +377,6 @@ en:
archived_on: "Archived on"
archived_on_title: "Task archived on %{date} at %{time}."
experiments:
canvas:
head_title: "%{project} | Overview"
canvas_edit: "Edit workflow"
modal_manage_tags:
head_title: "Manage tags for"
subtitle: "Showing tags of task %{module}"
no_tags: "No tags!"
edit_tag: "Edit tag."
remove_tag: "Remove tag from task %{module}."
delete_tag: "Permanently delete tag from all tasks."
save_tag: "Save tag."
cancel_tag: "Cancel changes to the tag."
create: "Add tag"
create_new: "Create new tag"
edit:
new_module: "New task"
new_module_hover: "Drag me onto canvas"
save: "Save workflow"
save_short: "Save"
cancel: "Cancel"
unsaved_work: "Are you sure you want to leave this page? All unsaved data will be lost."
drag_connections: "Drag connection/s from here"
options_header: "Options"
edit_module: "Rename task"
edit_module_group: "Rename workflow"
clone_module: "Clone task"
clone_module_group: "Clone workflow"
delete_module: "Archive task"
delete_module_group: "Archive workflow"
modal_new_module:
title: "Add new task"
name: "Task name"
name_placeholder: "My task"
confirm: "Add task"
error_length: "Name must contain from 2 to 50 characters."
error_invalid: "Name contains invalid characters ('|')."
error_whitespaces: "Name cannot be blank."
modal_edit_module:
title: "Rename task"
name: "Task name"
confirm: "Rename task"
modal_edit_module_group:
title: "Rename workflow"
name: "Workflow name"
confirm: "Rename workflow"
modal_delete_module:
title: "Archive task"
confirm: "Archive task"
message: "Are you sure you wish to archive task %{module}? Task's samples and position will be removed."
modal_delete_module_group:
title: "Archive workflow"
confirm: "Archive workflow"
message: "Are you sure you wish to archive the workflow task %{module} belongs to? All workflow tasks' samples and positions will be removed."
popups:
info_tab: "Task info"
no_description: "This task has no description."
full_info: "Edit description"
users_tab: "Assigned users"
no_users: "This task has no assigned users."
manage_users: "Manage users"
module_user_join: "Joined on %{date}."
module_user_join_full: "%{user} joined on %{date} at %{time}."
activities_tab: "Activity"
no_activities: "No activities!"
more_activities: "All activities"
comments_tab: "Comments"
no_comments: "No comments!"
more_comments: "More Comments"
comment_placeholder: "Your Message"
new_comment: "New comment"
samples_tab: "Samples"
no_samples: "No samples!"
manage_samples: "Manage samples"
full_zoom:
due_date: "Due date"
no_due_date: "not set"
modal_manage_users:
modal_title: "Manage users for"
no_users: "No users"
user_join: "Joined on %{date}."
user_join_full: "%{user} joined on %{date} at %{time}."
create: "Add"
invite_users_link: "Invite users"
invite_users_details: "to team %{organization}."
contact_admins: "To invite additional users to team %{organization}, contact its administrator/s."
update:
success_flash: "Project successfully updated."
user_organizations:
enums:
role:
@ -661,6 +572,114 @@ en:
no_activities: "There are no activities for this task."
more_activities: "Load older activities"
experiments:
new:
create: 'New experiment...'
modal_title: 'Create new experiment'
modal_create: 'Create experiment'
name: 'Experiment name'
name_placeholder: 'My experiment'
description: 'Description'
edit:
modal_title: 'Edit experiment %{experiment}'
modal_create: 'Update experiment'
create:
success_flash: "Successfully created experiment %{experiment}"
error_flash: 'Could not create a new experiment.'
update:
success_flash: "Successfully updated experiment %{experiment}"
error_flash: 'Could not update the experiment.'
archive:
success_flash: "Successfully archived experiment %{experiment}"
error_flash: 'Could not archive the experiment.'
canvas:
head_title: "%{project} | Overview"
canvas_edit: "Edit workflow"
modal_manage_tags:
head_title: "Manage tags for"
subtitle: "Showing tags of task %{module}"
no_tags: "No tags!"
edit_tag: "Edit tag."
remove_tag: "Remove tag from task %{module}."
delete_tag: "Permanently delete tag from all tasks."
save_tag: "Save tag."
cancel_tag: "Cancel changes to the tag."
create: "Add tag"
create_new: "Create new tag"
edit:
new_module: "New task"
new_module_hover: "Drag me onto canvas"
save: "Save workflow"
save_short: "Save"
cancel: "Cancel"
unsaved_work: "Are you sure you want to leave this page? All unsaved data will be lost."
drag_connections: "Drag connection/s from here"
options_header: "Options"
edit_module: "Rename task"
edit_module_group: "Rename workflow"
clone_module: "Clone task"
clone_module_group: "Clone workflow"
delete_module: "Archive task"
delete_module_group: "Archive workflow"
modal_new_module:
title: "Add new task"
name: "Task name"
name_placeholder: "My task"
confirm: "Add task"
error_length: "Name must contain from 2 to 50 characters."
error_invalid: "Name contains invalid characters ('|')."
error_whitespaces: "Name cannot be blank."
modal_edit_module:
title: "Rename task"
name: "Task name"
confirm: "Rename task"
modal_edit_module_group:
title: "Rename workflow"
name: "Workflow name"
confirm: "Rename workflow"
modal_delete_module:
title: "Archive task"
confirm: "Archive task"
message: "Are you sure you wish to archive task %{module}? Task's samples and position will be removed."
modal_delete_module_group:
title: "Archive workflow"
confirm: "Archive workflow"
message: "Are you sure you wish to archive the workflow task %{module} belongs to? All workflow tasks' samples and positions will be removed."
popups:
info_tab: "Task info"
no_description: "This task has no description."
full_info: "Edit description"
users_tab: "Assigned users"
no_users: "This task has no assigned users."
manage_users: "Manage users"
module_user_join: "Joined on %{date}."
module_user_join_full: "%{user} joined on %{date} at %{time}."
activities_tab: "Activity"
no_activities: "No activities!"
more_activities: "All activities"
comments_tab: "Comments"
no_comments: "No comments!"
more_comments: "More Comments"
comment_placeholder: "Your Message"
new_comment: "New comment"
samples_tab: "Samples"
no_samples: "No samples!"
manage_samples: "Manage samples"
full_zoom:
due_date: "Due date"
no_due_date: "not set"
modal_manage_users:
modal_title: "Manage users for"
no_users: "No users"
user_join: "Joined on %{date}."
user_join_full: "%{user} joined on %{date} at %{time}."
create: "Add"
invite_users_link: "Invite users"
invite_users_details: "to team %{organization}."
contact_admins: "To invite additional users to team %{organization}, contact its administrator/s."
update:
success_flash: "Project successfully updated."
my_module_tags:
new:
head_title: "%{project} | %{module} | Add tag"

View file

@ -88,17 +88,12 @@ Rails.application.routes.draw do
post 'destroy', as: :destroy # Destroy multiple entries at once
end
end
resources :experiments, only: [:new, :create, :edit, :update, :archive], defaults: { format: 'json' }
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
post 'samples_index' # Renders sample datatable for single project (ajax action)
get 'experiment_archive' # Experiment archive for single project
post :delete_samples, constraints: CommitParamRouting.new(MyModulesController::DELETE_SAMPLES), action: :delete_samples
end
@ -106,7 +101,17 @@ Rails.application.routes.draw do
get 'users/edit', to: 'user_projects#index_edit'
end
resources :experiments, only: [:show]
resources :experiments, only: [:show] do
member do
get 'canvas' # Overview/structure for single experiment
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 'module_archive' # Module archive for single experiment
end
end
# Show action is a popup (JSON) for individual module in full-zoom canvas,
# as well as "module info" page for single module (HTML)