mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-27 01:05:21 +08:00
[fixes SCI-304], [fixes SCI-37]
This commit is contained in:
parent
c7e1dea1bc
commit
caa80642c0
9 changed files with 104 additions and 28 deletions
|
@ -25,5 +25,29 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Initialize edit experiment form
|
||||
function initializeEditExperimentModal(){
|
||||
$("#edit-experiment")
|
||||
.on("ajax:beforeSend", function(){
|
||||
animateSpinner();
|
||||
})
|
||||
.on("ajax:success", function(e, data){
|
||||
$('body').append($.parseHTML(data.html));
|
||||
$('#edit-experiment-modal').modal('show',{
|
||||
backdrop: true,
|
||||
keyboard: false,
|
||||
});
|
||||
})
|
||||
.on("ajax:error", function() {
|
||||
animateSpinner(null, false);
|
||||
// TODO
|
||||
})
|
||||
.on("ajax:complete", function(){
|
||||
animateSpinner(null, false);
|
||||
});
|
||||
}
|
||||
|
||||
// init modals
|
||||
initializeNewExperimentModal();
|
||||
initializeEditExperimentModal();
|
||||
})();
|
||||
|
|
|
@ -26,9 +26,9 @@ class ExperimentsController < ApplicationController
|
|||
@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
|
||||
flash[:success] = t('experiments.create.success_flash',
|
||||
experiment: @experiment.name)
|
||||
redirect_to project_path(@project)
|
||||
else
|
||||
flash[:alert] = t('experiments.create.error_flash')
|
||||
redirect_to :back
|
||||
|
@ -39,27 +39,40 @@ class ExperimentsController < ApplicationController
|
|||
@project = @experiment.project
|
||||
end
|
||||
|
||||
def edit
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: {
|
||||
html: render_to_string(
|
||||
partial: 'edit_modal.html.erb'
|
||||
)
|
||||
}
|
||||
end
|
||||
end
|
||||
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
|
||||
flash[:success] = t('experiments.update.success_flash',
|
||||
experiment: @experiment.name)
|
||||
redirect_to canvas_experiment_path(@experiment)
|
||||
else
|
||||
flash[:alert] = t('experiments.update.error_flash')
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
||||
|
||||
def archive_experiment
|
||||
def archive
|
||||
@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
|
||||
flash[:success] = t('experiments.archive.success_flash',
|
||||
experiment: @experiment.name)
|
||||
redirect_to project_path(@experiment.project)
|
||||
else
|
||||
flash[:alert] = t('experiments.archive.error_flash')
|
||||
redirect_to :back
|
||||
|
@ -87,6 +100,6 @@ class ExperimentsController < ApplicationController
|
|||
end
|
||||
|
||||
def choose_layout
|
||||
action_name.in?(['index', 'archive']) ? 'main' : 'fluid'
|
||||
action_name.in?(%w(index archive)) ? 'main' : 'fluid'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ class UserMyModulesController < ApplicationController
|
|||
)
|
||||
Activity.create(
|
||||
user: current_user,
|
||||
project: @um.my_module.project,
|
||||
project: @um.my_module.experiment.project,
|
||||
my_module: @um.my_module,
|
||||
message: message,
|
||||
type_of: :assign_user_to_module
|
||||
|
@ -116,7 +116,7 @@ class UserMyModulesController < ApplicationController
|
|||
|
||||
Activity.create(
|
||||
user: current_user,
|
||||
project: @um.my_module.project,
|
||||
project: @um.my_module.experiment.project,
|
||||
my_module: @um.my_module,
|
||||
message: message,
|
||||
type_of: :unassign_user_from_module
|
||||
|
@ -159,7 +159,7 @@ class UserMyModulesController < ApplicationController
|
|||
@my_module = MyModule.find_by_id(params[:my_module_id])
|
||||
|
||||
if @my_module
|
||||
@project = @my_module.project
|
||||
@project = @my_module.experiment.project
|
||||
else
|
||||
render_404
|
||||
end
|
||||
|
|
|
@ -343,7 +343,7 @@ module PermissionHelper
|
|||
end
|
||||
|
||||
def can_restore_experiment(experiment)
|
||||
experiment.archived? and is_user_or_higher_of_project(experiment.project)
|
||||
experiment.archived? && is_user_or_higher_of_project(experiment.project)
|
||||
end
|
||||
|
||||
# ---- WORKFLOW PERMISSIONS ----
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!-- 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| %>
|
||||
<%= bootstrap_form_for [@project, @experiment] do |f| %>
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
|
|
@ -4,9 +4,47 @@
|
|||
|
||||
<div id="diagram-buttons" data-intro="<%=t ('tutorial.canvas_click_edit_workflow_html') %>" data-step="5" data-position="left">
|
||||
<% 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" %>
|
||||
<%=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">
|
||||
<% if can_create_experiment(@project) %>
|
||||
<%= link_to t('experiments.new.create'),
|
||||
new_project_experiment_url(@project),
|
||||
remote: true,
|
||||
type: "button",
|
||||
id: 'new-experiment',
|
||||
class: "btn btn-primary" %>
|
||||
<% end %>
|
||||
<!-- pexperiment actions -->
|
||||
<span class="dropdown">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="exActionsMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<span class="hidden-xs"><%= t'experiments.canvas.actions' %></span>
|
||||
<span class="visible-xs-inline"><i class="glyphicon glyphicon-sort"></i></span>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="exActionsMenu">
|
||||
<% if can_create_experiment(@project) %>
|
||||
<li><%= link_to t('experiments.edit.label_title'),
|
||||
edit_project_experiment_url(@project, @experiment),
|
||||
remote: true,
|
||||
type: 'button',
|
||||
id: 'edit-experiment' %></li>
|
||||
<% end %>
|
||||
<% if can_archive_experiment(@experiment) %>
|
||||
<li><%= link_to t('experiments.archive.label_title'),
|
||||
archive_experiment_url(@experiment),
|
||||
type: 'button',
|
||||
data: { confirm: t('experiments.canvas.archive_confirm') } %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</span>
|
||||
|
||||
<div id="zoom-level-buttons" class="btn-group pull-right" 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 %>
|
||||
|
@ -16,8 +54,9 @@
|
|||
<%=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>
|
||||
|
||||
<div id="canvas-container" data-project-id="<%= @project.id %>"
|
||||
data-step="4" data-position='left'
|
||||
data-intro="<%=t 'tutorial.canvas_overview_html' %>"
|
||||
|
|
|
@ -14,9 +14,4 @@
|
|||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<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>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
|
|
@ -576,7 +576,7 @@ en:
|
|||
|
||||
experiments:
|
||||
new:
|
||||
create: 'New experiment...'
|
||||
create: 'New experiment'
|
||||
modal_title: 'Create new experiment'
|
||||
modal_create: 'Create experiment'
|
||||
name: 'Experiment name'
|
||||
|
@ -585,6 +585,7 @@ en:
|
|||
edit:
|
||||
modal_title: 'Edit experiment %{experiment}'
|
||||
modal_create: 'Update experiment'
|
||||
label_title: "Edit details"
|
||||
create:
|
||||
success_flash: "Successfully created experiment %{experiment}"
|
||||
error_flash: 'Could not create a new experiment.'
|
||||
|
@ -594,9 +595,12 @@ en:
|
|||
archive:
|
||||
success_flash: "Successfully archived experiment %{experiment}"
|
||||
error_flash: 'Could not archive the experiment.'
|
||||
label_title: 'Archive'
|
||||
canvas:
|
||||
archive_confirm: "Are you sure to archive this experiment?"
|
||||
actions: 'Actions'
|
||||
head_title: "%{project} | Overview"
|
||||
canvas_edit: "Edit workflow"
|
||||
canvas_edit: "Edit experiment"
|
||||
modal_manage_tags:
|
||||
head_title: "Manage tags for"
|
||||
subtitle: "Showing tags of task %{module}"
|
||||
|
|
|
@ -88,7 +88,7 @@ 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' }
|
||||
resources :experiments, only: [:new, :create, :edit, :update], defaults: { format: 'json' }
|
||||
member do
|
||||
get 'notifications' # Notifications popup for individual project in projects index
|
||||
get 'samples' # Samples for single project
|
||||
|
@ -110,6 +110,7 @@ Rails.application.routes.draw do
|
|||
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
|
||||
get 'archive' # archive experiment
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue