mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-10 15:14:33 +08:00
Prepare views for experiment archive
This commit is contained in:
parent
775a39344c
commit
5a023483d7
5 changed files with 16 additions and 57 deletions
|
@ -274,17 +274,11 @@ module PermissionHelper
|
|||
end
|
||||
|
||||
def can_archive_project(project)
|
||||
is_owner_of_project(project) ||
|
||||
is_user_of_project(project) ||
|
||||
is_admin_of_organization(project.organization)
|
||||
is_owner_of_project(project)
|
||||
end
|
||||
|
||||
def can_restore_project(project)
|
||||
project.archived? && (
|
||||
is_owner_of_project(project) ||
|
||||
is_user_of_project(project) ||
|
||||
is_admin_of_organization(project.organization)
|
||||
)
|
||||
project.archived? && is_owner_of_project(project)
|
||||
end
|
||||
|
||||
def can_add_user_to_project(project)
|
||||
|
|
|
@ -108,6 +108,10 @@ class Project < ActiveRecord::Base
|
|||
experiments.is_archived(false)
|
||||
end
|
||||
|
||||
def archived_experiments
|
||||
experiments.is_archived(true)
|
||||
end
|
||||
|
||||
def project_my_modules
|
||||
MyModule.where('"experiment_id" IN (?)', experiments.select(:id))
|
||||
end
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
<% provide(:head_title, raw(t("projects.module_archive.head_title", project: @project.name))) %>
|
||||
<% provide(:head_title, raw(t("projects.experiment_archive.head_title", project: @project.name))) %>
|
||||
<%= render partial: "shared/sidebar" %>
|
||||
<%= render partial: "shared/secondary_navigation" %>
|
||||
|
||||
<% if @project.archived_modules.count > 0 %>
|
||||
<% if @project.archived_experiments.count > 0 %>
|
||||
<div class="row">
|
||||
<% @project.archived_modules.each_with_index do |my_module, i| %>
|
||||
<% @project.archived_experiments.each_with_index do |experiment, i| %>
|
||||
<div class="col-lg-2 col-md-3 col-sm-4 col-xs-6">
|
||||
<%= render partial: "projects/module_archive/my_module.html.erb", locals: { my_module: my_module} %>
|
||||
<%= render partial: "projects/experiment_archive/experiment.html.erb", locals: { experiment: experiment} %>
|
||||
</div>
|
||||
<% if (i+1) % 6 == 0 %>
|
||||
<div class="clearfix visible-lg-block"></div>
|
||||
|
@ -22,7 +22,7 @@
|
|||
<% else %>
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<em><%=t "projects.module_archive.no_archived_modules" %></em>
|
||||
<em><%=t "projects.experiment_archive.no_archived_experiments" %></em>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
<div class="panel panel-default panel-archive">
|
||||
|
||||
<div class="panel-heading">
|
||||
|
||||
<div class="dropdown pull-right">
|
||||
<button class="btn btn-link dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<% my_module_form = nil %>
|
||||
<%= form_for my_module, method: :patch, format: :html do |f| %>
|
||||
<% my_module_form = f %>
|
||||
<%= f.hidden_field :archived, value: false %>
|
||||
<% end %>
|
||||
<ul class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1">
|
||||
<li class="dropdown-header"><%=t "projects.index.options_header" %></li>
|
||||
<% if can_restore_module(my_module) %>
|
||||
<li><a href="#" class="form-submit-link" data-submit-form="<%= my_module_form.options[:html][:id] %>"><%= t "projects.module_archive.restore_option" %></a></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<h3 class="panel-title"><%= my_module.name %></h3>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-xs-6">
|
||||
<%=t "projects.module_archive.archived_on" %>
|
||||
</div>
|
||||
<div class="col-xs-6">
|
||||
<span title="<%=t "projects.module_archive.archived_on_title", date: l(my_module.archived_on, format: :full_date), time: l(my_module.archived_on, format: :time) %>">
|
||||
<%=l my_module.archived_on, format: :full_date %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
|
@ -386,12 +386,12 @@ en:
|
|||
name: "Comments for step %{step}"
|
||||
no_comments: "No comments"
|
||||
comment_prefix: "%{user} on %{date} at %{time}:"
|
||||
module_archive:
|
||||
head_title: "%{project} | Archived tasks"
|
||||
no_archived_modules: "No archived tasks!"
|
||||
experiment_archive:
|
||||
head_title: "%{project} | Archived experiments"
|
||||
no_archived_experiments: "No archived experiments!"
|
||||
restore_option: "Restore"
|
||||
archived_on: "Archived on"
|
||||
archived_on_title: "Task archived on %{date} at %{time}."
|
||||
archived_on_title: "Experiment archived on %{date} at %{time}."
|
||||
|
||||
user_organizations:
|
||||
enums:
|
||||
|
|
Loading…
Add table
Reference in a new issue