Disable inventories table initialization on turbolinks preview

This commit is contained in:
aignatov-bio 2020-07-10 11:05:27 +02:00
parent 7aa40a284e
commit 50714eb59d
2 changed files with 11 additions and 3 deletions

View file

@ -274,3 +274,8 @@ var HelperModule = (function(){
tinymce.remove();
});
})();
// Check that loaded page, not turbolinks preview
function notTurbolinksPreview() {
return !document.documentElement.hasAttribute("data-turbolinks-preview");
}

View file

@ -1,4 +1,5 @@
/* global I18n animateSpinner HelperModule DataTableHelpers DataTableCheckboxes */
/* global I18n animateSpinner HelperModule
DataTableHelpers DataTableCheckboxes notTurbolinksPreview */
(function() {
'use strict';
@ -32,7 +33,7 @@
function initRepositoriesDataTable(tableContainer, archived = false) {
var tableTemplate = $('#RepositoriesListTable').html();
$.get($(tableTemplate).data('source'), {archived: archived}, function(data) {
$.get($(tableTemplate).data('source'), { archived: archived }, function(data) {
if (REPOSITORIES_TABLE) REPOSITORIES_TABLE.destroy();
CHECKBOX_SELECTOR = null;
$('.content-body').html(tableTemplate);
@ -187,6 +188,8 @@
});
$('.create-new-repository').initializeModal('#create-repo-modal');
initRepositoriesDataTable('#repositoriesList', $('.repositories-index').hasClass('archived'));
if (notTurbolinksPreview()) {
initRepositoriesDataTable('#repositoriesList', $('.repositories-index').hasClass('archived'));
}
initRepositoryViewSwitcher();
}());