mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-27 01:05:21 +08:00
fixes search
This commit is contained in:
parent
efe031d766
commit
d7f514db09
21 changed files with 110 additions and 117 deletions
|
@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
|
|||
helper_method :current_organization
|
||||
before_action :generate_intro_tutorial, if: :is_current_page_root?
|
||||
around_action :set_time_zone, if: :current_user
|
||||
layout "main"
|
||||
layout 'main'
|
||||
|
||||
def forbidden
|
||||
render_403
|
||||
|
@ -20,7 +20,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def is_current_page_root?
|
||||
controller_name == "projects" && action_name == "index"
|
||||
controller_name == 'projects' && action_name == 'index'
|
||||
end
|
||||
|
||||
# Sets current organization for all controllers
|
||||
|
|
|
@ -55,6 +55,7 @@ class ExperimentsController < ApplicationController
|
|||
|
||||
def canvas
|
||||
@project = @experiment.project
|
||||
current_organization_switch(@project.organization)
|
||||
end
|
||||
|
||||
def edit
|
||||
|
|
|
@ -23,10 +23,11 @@ class ProjectsController < ApplicationController
|
|||
DELETE_SAMPLES = I18n.t("samples.delete_samples")
|
||||
|
||||
def index
|
||||
@current_organization_id = params[:organization].to_i
|
||||
@current_organization_id = current_organization.id
|
||||
@current_sort = params[:sort].to_s
|
||||
@projects_by_orgs = current_user.projects_by_orgs(
|
||||
@current_organization_id, @current_sort, @filter_by_archived)
|
||||
@projects_by_orgs = current_user.projects_by_orgs(@current_organization_id,
|
||||
@current_sort,
|
||||
@filter_by_archived)
|
||||
@organizations = current_user.organizations
|
||||
|
||||
# New project for create new project modal
|
||||
|
@ -237,6 +238,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def show
|
||||
# This is the "info" view
|
||||
current_organization_switch(@project.organization)
|
||||
end
|
||||
|
||||
def notifications
|
||||
|
@ -261,6 +263,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def experiment_archive
|
||||
current_organization_switch(@project.organization)
|
||||
end
|
||||
|
||||
def samples_index
|
||||
|
|
|
@ -741,9 +741,7 @@ class ProtocolsController < ApplicationController
|
|||
end
|
||||
|
||||
def load_organization_and_type
|
||||
@organizations = current_user.organizations.order(name: :asc)
|
||||
@current_organization = @organizations.select{ |org| org.id == params[:organization].to_i }.first
|
||||
@current_organization ||= @organizations.first
|
||||
@current_organization = current_organization
|
||||
# :public, :private or :archive
|
||||
@type = (params[:type] || "public").to_sym
|
||||
end
|
||||
|
|
|
@ -498,10 +498,10 @@ class Users::SettingsController < ApplicationController
|
|||
if @user.save
|
||||
flash[:success] = t('users.settings.changed_org_flash',
|
||||
team: @changed_org.name)
|
||||
redirect_to :back
|
||||
redirect_to root_path
|
||||
else
|
||||
flash[:alert] = t('users.settings.changed_org_error_flash')
|
||||
redirect_to :back
|
||||
redirect_to root_path
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,2 +1,9 @@
|
|||
module OrganizationsHelper
|
||||
def current_organization_switch(org)
|
||||
# resets the current organization if needed
|
||||
if org != current_organization
|
||||
current_user.current_organization_id = org.id
|
||||
current_user.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,4 +6,15 @@ module SearchHelper
|
|||
end
|
||||
experiments.uniq
|
||||
end
|
||||
|
||||
def route_to_other_org(path, search_org, text)
|
||||
if search_org != current_organization
|
||||
link_to text,
|
||||
path,
|
||||
data: { confirm: t('users.settings.changed_org_in_search',
|
||||
team: search_org.name) }
|
||||
else
|
||||
link_to text, path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -77,27 +77,6 @@
|
|||
</a>
|
||||
<% end %>
|
||||
|
||||
<!-- organization filter -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="organizationMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
<span class="hidden-xs"><%= t('projects.index.organization_filter') %></span>
|
||||
<span class="visible-xs-inline"><i class="glyphicon glyphicon-folder-open"></i></span>
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||
<% if @current_organization_id > 1 %>
|
||||
<li><a href="?<%= {sort: @current_sort}.reject{|k,v| v.blank?}.to_query %>"><%= t'projects.index.all_filter' %></a></li>
|
||||
<% end %>
|
||||
<% @organizations.each do |org| %>
|
||||
<% if org.id == @current_organization_id %>
|
||||
<li class="disabled"><a href="#"><%= org.name %></a></li>
|
||||
<% else %>
|
||||
<li><a href="?<%= {organization: org.id, sort: @current_sort}.reject{|k,v| v.blank?}.to_query %>"><%= org.name %></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- project sort -->
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="sortMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||
|
@ -132,9 +111,13 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @projects_by_orgs.length > 0 %>
|
||||
<% @projects_by_orgs.each do |org, projects| %>
|
||||
<%= render partial: "projects/index/org_projects", locals: {org: org, projects: projects} %>
|
||||
<% end %>
|
||||
<%= render partial: 'projects/index/introductory_popup' %>
|
||||
<%= javascript_include_tag 'projects/introdutory_popup' %>
|
||||
|
||||
<% if current_organization.projects.length> 0 %>
|
||||
<%= render partial: "projects/index/org_projects",
|
||||
locals: { org: current_organization,
|
||||
projects: current_organization.projects } %>
|
||||
|
||||
<% end %>
|
||||
<%= javascript_include_tag "projects/index", "data-turbolinks-track" => true %>
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
<ol class="breadcrumb breadcrumb-protocols-manager">
|
||||
<% if action_name == "index" %>
|
||||
<li class="active"><%= t("protocols.nav.breadcrumbs.manager") %></li>
|
||||
<li class="dropdown">
|
||||
<a class="dropdown-toggle" id="organizations-dropdown-a" role="button" data-toggle="dropdown" href="#"><%= current_organization.name %> <span class="caret"></span></a>
|
||||
<ul id="organizations-dropdown" class="dropdown-menu">
|
||||
<% organizations.each do |org| %>
|
||||
<% if org != current_organization %>
|
||||
<li>
|
||||
<%= link_to org.name, protocols_path(organization: org, type: type) %>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="disabled"><a href="#"><%= org.name %></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="disabled"><%= current_organization.name %></li>
|
||||
<% else %>
|
||||
<li><%= link_to t("protocols.nav.breadcrumbs.manager"), protocols_path(organization: current_organization, type: type) %></li>
|
||||
<li class="active"><%= current_organization.name %></li>
|
||||
|
@ -24,4 +11,4 @@
|
|||
<%= t("protocols.nav.breadcrumbs.edit") %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ol>
|
||||
</ol>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% provide(:head_title, t("protocols.index.head_title")) %>
|
||||
|
||||
<% if @organizations.count > 0 %>
|
||||
<% if current_organization %>
|
||||
<%= render partial: "protocols/breadcrumbs.html.erb", locals: { organizations: @organizations, current_organization: @current_organization, type: @type } %>
|
||||
|
||||
<ul class="nav nav-tabs nav-settings">
|
||||
|
|
|
@ -11,4 +11,4 @@
|
|||
</a>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -4,17 +4,15 @@
|
|||
<% if experiment.archived? %>
|
||||
<span class="label label-warning"><%=t "search.index.archived" %></span>
|
||||
<% if can_view_experiment(experiment) and can_restore_experiment(experiment.project) %>
|
||||
<a href="/">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org root_path, experiment.project.organization, text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if can_view_experiment(experiment) %>
|
||||
<a href="<%= canvas_experiment_path(experiment) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org canvas_experiment_path(experiment),
|
||||
experiment.project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
<% if my_module.archived? %>
|
||||
<span class="label label-warning"><%=t "search.index.archived" %></span>
|
||||
<% if can_view_experiment_archive(my_module.experiment) and can_restore_module(my_module) %>
|
||||
<a href="<%= module_archive_experiment_url(my_module.experiment) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org module_archive_experiment_url(my_module.experiment),
|
||||
my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
@ -15,21 +15,21 @@
|
|||
<% if can_view_module(my_module) %>
|
||||
<% case link_to_page %>
|
||||
<% when :samples %>
|
||||
<a href="<%= samples_my_module_path(my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org samples_my_module_path(my_module),
|
||||
my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% when :protocols %>
|
||||
<a href="<%= protocols_my_module_path(my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org protocols_my_module_path(my_module),
|
||||
my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% when :canvas %>
|
||||
<a href="<%= canvas_experiment_path(my_module.experiment) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org canvas_experiment_path(my_module.experiment),
|
||||
my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% when :results %>
|
||||
<a href="<%= results_my_module_path(my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org results_my_module_path(my_module),
|
||||
my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<% if can_view_projects(organization) %>
|
||||
<a href="<%= projects_path :organization => organization.id %>">
|
||||
<%= organization.name %>
|
||||
</a>
|
||||
<%= route_to_other_org projects_path(organization: organization.id),
|
||||
organization,
|
||||
organization.name %>
|
||||
<% else %>
|
||||
<%= organization.name %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,24 +5,24 @@
|
|||
<% if project.archived? %>
|
||||
<span class="label label-warning"><%=t "search.index.archived" %></span>
|
||||
<% if can_view_projects(project.organization) and can_restore_project(project) %>
|
||||
<a href="<%= projects_archive_path(organization: project.organization) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org projects_archive_path(organization: project.organization),
|
||||
project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if can_view_project(project) %>
|
||||
<% if link_to_page == :show %>
|
||||
<a href="<%= project_path(project) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org project_path(project),
|
||||
project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<a href="<%= root_path %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org root_path,
|
||||
nil,
|
||||
text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
</span>
|
||||
|
||||
<% if can_view_steps_in_protocol(protocol) %>
|
||||
<a href="<%= protocols_my_module_path(protocol.my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org protocols_my_module_path(protocol.my_module),
|
||||
protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
@ -31,9 +31,9 @@
|
|||
|
||||
<% end %>
|
||||
<% if can_edit_protocol(protocol) %>
|
||||
<a href="<%= edit_protocol_path(protocol) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org edit_protocol_path(protocol),
|
||||
protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
<a href="<%= edit_project_report_path(report.project, report) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org edit_project_report_path(report.project, report),
|
||||
report.project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -6,13 +6,14 @@
|
|||
<span class="label label-warning"><%=t "search.index.archived" %></span>
|
||||
<% if can_view_module_archive(result.my_module) %>
|
||||
<% if target == :comment %>
|
||||
<%= link_to archive_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}") do %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<%= route_to_other_org archive_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}"),
|
||||
result.my_module.experiment.project.organization,
|
||||
text %>
|
||||
|
||||
<% else %>
|
||||
<a href="<%= archive_my_module_path(result.my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org archive_my_module_path(result.my_module),
|
||||
result.my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
|
@ -20,13 +21,13 @@
|
|||
<% else %>
|
||||
<% if can_view_results_in_module(result.my_module) %>
|
||||
<% if target == :comment %>
|
||||
<%= link_to results_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}") do %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<%= route_to_other_org results_my_module_path(result.my_module, ctarget: "result-panel-#{result.id}"),
|
||||
result.my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<a href="<%= results_my_module_path(result.my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org results_my_module_path(result.my_module),
|
||||
result.my_module.experiment.project.organization,
|
||||
text %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
|
|
|
@ -5,18 +5,18 @@
|
|||
<% if can_view_steps_in_protocol(step.protocol) %>
|
||||
<% if step.protocol.in_module? %>
|
||||
<% if target == :comment %>
|
||||
<%= link_to protocols_my_module_path(step.protocol.my_module, ctarget: "step-panel-#{step.id}") do %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
<%= route_to_other_org protocols_my_module_path(step.protocol.my_module, ctarget: "step-panel-#{step.id}"),
|
||||
step.protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<a href="<%= protocols_my_module_path(step.protocol.my_module) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org protocols_my_module_path(step.protocol.my_module),
|
||||
step.protocol.organization,
|
||||
text %>
|
||||
<% end %>
|
||||
<% elsif can_edit_protocol(step.protocol) %>
|
||||
<a href="<%= edit_protocol_path(step.protocol) %>">
|
||||
<%= text %>
|
||||
</a>
|
||||
<%= route_to_other_org edit_protocol_path(step.protocol),
|
||||
step.protocol.organization,
|
||||
text %>
|
||||
<% else %>
|
||||
<%= text %>
|
||||
<% end %>
|
||||
|
|
|
@ -105,14 +105,14 @@
|
|||
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
|
||||
<span><%= current_organization.name %></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<ul class="dropdown-menu ">
|
||||
<%= form_for(current_user,
|
||||
url: user_current_organization_path,
|
||||
method: :post) do |f| %>
|
||||
<%= hidden_field(:user, :current_organization_id) %>
|
||||
<% current_user.organizations.each do |org| %>
|
||||
<% next unless org != current_organization %>
|
||||
<li><a href="#" data-id="<%= org.id %>"><%= org.name %></a></li>
|
||||
<li><a href="#" data-id="<%= org.id %>" class="text-center"><%= org.name %></a></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -1120,6 +1120,7 @@ en:
|
|||
settings:
|
||||
changed_org_flash: "You are working on %{team} now!"
|
||||
changed_org_error_flash: "Something get wrong! Try again later."
|
||||
changed_org_in_search: "The searched item is not in your current team. You will be redirected on %{team} team!"
|
||||
navigation:
|
||||
preferences: "My preferences"
|
||||
organizations: "My teams"
|
||||
|
|
Loading…
Reference in a new issue