mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
refactor repositories js files [fixes SCI-1485]
This commit is contained in:
parent
77893e6bcb
commit
a2b7bcda4c
8 changed files with 883 additions and 842 deletions
|
@ -41,8 +41,10 @@
|
|||
success: function (data) {
|
||||
var tabBody = $(pane.context.hash).find(".tab-content-body");
|
||||
tabBody.html(data.html);
|
||||
pane.tab('show').promise().done(function() {
|
||||
pane.tab('show').promise().done(function(el) {
|
||||
initImportRecordsModal();
|
||||
RepositoryDatatable.destroy()
|
||||
RepositoryDatatable.init(el.attr('data-repo-table'));
|
||||
});
|
||||
},
|
||||
error: function (error) {
|
||||
|
|
10
app/assets/javascripts/repositories/my_module_repository.js
Normal file
10
app/assets/javascripts/repositories/my_module_repository.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
// initialze repository datatable
|
||||
$(document).ready(function() {
|
||||
RepositoryDatatable.destroy()
|
||||
RepositoryDatatable.init($('#content').attr('data-repo-id'));
|
||||
onClickToggleAssignedRecords();
|
||||
});
|
||||
})();
|
File diff suppressed because it is too large
Load diff
|
@ -31,7 +31,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div id="content">
|
||||
<div id="content"
|
||||
data-repo-id="#repository-table-<%= @repository.id %>">
|
||||
<%= render partial: "repositories/repository_table",
|
||||
locals: {
|
||||
repository: @repository,
|
||||
|
@ -40,3 +41,7 @@
|
|||
}
|
||||
%>
|
||||
</div>
|
||||
|
||||
<%= stylesheet_link_tag 'datatables' %>
|
||||
<%= javascript_include_tag 'repositories/repository_datatable' %>
|
||||
<%= javascript_include_tag 'repositories/my_module_repository' %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="repository-table">
|
||||
<table id="repository-table" class="table"
|
||||
<table id="repository-table-<%= repository.id %>" class="table"
|
||||
data-current-uri="<%= request.original_url %>"
|
||||
data-repository-id="<%= repository.id %>"
|
||||
data-source="<%= repository_index_link %>"
|
||||
|
@ -35,6 +35,3 @@
|
|||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<%= stylesheet_link_tag 'datatables' %>
|
||||
<%= javascript_include_tag('repositories/repository_datatable') %>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<li role="presentation">
|
||||
<a href="#custom_repo_<%= repo.id %>"
|
||||
data-toggle="tab"
|
||||
data-repo-table="#repository-table-<%= repo.id %>"
|
||||
aria-controls="custom_repo_<%= repo.id %>"
|
||||
data-url="<%=team_repository_show_tab_path(current_team, repo)%>"
|
||||
title="<%=repo.name%>"><%= truncate(repo.name, length: Constants::NAME_TRUNCATION_LENGTH) %></a>
|
||||
|
@ -53,4 +54,6 @@
|
|||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= stylesheet_link_tag 'datatables' %>
|
||||
<%= javascript_include_tag 'repositories/repository_datatable' %>
|
||||
<%= javascript_include_tag "repositories/index", "data-turbolinks-track" => true %>
|
||||
|
|
|
@ -203,7 +203,10 @@
|
|||
<ul class="dropdown-menu repositories-dropdown-menu" aria-labelledby="repositoriesDropdownMenuLink">
|
||||
<% @my_module.experiment.project.team.repositories.order(created_at: :asc).each do |repository| %>
|
||||
<li>
|
||||
<a class="dropdown-item" href="<%= repository_my_module_url(id: @my_module, repository_id: repository) %>" title="<%= repository.name %>">
|
||||
<a class="dropdown-item"
|
||||
href="<%= repository_my_module_url(id: @my_module, repository_id: repository) %>"
|
||||
title="<%= repository.name %>"
|
||||
data-no-turbolink="true">
|
||||
<%= truncate(repository.name) %>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -76,6 +76,8 @@ Rails.application.config.assets.precompile += %w(repositories/index.js)
|
|||
Rails.application.config.assets.precompile += %w(repositories/edit.js)
|
||||
Rails.application.config.assets.precompile +=
|
||||
%w(repositories/repository_datatable.js)
|
||||
Rails.application.config.assets.precompile +=
|
||||
%w(repositories/my_module_repository.js)
|
||||
|
||||
# Libraries needed for Handsontable formulas
|
||||
Rails.application.config.assets.precompile += %w(lodash.js)
|
||||
|
|
Loading…
Reference in a new issue