Save repository table page to local storage [SCI-8512] (#5501)

This commit is contained in:
ajugo 2023-05-29 10:27:00 +02:00 committed by GitHub
parent 5b90a657e4
commit e2624987bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -636,9 +636,14 @@ var RepositoryDatatable = (function(global) {
type: 'POST',
success: function(json) {
var archived = $('.repository-show').hasClass('archived');
var viewType = archived ? 'archived' : 'active';
var state = localStorage.getItem(`datatables_repositories_state/${repositoryId}/${viewType}`);
json.state.start = state !== null ? JSON.parse(state).start : 0;
if (json.state.columns[6]) json.state.columns[6].visible = archived;
if (json.state.columns[7]) json.state.columns[7].visible = archived;
if (json.state.search) delete json.state.search;
callback(json.state);
}
});
@ -646,6 +651,12 @@ var RepositoryDatatable = (function(global) {
stateSaveCallback: function(settings, data) {
// Send an Ajax request to the server with the state object
let repositoryId = $(TABLE_ID).data('repository-id');
var viewType = $('.repository-show').hasClass('archived') ? 'archived' : 'active';
localStorage.setItem(
`datatables_repositories_state/${repositoryId}/${viewType}`,
JSON.stringify(data)
);
$.ajax({
url: '/repositories/' + repositoryId + '/state_save',