Skip to content

Commit

Permalink
feat(tagstatistics): improve ux on front filters
Browse files Browse the repository at this point in the history
  • Loading branch information
lucashimpens committed Dec 13, 2024
1 parent 1468c10 commit 6b615fb
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions source/src/main/webapp/js/pages/ReportingCampaignStatistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ $.when($.getScript("js/global/global.js")).then(function () {
'placement': 'auto',
'container': 'body'}
);

$("#system-select").change(function () {
if ($(this).val() == null) {
$('#application-select').multiselect("deselectAll", false);
$('#application-select').multiselect('updateButtonText');
$('#application-select').next('div').find('button').prop('disabled', true);
$('#loadButton').prop('disabled', true);
} else {
setApplicationSelectOptions($(this).val());
$('#application-select').next('div').find('button').prop('disabled', false);
}
});

$("#application-select").change(function () {
if ($(this).val() == null) {
$('#loadButton').prop('disabled', true);
} else {
$('#loadButton').prop('disabled', false);
}
})
});
});

Expand Down Expand Up @@ -94,13 +114,9 @@ function removeLoadingStatus(datatable) {
function setSelectOptions(selectId, options, param) {
let select = $('#' + selectId);
if (select.val() === null) {
select.empty();
select.multiselect('rebuild');
let selectOptions = select.html();
let selectOptions = select.html("");
$.each(options, function(index, value) {
if ($("#" + selectId + " option[value='" + options[index] + "']").length === 0) {
selectOptions += `<option value="${options[index]}">${options[index]}</option>`;
}
selectOptions += `<option value="${value}">${value}</option>`;
});
select.html(selectOptions);
select.multiselect('rebuild');
Expand All @@ -114,17 +130,18 @@ function setSelectOptions(selectId, options, param) {
function setSystemSelectOptions() {
let user = JSON.parse(sessionStorage.getItem('user'));
let systems = user.system;
let options = $("#system-select").html();
let options = $("#system-select").html("");
$.each(systems, function(index, value) {
options += `<option value="${value}">${value}</option>`;
})
$('#system-select').html(options);
$("#system-select").multiselect('rebuild');
}

function setApplicationSelectOptions() {
function setApplicationSelectOptions(systems) {
let systemsQ = "";
let systems = JSON.parse(sessionStorage.getItem('user')).system;
$("#application-select").html("");
$('#application-select').multiselect('refresh')
$.each(systems, function(index, value) {
systemsQ += "&system=" + encodeURI(systems[index]);
})
Expand All @@ -135,7 +152,7 @@ function setApplicationSelectOptions() {
dataType: "json",
method: 'GET',
data: {
system: encodeURI(JSON.parse(sessionStorage.getItem('user')).system),
system: encodeURI(systems),
},
success: function(data) {
let result = data.contentTable;
Expand Down Expand Up @@ -224,7 +241,9 @@ function initGlobalPage() {
createDataTableWithPermissions(config, undefined, "#tagStatisticList", undefined, undefined, undefined, undefined);
displayPageLabel();
setSystemSelectOptions();
setApplicationSelectOptions();
$('#application-select').next('div').find('button').prop('disabled', true);
$('#group1-select').next('div').find('button').prop('disabled', true);
$('#loadButton').prop('disabled', true);

$('#loadButton').click(function()
{
Expand Down Expand Up @@ -264,6 +283,7 @@ function getStatistics() {
success: function(data) {
updateDatatable($("#tagStatisticTable"), data);
removeLoadingStatus($("#tagStatisticList"));
$('#group1-select').prop('disabled', false);
setSelectOptions("group1-select", data.globalGroup1List);
}
});
Expand Down

0 comments on commit 6b615fb

Please sign in to comment.