WebAdmin: fix column visibility after reorder

Fixes #1899

Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
Nicola Murino 2025-03-02 19:26:55 +01:00
commit 1a39146606
No known key found for this signature in database
GPG key ID: 935D2952DEC4EECF
5 changed files with 61 additions and 28 deletions

View file

@ -256,6 +256,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "status",
name: "status",
render: function(data, type, row) {
if (type === 'display') {
switch (data){
@ -270,6 +271,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "last_login",
name: "last_login",
defaultContent: "",
render: function(data, type, row) {
if (type === 'display') {
@ -288,6 +290,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "email",
name: "email",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -302,6 +305,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "role",
name: "role",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -316,6 +320,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "filters.totp_config",
name: "two_factor",
visible: false,
defaultContent: false,
render: function(data, type, row) {
@ -330,6 +335,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "description",
name: "description",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -431,10 +437,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$('#table_body').localize();
}
function handleColVisibilityCheckbox(el, index) {
function handleColVisibilityCheckbox(el, selector) {
let index = dt.column(selector).index();
el.off("change");
el.prop('checked', dt.column(index).visible());
el.on("change", function(e){
let index = dt.column(selector).index();
dt.column(index).visible($(this).is(':checked'));
dt.draw('page');
});
@ -447,12 +455,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
dt.rows().deselect();
dt.search(e.target.value).draw();
});
handleColVisibilityCheckbox($('#checkColStatus'), 1);
handleColVisibilityCheckbox($('#checkColLastLogin'), 2);
handleColVisibilityCheckbox($('#checkColEmail'), 3);
handleColVisibilityCheckbox($('#checkColRole'), 4);
handleColVisibilityCheckbox($('#checkCol2FA'), 5);
handleColVisibilityCheckbox($('#checkColDesc'), 6);
handleColVisibilityCheckbox($('#checkColStatus'), "status:name");
handleColVisibilityCheckbox($('#checkColLastLogin'), "last_login:name");
handleColVisibilityCheckbox($('#checkColEmail'), "email:name");
handleColVisibilityCheckbox($('#checkColRole'), "role:name");
handleColVisibilityCheckbox($('#checkCol2FA'), "two_factor:name");
handleColVisibilityCheckbox($('#checkColDesc'), "description:name");
}
function handleRowActions() {

View file

@ -193,6 +193,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "filesystem.provider",
name: "storage",
defaultContent: "",
render: function(data, type, row) {
if (type === 'display') {
@ -218,6 +219,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "used_quota_size",
name: "quota",
visible: false,
searchable: false,
orderable: false,
@ -238,6 +240,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "users",
name: "associations",
defaultContent: "",
visible: false,
searchable: false,
@ -259,6 +262,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "description",
name: "description",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -355,10 +359,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$('#table_body').localize();
}
function handleColVisibilityCheckbox(el, index) {
function handleColVisibilityCheckbox(el, selector) {
let index = dt.column(selector).index();
el.off("change");
el.prop('checked', dt.column(index).visible());
el.on("change", function(e){
let index = dt.column(selector).index();
dt.column(index).visible($(this).is(':checked'));
dt.draw('page');
});
@ -371,10 +377,10 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
dt.rows().deselect();
dt.search(e.target.value).draw();
});
handleColVisibilityCheckbox($('#checkColStorage'), 1);
handleColVisibilityCheckbox($('#checkColQuota'), 2);
handleColVisibilityCheckbox($('#checkColAssociations'), 3);
handleColVisibilityCheckbox($('#checkColDesc'), 4);
handleColVisibilityCheckbox($('#checkColStorage'), "storage:name");
handleColVisibilityCheckbox($('#checkColQuota'), "quota:name");
handleColVisibilityCheckbox($('#checkColAssociations'), "associations:name");
handleColVisibilityCheckbox($('#checkColDesc'), "description:name");
}
function handleRowActions() {

View file

@ -179,6 +179,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "users",
name: "members",
defaultContent: "",
searchable: false,
orderable: false,
@ -199,6 +200,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "description",
name: "description",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -288,10 +290,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$('#table_body').localize();
}
function handleColVisibilityCheckbox(el, index) {
function handleColVisibilityCheckbox(el, selector) {
let index = dt.column(selector).index();
el.off("change");
el.prop('checked', dt.column(index).visible());
el.on("change", function(e){
let index = dt.column(selector).index();
dt.column(index).visible($(this).is(':checked'));
dt.draw('page');
});
@ -304,8 +308,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
dt.rows().deselect();
dt.search(e.target.value).draw();
});
handleColVisibilityCheckbox($('#checkColMembers'), 1);
handleColVisibilityCheckbox($('#checkColDesc'), 2);
handleColVisibilityCheckbox($('#checkColMembers'), "members:name");
handleColVisibilityCheckbox($('#checkColDesc'), "description:name");
}
function handleRowActions() {

View file

@ -180,6 +180,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "users",
name: "members",
defaultContent: "",
searchable: false,
orderable: false,
@ -200,6 +201,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "description",
name: "description",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -289,10 +291,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$('#table_body').localize();
}
function handleColVisibilityCheckbox(el, index) {
function handleColVisibilityCheckbox(el, selector) {
let index = dt.column(selector).index();
el.off("change");
el.prop('checked', dt.column(index).visible());
el.on("change", function(e){
let index = dt.column(selector).index();
dt.column(index).visible($(this).is(':checked'));
dt.draw('page');
});
@ -305,8 +309,8 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
dt.rows().deselect();
dt.search(e.target.value).draw();
});
handleColVisibilityCheckbox($('#checkColMembers'), 1);
handleColVisibilityCheckbox($('#checkColDesc'), 2);
handleColVisibilityCheckbox($('#checkColMembers'), "members:name");
handleColVisibilityCheckbox($('#checkColDesc'), "description:name");
}
function handleRowActions() {

View file

@ -308,6 +308,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "status",
name: "status",
render: function(data, type, row) {
let result = data;
if (row.expiration_date){
@ -330,6 +331,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "last_login",
name: "last_login",
defaultContent: "",
render: function(data, type, row) {
if (type === 'display') {
@ -348,6 +350,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "email",
name: "email",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -362,6 +365,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "filesystem.provider",
name: "storage",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -388,6 +392,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "role",
name: "role",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -402,6 +407,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "filters.totp_config",
name: "two_factor",
visible: false,
defaultContent: "",
render: function(data, type, row) {
@ -419,6 +425,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "quota_files",
name: "disk_quota",
visible: false,
searchable: false,
orderable: false,
@ -453,6 +460,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "total_data_transfer",
name: "transfer_quota",
visible: false,
searchable: false,
orderable: false,
@ -495,6 +503,7 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
},
{
data: "groups",
name: "groups",
visible: false,
defaultContent: [],
render: function(data, type, row) {
@ -612,10 +621,12 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
$('#table_body').localize();
}
function handleColVisibilityCheckbox(el, index) {
function handleColVisibilityCheckbox(el, selector) {
let index = dt.column(selector).index();
el.off("change");
el.prop('checked', dt.column(index).visible());
el.on("change", function(e){
let index = dt.column(selector).index();
dt.column(index).visible($(this).is(':checked'));
dt.draw('page');
});
@ -628,15 +639,15 @@ explicit grant from the SFTPGo Team (support@sftpgo.com).
dt.rows().deselect();
dt.search(e.target.value).draw();
});
handleColVisibilityCheckbox($('#checkColStatus'), 1);
handleColVisibilityCheckbox($('#checkColLastLogin'), 2);
handleColVisibilityCheckbox($('#checkColEmail'), 3);
handleColVisibilityCheckbox($('#checkColStorage'), 4);
handleColVisibilityCheckbox($('#checkColRole'), 5);
handleColVisibilityCheckbox($('#checkCol2FA'), 6);
handleColVisibilityCheckbox($('#checkColDiskQuota'), 7);
handleColVisibilityCheckbox($('#checkColTransferQuota'), 8);
handleColVisibilityCheckbox($('#checkColGroups'), 9);
handleColVisibilityCheckbox($('#checkColStatus'), "status:name");
handleColVisibilityCheckbox($('#checkColLastLogin'), "last_login:name");
handleColVisibilityCheckbox($('#checkColEmail'), "email:name");
handleColVisibilityCheckbox($('#checkColStorage'), "storage:name");
handleColVisibilityCheckbox($('#checkColRole'), "role:name");
handleColVisibilityCheckbox($('#checkCol2FA'), "two_factor:name");
handleColVisibilityCheckbox($('#checkColDiskQuota'), "disk_quota:name");
handleColVisibilityCheckbox($('#checkColTransferQuota'), "transfer_quota:name");
handleColVisibilityCheckbox($('#checkColGroups'), "groups:name");
}
function handleRowActions() {