Connect experiment options to the table view [SCI-7554] (#4692)

This commit is contained in:
ajugo 2022-12-07 14:51:48 +01:00 committed by GitHub
parent 4b83f77c5b
commit add6554732
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 47 deletions

View file

@ -46,3 +46,41 @@
}
}
}
.dropdown-experiment-actions,
.my-module-menu {
.divider-label {
@include font-small;
color: $color-silver-chalice;
padding: .25em 1em;
&.footer {
border-top: 1px solid $color-concrete;
padding-top: .5em;
}
}
li {
@include font-button;
cursor: pointer;
padding: .5em 1em;
white-space: nowrap;
.fas {
display: inline-block;
margin-right: .25em;
width: 18px;
}
&:hover:not(.divider-label) {
background: $color-concrete;
}
a {
display: inline-block;
margin: -.5em -1em;
padding: .5em 1em;
width: calc(100% + 2em);
}
}
}

View file

@ -427,40 +427,6 @@
margin-bottom: 0;
}
.my-module-menu {
.dropdown-menu {
.divider-label {
@include font-small;
color: $color-silver-chalice;
padding: .25em 1em;
}
li {
@include font-button;
cursor: pointer;
padding: .5em 1em;
white-space: nowrap;
.fas {
display: inline-block;
margin-right: .25em;
width: 18px;
}
&:hover:not(.divider-label) {
background: $color-concrete;
}
a {
display: inline-block;
margin: -.5em -1em;
padding: .5em 1em;
width: calc(100% + 2em);
}
}
}
}
&.archived {
.table-body-cell {
background-color: $color-concrete;

View file

@ -224,7 +224,8 @@ class ExperimentsController < ApplicationController
format.json do
render json: {
html: render_to_string(
partial: 'clone_modal.html.erb'
partial: 'clone_modal.html.erb',
locals: { view_mode: params[:view_mode] }
)
}
end
@ -243,7 +244,8 @@ class ExperimentsController < ApplicationController
if service.succeed?
flash[:success] = t('experiments.clone.success_flash',
experiment: @experiment.name)
redirect_to canvas_experiment_path(service.cloned_experiment)
redirect_to canvas_experiment_path(service.cloned_experiment) if params[:view_mode] == 'canvas'
redirect_to table_experiment_path(service.cloned_experiment) if params[:view_mode] == 'table'
else
flash[:error] = t('experiments.clone.error_flash',
experiment: @experiment.name)
@ -274,14 +276,13 @@ class ExperimentsController < ApplicationController
if service.succeed?
flash[:success] = t('experiments.move.success_flash',
experiment: @experiment.name)
path = canvas_experiment_url(@experiment)
status = :ok
else
message = service.errors.values.join(', ')
status = :unprocessable_entity
end
render json: { message: message, path: path }, status: status
render json: { message: message }, status: status
end
def move_modules_modal

View file

@ -1,7 +1,7 @@
<div class="modal" id="clone-experiment-modal-<%= @experiment.id %>" tabindex="-1" role="dialog" aria-labelledby="clone-experiment-modal-label">
<div class="modal-dialog" role="document">
<div class="modal-content">
<%= bootstrap_form_for @experiment, url: clone_experiment_path(@experiment), method: :post do |f| %>
<%= bootstrap_form_for @experiment, url: clone_experiment_path(@experiment, :view_mode=>view_mode), method: :post do |f| %>
<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="clone-experiment-modal-label"><%= t("experiments.clone.modal_title", experiment: @experiment.name ) %></h5>

View file

@ -3,6 +3,10 @@
aria-labelledby="exActionsMenu-<%= experiment.id %>"
data-id="<%= experiment.id %>">
<div class="divider-label">
<%= t('experiments.experiment_actions') %>
</div>
<% if can_manage_experiment?(experiment) && !archived %>
<li>
<%= link_to edit_experiment_url(experiment),
@ -15,10 +19,10 @@
<% end %>
</li>
<% end %>
<li data-hook="experiment-actions-second-child"></li>
<% if can_clone_experiment?(experiment) && !archived %>
<li>
<%= link_to clone_modal_experiment_url(experiment),
<%= link_to clone_modal_experiment_url(experiment, :view_mode=>action_name),
remote: true, type: 'button',
class: 'clone-experiment' do %>
<i class="fas fa-copy"></i>
@ -72,9 +76,8 @@
<li><a href="#" class="form-submit-link" data-turbolinks="false" data-submit-form="<%= experiment_form.options[:html][:id] %>">
<i class="fas fa-undo"></i><%= t "projects.experiment_archive.restore_option" %></a></li>
<% end %>
<li class="form-dropdown-item">
<div class="form-dropdown-item-info">
<small><%= t('experiments.experiment_id') %>: <strong><%= experiment.code %></strong></small>
<div class="divider-label footer">
<%= t('experiments.experiment_id') %>: <strong><%= experiment.code %></strong>
</div>
</li>
</ul>

View file

@ -58,7 +58,7 @@
<span class="caret"></span>
</button>
<%= render partial: 'experiments/dropdown_actions.html.erb',
locals: { project: @project, experiment: @experiment } %>
locals: { project: @project, experiment: @experiment, action_name: action_name } %>
</span>
<% end %>
<% if action_name == 'table' %>

View file

@ -63,3 +63,4 @@
<%= javascript_include_tag("my_modules/tags") %>
<%= javascript_include_tag("experiments/table") %>
<%= javascript_include_tag("experiments/dropdown_actions") %>

View file

@ -1214,6 +1214,7 @@ en:
experiments:
id: "ID"
experiment_id: "Experiment ID"
experiment_actions: "EXPERIMENT ACTIONS"
header:
cards: "Cards"
table: "Table"