mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-10 17:36:33 +08:00
Save repository table page to local storage [SCI-8512] (#5501)
This commit is contained in:
parent
5b90a657e4
commit
e2624987bd
1 changed files with 11 additions and 0 deletions
|
@ -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',
|
||||
|
|
Loading…
Reference in a new issue