Skip to content

Commit 0f4c707

Browse files
committed
small fix for leading zeros regex, and search box hiding when there are 0 results from the datasource
git-svn-id: https://share-extras.googlecode.com/svn/trunk/Sandbox/Audit Dashlet@800 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent 5306192 commit 0f4c707

File tree

1 file changed

+38
-25
lines changed

1 file changed

+38
-25
lines changed

source/web/components/dashlets/audit-application.js

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@
284284
var vfHeader = this.options.valueFilter ? " " + this.msg("audit.dashlet.valuefilteredOn") + " " + this.options.valueFilter : "";
285285
// valid limit parameter values : strictly positive integers. other values are ignored
286286
var validLimit = this.options.limit != "" && !isNaN(this.options.limit) && !((this.options.limit * 1) < 1 );
287-
var limitHeader = validLimit ? " ("+ this.options.limit.replace(/0+/,'') + " max)" : ""; // remove leading zeros, if any
287+
var limitHeader = validLimit ? " ("+ this.options.limit.replace(/^0+/,'') + " max)" : ""; // trim leading zeros, if any
288288

289289
this.titleContainer.innerHTML = this.msg("audit.dashlet.header.default")+ " : " + appHeader + vfHeader + limitHeader;
290290

@@ -600,37 +600,50 @@
600600
{
601601
var currentCount = res.results.length;
602602

603-
if(req)
603+
if(currentCount > 0)
604604
{
605-
var filterOutput = dashlet.applyRegexFilterOnResponse(req,res);
606-
res.results = filterOutput.filtered;
607-
608-
if(filterOutput.regexStatus == "valid")
605+
// show the search box if it was hidden
606+
Dom.removeClass(dashlet.searchBoxContainer,'shy');
607+
Dom.removeClass(dashlet.searchBoxLabelContainer,'shy');
608+
609+
if(req)
609610
{
610-
//switch the search background to valid. no need to test with hasClass, YUI dom already does this internally
611-
Dom.removeClass(dashlet.searchBoxContainer,'invalid-regex');
612-
Dom.addClass(dashlet.searchBoxContainer,'valid-regex');
611+
var filterOutput = dashlet.applyRegexFilterOnResponse(req,res);
612+
res.results = filterOutput.filtered;
613+
614+
if(filterOutput.regexStatus == "valid")
615+
{
616+
//switch the search background to valid. no need to test with hasClass, YUI dom already does this internally
617+
Dom.removeClass(dashlet.searchBoxContainer,'invalid-regex');
618+
Dom.addClass(dashlet.searchBoxContainer,'valid-regex');
619+
620+
// update the message containing the number of new (now filtered out) results
621+
var filteredCount = filterOutput.filtered.length;
622+
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.filteredResults", filteredCount, currentCount - filteredCount) +" :";
623+
}
624+
else if(filterOutput.regexStatus == "invalid")
625+
{
626+
//switch the search background to invalid
627+
Dom.removeClass(dashlet.searchBoxContainer,'valid-regex');
628+
Dom.addClass(dashlet.searchBoxContainer,'invalid-regex');
613629

614-
// update the message containing the number of new (now filtered out) results
615-
var filteredCount = filterOutput.filtered.length;
616-
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.filteredResults", filteredCount, currentCount - filteredCount) +" :";
630+
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.invalidSearch") +" :";
631+
}
617632
}
618-
else if(filterOutput.regexStatus == "invalid")
633+
else
619634
{
620-
//switch the search background to invalid
635+
//we're back to an empty filter. remove the invalid-regex styling, if present
636+
Dom.removeClass(dashlet.searchBoxContainer,'invalid-regex');
621637
Dom.removeClass(dashlet.searchBoxContainer,'valid-regex');
622-
Dom.addClass(dashlet.searchBoxContainer,'invalid-regex');
623638

624-
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.invalidSearch") +" :";
639+
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.searchWithinResults", currentCount) +" :";
625640
}
626641
}
627642
else
628643
{
629-
//we're back to an empty filter. remove the invalid-regex styling, if present
630-
Dom.removeClass(dashlet.searchBoxContainer,'invalid-regex');
631-
Dom.removeClass(dashlet.searchBoxContainer,'valid-regex');
632-
633-
dashlet.searchBoxLabelContainer.innerHTML = dashlet.msg("audit.dashlet.searchWithinResults", currentCount) +" :";
644+
// don't show the search box if there are no results from the datasource
645+
Dom.addClass(dashlet.searchBoxContainer,'shy');
646+
Dom.addClass(dashlet.searchBoxLabelContainer,'shy');
634647
}
635648

636649

@@ -1008,11 +1021,11 @@
10081021
this.options.application = Dom.get(this.configDialog.id + "-application").value;
10091022
this.options.valueFilter = Dom.get(this.configDialog.id + "-valueFilter").value;
10101023

1011-
this.options.limit = Dom.get(this.configDialog.id + "-limit").value.replace(/0+/,''); // remove leading zeros, if any
1024+
this.options.limit = Dom.get(this.configDialog.id + "-limit").value.replace(/^0+/,''); // trim leading zeros, if any
10121025
if(isNaN(this.options.limit) || (this.options.limit * 1) < 1 )
10131026
this.options.limit = ""; // invalid values (not strictly positive integers ) are dropped
10141027

1015-
this.options.rowsPerPage = Dom.get(this.configDialog.id + "-rowsPerPage").value.replace(/0+/,''); // remove leading zeros, if any
1028+
this.options.rowsPerPage = Dom.get(this.configDialog.id + "-rowsPerPage").value.replace(/^0+/,''); // trim leading zeros, if any
10161029
if(isNaN(this.options.rowsPerPage) || (this.options.rowsPerPage * 1) < 1 )
10171030
this.options.rowsPerPage = this.options.defaultRowsPerPage; // invalid values (not strictly positive integers ) are dropped
10181031

@@ -1039,13 +1052,13 @@
10391052
if(isNaN(this.options.limit) || (this.options.limit * 1) < 1 )
10401053
Dom.get(this.configDialog.id + "-limit").value = "";
10411054
else
1042-
Dom.get(this.configDialog.id + "-limit").value = this.options.limit.replace(/0+/,''); // remove leading zeros, if any
1055+
Dom.get(this.configDialog.id + "-limit").value = this.options.limit.replace(/^0+/,''); // trim leading zeros, if any
10431056

10441057
// invalid values (not strictly positive integers ) are dropped
10451058
if(isNaN(this.options.rowsPerPage) || (this.options.rowsPerPage * 1) < 1 )
10461059
Dom.get(this.configDialog.id + "-rowsPerPage").value = this.options.defaultRowsPerPage;
10471060
else
1048-
Dom.get(this.configDialog.id + "-rowsPerPage").value = this.options.rowsPerPage.replace(/0+/,''); // remove leading zeros, if any
1061+
Dom.get(this.configDialog.id + "-rowsPerPage").value = this.options.rowsPerPage.replace(/^0+/,''); // trim leading zeros, if any
10491062

10501063
// additional audit API server side query params
10511064
Dom.get(this.configDialog.id + "-additionalQueryParams").value = this.options.additionalQueryParams;

0 commit comments

Comments
 (0)