Skip to content

Commit

Permalink
Merge pull request #2257 from department-of-veterans-affairs/rc/2023-…
Browse files Browse the repository at this point in the history
…12-5/Sprint-65-c3

Rc/2023 12 5/sprint 65 c3
  • Loading branch information
Pelentan authored Dec 18, 2023
2 parents 50dc95b + 4712fbd commit affc4c9
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 73 deletions.
11 changes: 11 additions & 0 deletions LEAF_Nexus/js/employeeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function employeeSelector(containerID) {
this.intervalID = null;
this.selectHandler = null;
this.resultHandler = null;
this.selectHandlers = [];
this.selectLink = null;
this.selectionData = new Object();
this.optionNoLimit = 0;
Expand Down Expand Up @@ -108,6 +109,7 @@ employeeSelector.prototype.select = function (id) {
if (this.selectHandler != null) {
this.selectHandler();
}
this.selectHandlers.forEach(selectHandler => selectHandler());
};

employeeSelector.prototype.setSelectHandler = function (func) {
Expand All @@ -118,6 +120,15 @@ employeeSelector.prototype.setResultHandler = function (func) {
this.resultHandler = func;
};

employeeSelector.prototype.addSelectHandler = function (func) {
if(typeof func == 'function') {
this.selectHandlers.push(func);
}
else {
console.error('argument supplied to addSelectHandler must be a function');
}
};

employeeSelector.prototype.setSelectLink = function (link) {
this.selectLink = link;
};
Expand Down
11 changes: 11 additions & 0 deletions LEAF_Nexus/js/nationalEmployeeSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function nationalEmployeeSelector(containerID) {
this.intervalID = null;
this.selectHandler = null;
this.resultHandler = null;
this.selectHandlers = [];
this.selectLink = null;
this.selectionData = new Object();
this.optionNoLimit = 0;
Expand Down Expand Up @@ -161,6 +162,7 @@ nationalEmployeeSelector.prototype.select = function (id) {
if (this.selectHandler != null) {
this.selectHandler();
}
this.selectHandlers.forEach(selectHandler => selectHandler());
};

nationalEmployeeSelector.prototype.setSelectHandler = function (func) {
Expand All @@ -171,6 +173,15 @@ nationalEmployeeSelector.prototype.setResultHandler = function (func) {
this.resultHandler = func;
};

nationalEmployeeSelector.prototype.addSelectHandler = function (func) {
if(typeof func == 'function') {
this.selectHandlers.push(func);
}
else {
console.error('argument supplied to addSelectHandler must be a function');
}
};

nationalEmployeeSelector.prototype.setSelectLink = function (link) {
this.selectLink = link;
};
Expand Down
5 changes: 0 additions & 5 deletions LEAF_Request_Portal/admin/templates/mod_templates.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@
},
url: '../api/templateFileHistory/_' + currentFile,
success: function(res) {
console.log("File history has been saved.");
getFileHistory(currentFile);
}
})
Expand Down Expand Up @@ -471,7 +470,6 @@
dataType: 'json',
success: function(res) {
if (res.length === 0) {
console.log('There are no files in the directory');
var contentMessage = '<p class="contentMessage">There are no history files.</p>';
$('.file-history-res').html(contentMessage);
return;
Expand All @@ -482,7 +480,6 @@
});
if (fileNames.indexOf(template) === -1) {
console.log('Template file not found in directory');
return;
}
Expand Down Expand Up @@ -859,8 +856,6 @@
if (windowWidth < 1024) {
$('.leaf-right-nav').css('right', '-100%');
} else {
console.log('Please check the width of the window');
}
$.ajax({
type: 'GET',
Expand Down
7 changes: 0 additions & 7 deletions LEAF_Request_Portal/admin/templates/mod_templates_email.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@
console.log('Error occurred during the save operation:', errorThrown);
}
});
console.log('Your Template has been saved.');
}
function showDialog(message, color) {
Expand Down Expand Up @@ -383,7 +382,6 @@
currentSubjectContent = subject;
currentEmailToContent = emailToData;
currentEmailCcContent = emailCcData;
console.log("File history has been saved.");
getFileHistory(currentFile);
}
});
Expand Down Expand Up @@ -419,7 +417,6 @@
dataType: 'json',
success: function(res) {
if (res.length === 0) {
console.log('There are no files in the directory');
var contentMessage = '<p class="contentMessage">There are no history files.</p>';
$('.file-history-res').html(contentMessage);
return;
Expand All @@ -430,7 +427,6 @@
});
if (!fileNames.includes(template)) {
console.log('Template file not found in directory');
return;
}
Expand Down Expand Up @@ -631,7 +627,6 @@
dataType: 'json',
cache: false,
success: function(res) {
console.log(res);
loadContent(currentName, currentFile, currentSubjectFile, currentEmailToFile,
currentEmailCcFile);
exitExpandScreen();
Expand Down Expand Up @@ -1171,8 +1166,6 @@
if (windowWidth < 1024) {
$('.leaf-right-nav').css('right', '-100%');
} else {
console.log('Please check the width of the window');
}
$.ajax({
type: 'GET',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@
},
url: '../api/applet/fileHistory/_' + currentFile,
success: function(res) {
console.log("File history has been saved.");
getFileHistory(currentFile);
}
});
Expand Down Expand Up @@ -404,7 +403,6 @@
url: '../api/applet/deleteHistoryFileReport/_' + templateFile + '?' +
$.param({'CSRFToken': '<!--{$CSRFToken}-->'}),
success: function() {
console.log(templateFile + ', was deleted');
location.reload();
}
});
Expand Down Expand Up @@ -438,7 +436,6 @@
dataType: 'json',
success: function(res) {
if (res.length === 0) {
console.log('There are no files in the directory');
var contentMessage = '<p class="contentMessage">There are no history files.</p>';
$('.file-history-res').html(contentMessage);
return;
Expand All @@ -449,7 +446,7 @@
});
if (fileNames.indexOf(template) === -1) {
console.log('Template file not found in directory');
alert('Template file not found in directory');
return;
}
Expand Down Expand Up @@ -854,8 +851,6 @@
if (windowWidth < 1024) {
$('.leaf-right-nav').css('right', '-100%');
} else {
console.log('Please check the width of the window');
}
$.ajax({
type: 'GET',
Expand Down
12 changes: 12 additions & 0 deletions LEAF_Request_Portal/js/formQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var LeafFormQuery = function () { //NOTE: keeping this a var in case custom code
let results = {};
let batchSize = 500;
let abortSignal;
let firstRun = true; // keep track of query limit state, to align with user intent
let origLimit, origLimitOffset;

clearTerms();

Expand Down Expand Up @@ -91,6 +93,7 @@ var LeafFormQuery = function () { //NOTE: keeping this a var in case custom code
* @memberOf LeafFormQuery
*/
function setLimit(offset = 50, limit = 0) {
firstRun = true;
if (limit === 0) {
query.limit = offset;
} else {
Expand Down Expand Up @@ -280,6 +283,15 @@ var LeafFormQuery = function () { //NOTE: keeping this a var in case custom code
* @memberOf LeafFormQuery
*/
function execute() {
if(firstRun) {
firstRun = false;
origLimit = query.limit;
origLimitOffset = query.limitOffset;
} else {
query.limit = origLimit;
query.limitOffset = origLimitOffset;
}

if (query.getData != undefined && query.getData.length == 0) {
delete query.getData;
}
Expand Down
99 changes: 62 additions & 37 deletions LEAF_Request_Portal/js/formSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var LeafFormSearch = function (containerID) {
'<div style="display:flex; align-items:center; width:fit-content; width: -moz-fit-content;">\
<img id="' +
prefixID +
'searchIcon" class="searchIcon" alt="search" style="vertical-align: middle; padding-right: 4px; display: inline;" src="' +
'searchIcon" class="searchIcon" alt="" style="vertical-align: middle; padding-right: 4px; display: inline;" src="' +
rootURL +
'dynicons/?img=search.svg&w=16">\
<img id="' +
Expand All @@ -51,17 +51,20 @@ var LeafFormSearch = function (containerID) {
'advancedOptionsClose" style="float: right; margin-top: -20px; margin-right: -14px; display: none; cursor: pointer; background-image:url(' +
rootURL +
'dynicons/?img=process-stop.svg&w=16); height: 16px;width: 16px; border: none; background-color: transparent; text-indent: -9999em" alt="Close advanced search">Close advanced search</button>\
<div style="width: 550px">Find items where...</div>\
<div style="width: 550px">Find items where...</div>\
<table id="' +
prefixID +
'searchTerms"></table>\
<button class="buttonNorm" id="' +
<button type="button" aria-label="add logical and filter" class="buttonNorm" id="' +
prefixID +
'addTerm" style="float: left">And...</button>\
<button class="buttonNorm" id="' +
<button type="button" aria-label="add logical or filter" class="buttonNorm" id="' +
prefixID +
'orTerm" style="float: left">Or...</button>\
<br /><br />\
<div id="unsubmitted_results_notice" style="display:none;color:#b00; margin:0.5rem 2px;">\
<div>Results can include unsubmitted requests. Consider including \'Current Status IS Submitted\'.</div>\
</div>\
<button id="' +
prefixID +
'advancedSearchApply" class="buttonNorm" style="text-align: center; width: 100%">Apply Filters</button>\
Expand Down Expand Up @@ -672,6 +675,39 @@ var LeafFormSearch = function (containerID) {
}
}

/* assesses query logic for some term filters and updates display of status message if the query can return unsubmitted requests */
function checkDateStatus() {
let includesOnAndBefore = false;
let filtersUnsubmitted = false;

const elSelTerms = Array.from(document.querySelectorAll(`table select[id^="${prefixID}widgetTerm_"]`));
elSelTerms.forEach(sel => {
if(sel?.value === "dateSubmitted" || sel?.value === "stepID") {
const codID = (sel?.id || '').replace('widgetTerm_', 'widgetCod_');
const gateID = (sel?.id || '').replace('widgetTerm_', 'widgetGate_');
const opValue = document.getElementById(codID)?.value || '';
const gateVal = document.getElementById(gateID)?.innerText || 'AND';

if(sel.value === "dateSubmitted") {
if(opValue === '<=') {
includesOnAndBefore = true;
} else {
if (gateVal === 'AND') {
filtersUnsubmitted = true;
}
}
}
if(sel.value === "stepID" && gateVal === 'AND' && opValue === '=') {
filtersUnsubmitted = true;
}
}
});
let msgEl = document.getElementById('unsubmitted_results_notice');
if (msgEl !== null) {
msgEl.style.display = includesOnAndBefore && !filtersUnsubmitted ? 'block' : 'none';
}
}

/**
* @memberOf LeafFormSearch
*/
Expand Down Expand Up @@ -748,16 +784,13 @@ var LeafFormSearch = function (containerID) {
case "dateInitiated":
case "dateSubmitted":
$("#" + prefixID + "widgetCondition_" + widgetID).html(
'<select id="' +
prefixID +
"widgetCod_" +
widgetID +
'" style="width: 140px" class="chosen" aria-label="date">\
<option value="=">ON</option>\
<option value=">=">ON AND AFTER</option>\
<option value="<=">ON AND BEFORE</option>\
</select>'
`<select id="${prefixID}widgetCod_${widgetID}" style="width: 140px" class="chosen" aria-label="date">
<option value="=">ON</option>
<option value=">=">ON AND AFTER</option>
<option value="<=">ON AND BEFORE</option>
</select>`
);
$(`#${prefixID}widgetCod_${widgetID}`).on("change", checkDateStatus);
$("#" + prefixID + "widgetMatch_" + widgetID).html(
'<input type="text" aria-label="text" id="' +
prefixID +
Expand Down Expand Up @@ -922,6 +955,7 @@ var LeafFormSearch = function (containerID) {
<option value="!=" selected>IS NOT</option>\
</select>'
);
$(`#${prefixID}widgetCod_${widgetID}`).on("change", checkDateStatus);
url =
rootURL === ""
? "./api/workflow/steps"
Expand Down Expand Up @@ -1476,29 +1510,17 @@ var LeafFormSearch = function (containerID) {
if (gate === undefined) {
gate = "AND";
}
let widget =
'<tr id="' +
prefixID +
"widget_" +
widgetCounter +
'" style="border-spacing: 5px">\
<td id="' +
prefixID +
"widgetRemove_" +
widgetCounter +
'"><button id="widgetRemoveButton"><img src="' +
rootURL +
'dynicons/?img=list-remove.svg&w=16" style="cursor: pointer" alt="remove search term" tabindex="0"></button></td>\
<td style="text-align: center"><strong id="' +
prefixID +
"widgetGate_" +
widgetCounter +
'" value="' +
gate +
'">' +
gate +
'</strong></td>\
<td><select id="' +

let widget = `<tr id="${prefixID}widget_${widgetCounter}" style="border-spacing: 5px">
<td id="${prefixID}widgetRemove_${widgetCounter}">
<button type="button" id="${prefixID}widgetRemoveButton_${widgetCounter}" aria-label="remove filter row" style="cursor: pointer">
<img src="${rootURL}dynicons/?img=list-remove.svg&w=16" alt="" />
</button>
</td>
<td style="text-align: center">
<strong id="${prefixID}widgetGate_${widgetCounter}" value="${gate}">${gate}</strong>
</td>` +
'<td><select id="' +
prefixID +
"widgetTerm_" +
widgetCounter +
Expand All @@ -1524,6 +1546,7 @@ var LeafFormSearch = function (containerID) {
widgetCounter +
'"></td>\
</tr>';

$(widget).appendTo("#" + prefixID + "searchTerms");
renderWidget(widgetCounter);
firstChild();
Expand All @@ -1534,16 +1557,18 @@ var LeafFormSearch = function (containerID) {
widgetCounter,
function (e) {
renderWidget(e.data);
checkDateStatus();
chosenOptions();
}
);
$("#" + prefixID + "widgetRemove_" + widgetCounter).on(
$("#" + prefixID + "widgetRemoveButton_" + widgetCounter).on(
"click",
"",
widgetCounter,
function (e) {
$("#" + prefixID + "widget_" + e.data).remove();
$("#" + prefixID + "widgetOp_" + e.data).remove();
checkDateStatus();
firstChild();
}
);
Expand Down
Loading

0 comments on commit affc4c9

Please sign in to comment.