mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-06 04:34:06 +08:00
Merge pull request #2509 from aignatov-bio/ai-sci-4506-add-repositories-dropdown-list
Add repositories dropdown list [SCI-4506]
This commit is contained in:
commit
be47efce74
10 changed files with 123 additions and 39 deletions
|
@ -170,10 +170,20 @@ var MyModuleRepositories = (function() {
|
|||
});
|
||||
}
|
||||
|
||||
function initRepositoriesDropdown() {
|
||||
$('.repositories-assign-container').on('show.bs.dropdown', function() {
|
||||
var dropdownContainer = $(this);
|
||||
$.get(dropdownContainer.data('repositories-url'), function(result) {
|
||||
dropdownContainer.find('.repositories-dropdown-menu').html(result.html);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
init: () => {
|
||||
initSimpleTable();
|
||||
initRepositoryFullView();
|
||||
initRepositoriesDropdown();
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
|
|
@ -37,6 +37,57 @@
|
|||
margin-top: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.task-section-header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.actions-block {
|
||||
display: flex;
|
||||
flex-grow: 1;
|
||||
justify-content: flex-end;
|
||||
|
||||
.repositories-assign-container {
|
||||
flex-grow: 1;
|
||||
max-width: 200px;
|
||||
|
||||
.btn {
|
||||
text-align: left;
|
||||
|
||||
.caret {
|
||||
margin: 8px 0;
|
||||
}
|
||||
}
|
||||
|
||||
.repositories-dropdown-menu {
|
||||
width: 100%;
|
||||
|
||||
.repository {
|
||||
@include font-button;
|
||||
display: flex;
|
||||
padding: 8px 16px;
|
||||
|
||||
.assigned-items,
|
||||
.shared-icon {
|
||||
flex-shrink: 0;
|
||||
|
||||
.fas {
|
||||
padding-right: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
.assigned-items {
|
||||
color: $color-alto;
|
||||
}
|
||||
|
||||
.name {
|
||||
flex-grow: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.complete-button-container {
|
||||
|
|
|
@ -97,6 +97,8 @@
|
|||
}
|
||||
|
||||
#assigned-items-container {
|
||||
padding-top: 10px;
|
||||
|
||||
.assigned-repository {
|
||||
border: $border-default;
|
||||
border-radius: $border-radius-modal;
|
||||
|
|
|
@ -187,29 +187,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.repositories-dropdown-menu {
|
||||
border: 1px solid $color-gainsboro;
|
||||
border-top: 0;
|
||||
box-shadow: 0 1px 1px 0 rgba(0, 0, 0, .05);
|
||||
height: auto;
|
||||
max-height: 400px;
|
||||
overflow-x: hidden;
|
||||
text-transform: initial;
|
||||
width: 300px;
|
||||
|
||||
li:not(:first-child) {
|
||||
border-top: 1px solid $color-gainsboro;
|
||||
}
|
||||
|
||||
.fas-custom {
|
||||
float: right;
|
||||
}
|
||||
|
||||
a.muted {
|
||||
opacity: .7;
|
||||
}
|
||||
}
|
||||
|
||||
.repository-share-status {
|
||||
display: contents !important;
|
||||
|
||||
|
|
|
@ -1899,10 +1899,6 @@ th.custom-field .modal-tooltiptext {
|
|||
background-color: $color-alto;
|
||||
}
|
||||
|
||||
.my_module-state-buttons {
|
||||
padding-top: 6px;
|
||||
}
|
||||
|
||||
.parse-records-table {
|
||||
max-height: 200px;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MyModuleRepositoriesController < ApplicationController
|
||||
before_action :load_vars, only: %i(show full_view_table)
|
||||
before_action :check_view_permissions, only: %i(show full_view_table)
|
||||
before_action :load_my_module, only: %i(show full_view_table dropdown_list)
|
||||
before_action :load_repository, only: %i(show full_view_table)
|
||||
before_action :check_my_module_view_permissions, only: %i(show full_view_table dropdown_list)
|
||||
before_action :check_repository_view_permissions, only: %i(show full_view_table)
|
||||
|
||||
def show
|
||||
@draw = params[:draw].to_i
|
||||
|
@ -30,17 +32,29 @@ class MyModuleRepositoriesController < ApplicationController
|
|||
render json: { html: render_to_string(partial: 'my_modules/repositories/full_view_table') }
|
||||
end
|
||||
|
||||
def dropdown_list
|
||||
@repositories = Repository.accessible_by_teams(current_team)
|
||||
|
||||
render json: { html: render_to_string(partial: 'my_modules/repositories/repositories_dropdown_list') }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_vars
|
||||
@my_module = MyModule.find(params[:my_module_id])
|
||||
@repository = Repository.find(params[:id])
|
||||
|
||||
render_404 unless @my_module && @repository
|
||||
def load_my_module
|
||||
@my_module = MyModule.find_by(id: params[:my_module_id])
|
||||
render_404 unless @my_module
|
||||
end
|
||||
|
||||
def check_view_permissions
|
||||
render_403 unless can_read_experiment?(@my_module.experiment) &&
|
||||
can_read_repository?(@repository)
|
||||
def load_repository
|
||||
@repository = Repository.find_by(id: params[:id])
|
||||
render_404 unless @repository
|
||||
end
|
||||
|
||||
def check_my_module_view_permissions
|
||||
render_403 unless can_read_experiment?(@my_module.experiment)
|
||||
end
|
||||
|
||||
def check_repository_view_permissions
|
||||
render_403 unless can_read_repository?(@repository)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<span class="task-section-title">
|
||||
<h2><%= t('my_modules.details.title') %></h2>
|
||||
</span>
|
||||
<div class="complete-button-container">
|
||||
<div class="actions-block">
|
||||
<%= render partial: "my_modules/state_buttons.html.erb" %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -41,7 +41,20 @@
|
|||
<span class="task-section-title">
|
||||
<h2><%= t('my_modules.assigned_items.title') %></h2>
|
||||
</span>
|
||||
</a>
|
||||
</a>
|
||||
<div class="actions-block">
|
||||
<div class="dropdown repositories-assign-container"
|
||||
data-repositories-url="<%= dropdown_list_my_module_my_module_repositories_path(@my_module) %>"
|
||||
>
|
||||
<a href="#" id="repositories-assign-button" class="btn btn-secondary btn-block" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<span class="fas fa-file-signature"></span>
|
||||
<span><%= t('my_modules.assigned_items.assign_from') %></span>
|
||||
<span class="caret pull-right"></span>
|
||||
</a>
|
||||
<ul class="dropdown-menu repositories-dropdown-menu" aria-labelledby="repositories-assign-button">
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="collapse panel-group" id="assigned-items-container">
|
||||
<%= render partial: "my_modules/repositories/repositories_list" %>
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<% @repositories.each do |repository| %>
|
||||
<% assigned_items_count = @my_module.repository_rows_count(repository) %>
|
||||
<li class="repository">
|
||||
<% if repository.shared_with?(current_team) %>
|
||||
<span class="shared-icon">
|
||||
<i class="fas fa-users"></i>
|
||||
</span>
|
||||
<% end %>
|
||||
<span class="name"><%= escape_input(repository.name) %></span>
|
||||
<% if assigned_items_count.positive? %>
|
||||
<span class="assigned-items">
|
||||
<i class="fas fa-file-signature"></i>
|
||||
<%= assigned_items_count %>
|
||||
</span>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
|
@ -604,6 +604,7 @@ en:
|
|||
empty_description_edit_label: "Click here to start writing notes"
|
||||
assigned_items:
|
||||
title: "Assigned items"
|
||||
assign_from: "Assign from"
|
||||
protocol:
|
||||
title: "Protocol"
|
||||
buttons:
|
||||
|
|
|
@ -388,6 +388,9 @@ Rails.application.routes.draw do
|
|||
member do
|
||||
get :full_view_table
|
||||
end
|
||||
collection do
|
||||
get :dropdown_list
|
||||
end
|
||||
end
|
||||
|
||||
# resources :sample_my_modules, path: '/samples_index', only: [:index]
|
||||
|
|
Loading…
Reference in a new issue