Code Refactored
This commit is contained in:
@@ -20,10 +20,12 @@
|
|||||||
<script language="javascript" src="/matrix/js/lib/jsfuncs.js" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/lib/jsfuncs.js" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/lib/notifications.js?ver=1" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/lib/notifications.js?ver=1" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/lib/payload-crypto.js?ver=1" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/lib/payload-crypto.js?ver=1" type="text/javascript"></script>
|
||||||
|
<script language="javascript" src="/matrix/js/lib/form-validation.js?ver=1" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/ui/msgdialog.js" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/ui/msgdialog.js" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/ui/select.js" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/ui/select.js" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/edp/initiation.js?ver=7" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/edp/punching/initiation.js?ver=7" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/edp/application-save.js?ver=2" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/edp/punching/initiation-validation.js?ver=1" type="text/javascript"></script>
|
||||||
|
<script language="javascript" src="/matrix/js/edp/punching/application-save.js?ver=2" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/validator.js?ver=2" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/validator.js?ver=2" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/ajax.js" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/ajax.js" type="text/javascript"></script>
|
||||||
<script language="javascript" src="/matrix/js/ajax-dynamic-list.js?ver=1" type="text/javascript"></script>
|
<script language="javascript" src="/matrix/js/ajax-dynamic-list.js?ver=1" type="text/javascript"></script>
|
||||||
@@ -115,7 +117,7 @@
|
|||||||
Appl No.
|
Appl No.
|
||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<input type="text" id="applno" name="applno" maxlength="25" style="width:115px;text-transform:uppercase" value="" onblur="if(validate(this,'t','AlphaNumeric')){FindSameDet(this,'A','customername');}" />
|
<input type="text" id="applno" name="applno" maxlength="25" style="width:115px;text-transform:uppercase" value="" onblur="if(CygnusInitiationValidation.validateField(this)){FindSameDet(this,'A','customername');}" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget">
|
<div class="widget">
|
||||||
@@ -123,7 +125,7 @@
|
|||||||
Bank Code
|
Bank Code
|
||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<input type="text" maxlength="25" id="bankcode" name="bankcode" style="width:70px;text-transform:uppercase" value="" onblur="validate(this,'f','AlphaNumeric');" />
|
<input type="text" maxlength="25" id="bankcode" name="bankcode" style="width:70px;text-transform:uppercase" value="" onblur="CygnusInitiationValidation.validateField(this);" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget">
|
<div class="widget">
|
||||||
@@ -132,7 +134,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<div class="divselect" id="divbranch" style="width:135px;">
|
<div class="divselect" id="divbranch" style="width:135px;">
|
||||||
<select id="bank_branch_id" name="bank_branch_id" style="width:153px" onblur="validate(this,'t','');">
|
<select id="bank_branch_id" name="bank_branch_id" style="width:153px" onblur="CygnusInitiationValidation.validateField(this);">
|
||||||
<option value="-1" selected >SELECT</option>
|
<option value="-1" selected >SELECT</option>
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${not empty model}">
|
<c:when test="${not empty model}">
|
||||||
@@ -152,7 +154,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<div class="divselect" id="divproduct" style="width:132px;">
|
<div class="divselect" id="divproduct" style="width:132px;">
|
||||||
<select id="product" name="product" style="width:150px" onblur="validate(this,'t','');">
|
<select id="product" name="product" style="width:150px" onblur="CygnusInitiationValidation.validateField(this);">
|
||||||
<option value="-1" selected >SELECT</option>
|
<option value="-1" selected >SELECT</option>
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${not empty model}"><c:forEach items="${model.options['product.']}" var="option"><option value="${option.value}"><c:out value="${option.label}" /></option></c:forEach></c:when>
|
<c:when test="${not empty model}"><c:forEach items="${model.options['product.']}" var="option"><option value="${option.value}"><c:out value="${option.label}" /></option></c:forEach></c:when>
|
||||||
@@ -167,7 +169,7 @@
|
|||||||
Name
|
Name
|
||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<input type="text" id="customername" name="customername" maxlength="100" style="width:200px" value="" onblur="validate(this,'t','AlphaSpace');" />
|
<input type="text" id="customername" name="customername" maxlength="100" style="width:200px" value="" onblur="CygnusInitiationValidation.validateField(this);" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget">
|
<div class="widget">
|
||||||
@@ -184,7 +186,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="inputcontainer">
|
<div class="inputcontainer">
|
||||||
<div class="divselect" id="divapptype" style="width:135px;">
|
<div class="divselect" id="divapptype" style="width:135px;">
|
||||||
<select id="apptype" name="apptype" style="width:153px" onchange="ToggleChks((this.value.toUpperCase()!='APPLICANT' && this.value.toUpperCase()!='-1'),'sradd!C0L!soadd!C0L!spadd!C0L!','!C0L!')" onblur="validate(this,'t','');">
|
<select id="apptype" name="apptype" style="width:153px" onchange="ToggleChks((this.value.toUpperCase()!='APPLICANT' && this.value.toUpperCase()!='-1'),'sradd!C0L!soadd!C0L!spadd!C0L!','!C0L!')" onblur="CygnusInitiationValidation.validateField(this);">
|
||||||
<option value="-1" selected>SELECT</option>
|
<option value="-1" selected>SELECT</option>
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${not empty model}"><c:forEach items="${model.options['applicationType.']}" var="option"><option value="${option.value}"><c:out value="${option.label}" /></option></c:forEach></c:when>
|
<c:when test="${not empty model}"><c:forEach items="${model.options['applicationType.']}" var="option"><option value="${option.value}"><c:out value="${option.label}" /></option></c:forEach></c:when>
|
||||||
@@ -264,10 +266,10 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<img class="matrix-title-icon" src="/matrix/images/resdet.png" />
|
<img class="matrix-title-icon" src="/matrix/images/resdet.png" />
|
||||||
<span class="matrix-title-text">Residence Details</span>
|
<span class="matrix-title-text">Residence Details</span>
|
||||||
<div class="divchk" id="ctrldiv">
|
<div class="divchk ctrldiv">
|
||||||
<input type="checkbox" id="rv" name="rv" onclick="HandleClick(this)" />RVR
|
<input type="checkbox" id="rv" name="rv" onclick="HandleClick(this)" />RVR
|
||||||
<input type="checkbox" id="sradd" name="rv" onclick="return FindSameDet(this,'R','rphone')" /><span id="sradd">Same Resi</span>
|
<input type="checkbox" id="sradd" name="sradd" onclick="return FindSameDet(this,'R','rphone')" /><span id="sradd-label">Same Resi</span>
|
||||||
<input type="checkbox" id="rtv" name="rv" onclick="HandleClick(this)" /><span id="rtv">RTV</span>
|
<input type="checkbox" id="rtv" name="rtv" onclick="HandleClick(this)" /><span id="rtv-label">RTV</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -372,11 +374,11 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<img class="matrix-title-icon" src="/matrix/images/optmale.png" />
|
<img class="matrix-title-icon" src="/matrix/images/optmale.png" />
|
||||||
<span class="matrix-title-text">Office Details</span>
|
<span class="matrix-title-text">Office Details</span>
|
||||||
<div class="divchk" id="ctrldiv">
|
<div class="divchk ctrldiv">
|
||||||
<input type="checkbox" id="ov" onclick="HandleClick(this)" />OVR
|
<input type="checkbox" id="ov" onclick="HandleClick(this)" />OVR
|
||||||
<input type="checkbox" id="rco" style="display:none" onclick="HandleClick(this)" /><span id="rco">RCO </span>
|
<input type="checkbox" id="rco" style="display:none" onclick="HandleClick(this)" /><span id="rco-label">RCO </span>
|
||||||
<input type="checkbox" id="soadd" onclick="return FindSameDet(this,'O','ophone')" /><span id="soadd">Same Office</span>
|
<input type="checkbox" id="soadd" onclick="return FindSameDet(this,'O','ophone')" /><span id="soadd-label">Same Office</span>
|
||||||
<input type="checkbox" id="otv" onclick="HandleClick(this)" /><span id="otv">OTV</span>
|
<input type="checkbox" id="otv" onclick="HandleClick(this)" /><span id="otv-label">OTV</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -473,7 +475,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br >
|
<br >
|
||||||
<div class="inputcontainer" style="padding:1px">
|
<div class="inputcontainer" style="padding:1px">
|
||||||
<input type="text" id="department" name="designation" maxlength="50" style="width:100px" value="" onblur="validate(this,'f','SplInstruction')" />
|
<input type="text" id="department" name="department" maxlength="50" style="width:100px" value="" onblur="validate(this,'f','SplInstruction')" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget" style="margin-left:2px">
|
<div class="widget" style="margin-left:2px">
|
||||||
@@ -508,11 +510,11 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<img class="matrix-title-icon" src="/matrix/images/resdet.png" />
|
<img class="matrix-title-icon" src="/matrix/images/resdet.png" />
|
||||||
<span class="matrix-title-text">Property Details</span>
|
<span class="matrix-title-text">Property Details</span>
|
||||||
<div class="divchk" id="ctrldiv">
|
<div class="divchk ctrldiv">
|
||||||
<input type="checkbox" id="pv" onclick="HandleClick(this)" />PVR
|
<input type="checkbox" id="pv" onclick="HandleClick(this)" />PVR
|
||||||
<input type="checkbox" id="rcp" style="display:none" onclick="HandleClick(this)" /><span id="rcp">RCP </span>
|
<input type="checkbox" id="rcp" style="display:none" onclick="HandleClick(this)" /><span id="rcp-label">RCP </span>
|
||||||
<input type="checkbox" id="ocp" style="display:none" onclick="HandleClick(this)" /><span id="ocp">OCP </span>
|
<input type="checkbox" id="ocp" style="display:none" onclick="HandleClick(this)" /><span id="ocp-label">OCP </span>
|
||||||
<input type="checkbox" id="spadd" onclick="return FindSameDet(this,'P','ppincode')" /><span id="spadd">Same Property</span>
|
<input type="checkbox" id="spadd" onclick="return FindSameDet(this,'P','ppincode')" /><span id="spadd-label">Same Property</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -527,7 +529,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br >
|
<br >
|
||||||
<div class="inputcontainer" style="padding:1px">
|
<div class="inputcontainer" style="padding:1px">
|
||||||
<input type="text" id="paddr1" name="paddr1" readonly="readonly" maxlength="40" style="width:90px" value="" onblur="validate(this,document.getElementById('rv').checked ? 't':'f','SplInstruction')" />
|
<input type="text" id="paddr1" name="paddr1" readonly="readonly" maxlength="40" style="width:90px" value="" onblur="CygnusInitiationValidation.validateField(this);" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget" style="margin-left:2px">
|
<div class="widget" style="margin-left:2px">
|
||||||
@@ -582,7 +584,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<br >
|
<br >
|
||||||
<div class="inputcontainer" style="padding:1px">
|
<div class="inputcontainer" style="padding:1px">
|
||||||
<input type="text" id="ppincode" name="colp_pincode" readonly="readonly" maxlength="6" style="width:45px" value="" onblur="validate(this,document.getElementById('rv').checked ? 't':'f','Pincode')" />
|
<input type="text" id="ppincode" name="colp_pincode" readonly="readonly" maxlength="6" style="width:45px" value="" onblur="CygnusInitiationValidation.validateField(this);" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="widget" style="margin-left:2px">
|
<div class="widget" style="margin-left:2px">
|
||||||
@@ -608,7 +610,7 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<img class="matrix-title-icon" src="/matrix/images/ref.png" />
|
<img class="matrix-title-icon" src="/matrix/images/ref.png" />
|
||||||
<span class="matrix-title-text">Reference Details</span>
|
<span class="matrix-title-text">Reference Details</span>
|
||||||
<div class="divchk" id="ctrldiv">
|
<div class="divchk ctrldiv">
|
||||||
<input type="checkbox" id="refv" name="refv" onclick="HandleClick(this)" />Ref Check
|
<input type="checkbox" id="refv" name="refv" onclick="HandleClick(this)" />Ref Check
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -673,7 +675,7 @@
|
|||||||
<div class="title">
|
<div class="title">
|
||||||
<img class="matrix-title-icon" src="/matrix/images/documents.png" />
|
<img class="matrix-title-icon" src="/matrix/images/documents.png" />
|
||||||
<span class="matrix-title-text">Document Details</span>
|
<span class="matrix-title-text">Document Details</span>
|
||||||
<div class="divchk" id="ctrldiv">
|
<div class="divchk ctrldiv">
|
||||||
<input type="checkbox" name="docv" id="docv" />Doc VR
|
<input type="checkbox" name="docv" id="docv" />Doc VR
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -696,10 +698,8 @@
|
|||||||
<input type="hidden" id="branch_id" name="branch_id" value="${sessionScope.userSession.branchId}" />
|
<input type="hidden" id="branch_id" name="branch_id" value="${sessionScope.userSession.branchId}" />
|
||||||
<input type="hidden" id="status" name="status" value="" />
|
<input type="hidden" id="status" name="status" value="" />
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<input type="hidden" id="invalidfields" value="0" />
|
<c:if test="${pageFormMode gt 0}">
|
||||||
<c:if test="${pageFormMode gt 0}">
|
<div style="position:fixed;text-align:right;bottom:0px;width:980px;" class="buttonbar">
|
||||||
<div style="position:fixed;text-align:right;bottom:0px;width:980px;" class="buttonbar">
|
|
||||||
<input type="hidden" id="invalidfields" value="0" />
|
|
||||||
<input type="button" class="button" name="btnfirst" style="margin-left:5px;margin-top:-2px;float:left;width:80px" value="" id="btnfirst" accesskey="F" onclick="findRecord(1)" />
|
<input type="button" class="button" name="btnfirst" style="margin-left:5px;margin-top:-2px;float:left;width:80px" value="" id="btnfirst" accesskey="F" onclick="findRecord(1)" />
|
||||||
<input type="button" class="button" name="btnprev" style="margin-top:-2px;float:left;width:80px" value="" id="btnprev" accesskey="P" onclick="findRecord(2)" />
|
<input type="button" class="button" name="btnprev" style="margin-top:-2px;float:left;width:80px" value="" id="btnprev" accesskey="P" onclick="findRecord(2)" />
|
||||||
<input type="button" class="button" name="btnnext" style="margin-top:-2px;float:left;width:80px" value="" id="btnnext" accesskey="N" onclick="findRecord(3)" />
|
<input type="button" class="button" name="btnnext" style="margin-top:-2px;float:left;width:80px" value="" id="btnnext" accesskey="N" onclick="findRecord(3)" />
|
||||||
@@ -722,8 +722,9 @@
|
|||||||
</body>
|
</body>
|
||||||
<!-- Page Load Javascript -->
|
<!-- Page Load Javascript -->
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
(function () {
|
(function () {
|
||||||
var sectionFields = document.querySelectorAll(".model-visible-section");
|
CygnusInitiationValidation.bind(document.getElementById("casedetails"));
|
||||||
|
var sectionFields = document.querySelectorAll(".model-visible-section");
|
||||||
if (sectionFields.length > 0) {
|
if (sectionFields.length > 0) {
|
||||||
document.getElementById("visiblecontents").value = Array.prototype.map.call(
|
document.getElementById("visiblecontents").value = Array.prototype.map.call(
|
||||||
sectionFields, function (field) { return field.textContent; }
|
sectionFields, function (field) { return field.textContent; }
|
||||||
@@ -734,7 +735,10 @@
|
|||||||
var code = document.getElementById("page-error-code");
|
var code = document.getElementById("page-error-code");
|
||||||
var errorMessage = document.getElementById("page-error-message");
|
var errorMessage = document.getElementById("page-error-message");
|
||||||
if (code && errorMessage) {
|
if (code && errorMessage) {
|
||||||
CallMessage(code.textContent + ":error:" + errorMessage.textContent, 3000, 200, 300);
|
CygnusNotifications.show({
|
||||||
|
type: "danger", code: code.textContent,
|
||||||
|
message: errorMessage.textContent, duration: 3000
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}());
|
}());
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -75,7 +75,8 @@
|
|||||||
right:8px;
|
right:8px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
}
|
}
|
||||||
.title #ctrldiv
|
.title #ctrldiv,
|
||||||
|
.title .ctrldiv
|
||||||
{
|
{
|
||||||
border:none;
|
border:none;
|
||||||
position:relative;
|
position:relative;
|
||||||
|
|||||||
@@ -41,7 +41,12 @@
|
|||||||
const INTEGER_FIELDS = new Set(["applicationId", "portfolioId", "bankBranchId", "residenceColonyId",
|
const INTEGER_FIELDS = new Set(["applicationId", "portfolioId", "bankBranchId", "residenceColonyId",
|
||||||
"officeColonyId", "propertyColonyId", "formMode"]);
|
"officeColonyId", "propertyColonyId", "formMode"]);
|
||||||
const element = (id) => document.getElementById(id);
|
const element = (id) => document.getElementById(id);
|
||||||
const value = (id) => element(id)?.value?.trim() ?? "";
|
const value = (id) => {
|
||||||
|
const field = element(id);
|
||||||
|
if (!field) return "";
|
||||||
|
window.CygnusFormValidation.sanitizeElement(field);
|
||||||
|
return field.value?.trim() ?? "";
|
||||||
|
};
|
||||||
const integer = (id) => {
|
const integer = (id) => {
|
||||||
const parsed = Number.parseInt(value(id), 10);
|
const parsed = Number.parseInt(value(id), 10);
|
||||||
return Number.isFinite(parsed) ? parsed : 0;
|
return Number.isFinite(parsed) ? parsed : 0;
|
||||||
@@ -74,24 +79,14 @@
|
|||||||
notify("danger", "APP-4221", "At least one verification type is required.");
|
notify("danger", "APP-4221", "At least one verification type is required.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
window.invalidFields = 0;
|
const validation = window.CygnusInitiationValidation.validateForm();
|
||||||
window.validate(element("applno"), "t", "AlphaNumeric");
|
|
||||||
window.validate(element("bank_branch_id"), "t", "");
|
|
||||||
window.validate(element("product"), "t", "");
|
|
||||||
window.validate(element("customername"), "t", "AlphaSpace");
|
|
||||||
window.validate(element("apptype"), "t", "");
|
|
||||||
if (checked("rv")) window.CheckForm(element("rv"), "raddr1,raddr2,raddr3,rlandmark,colr,rcity,rpincode", "t,f,t,f,t,t,f", "SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode");
|
|
||||||
if (checked("ov")) window.CheckForm(element("ov"), "companyname,oaddr1,oaddr2,oaddr3,olandmark,colo,ocity,opincode,department,designation", "f,t,f,t,f,t,t,f,f,f", "SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode,SplInstruction,SplInstruction");
|
|
||||||
if (checked("pv")) window.CheckForm(element("pv"), "paddr1,paddr2,paddr3,plandmark,colp,pcity,ppincode", "t,f,t,f,t,t,f", "SplInstruction,SplInstruction,SplInstruction,SplInstruction,SplInstruction,,Pincode");
|
|
||||||
if (checked("rtv")) window.CheckForm(element("rtv"), "rphone", "t", "Phone");
|
|
||||||
if (checked("otv")) window.CheckForm(element("otv"), "ophone", "t", "Phone");
|
|
||||||
if (checked("refv")) window.CheckForm(element("refv"), "refname1,refaddress1,refcontactno1", "t,f,t", "AlphaSpace,SplInstruction,Phone");
|
|
||||||
[["rv", "Rcolony", "colr"], ["ov", "Ocolony", "colo"], ["pv", "Pcolony", "colp"]]
|
[["rv", "Rcolony", "colr"], ["ov", "Ocolony", "colo"], ["pv", "Pcolony", "colp"]]
|
||||||
.forEach(([flag, hidden, visible]) => {
|
.forEach(([flag, hidden, visible]) => {
|
||||||
if (checked(flag) && integer(hidden) === 0) window.highlightField(element(visible));
|
if (checked(flag) && integer(hidden) === 0) window.highlightField(element(visible));
|
||||||
});
|
});
|
||||||
if (document.querySelector(".matrix-validation-error-icon")) {
|
if (!validation.valid || document.querySelector(".matrix-validation-error-icon")) {
|
||||||
notify("danger", "APP-4221", "Correct the highlighted fields and submit the application again.");
|
notify("danger", "APP-4221", "Correct the highlighted fields and submit the application again.");
|
||||||
|
validation.invalid[0]?.focus();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
(function (window, document) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const element = (id) => document.getElementById(id);
|
||||||
|
const checked = (id) => Boolean(element(id)?.checked);
|
||||||
|
const requiredWhen = (id) => () => checked(id);
|
||||||
|
const sectionRule = (id, rule = {}) => Object.assign({ when: requiredWhen(id) }, rule);
|
||||||
|
const RULES = {
|
||||||
|
applno: { required: true, format: "AlphaNumeric", requiredMessage: "Application number is required." },
|
||||||
|
bank_branch_id: { required: true, requiredMessage: "Bank branch is required." },
|
||||||
|
product: { required: true, requiredMessage: "Product is required." },
|
||||||
|
customername: { required: true, format: "AlphaSpace", requiredMessage: "Customer name is required." },
|
||||||
|
apptype: { required: true, requiredMessage: "Application type is required." },
|
||||||
|
bankcode: { format: "AlphaNumeric" }, fathername: { format: "AlphaSpace" }, dob: { format: "Date" },
|
||||||
|
mobileno: { format: "AllowWrong" }, loanamount: { format: "LoanAmount" },
|
||||||
|
contactperson: { format: "AlphaSpace" }, specialinst: { format: "SplInstruction" },
|
||||||
|
raddr1: sectionRule("rv", { required: true, format: "SplInstruction" }), raddr2: sectionRule("rv", { format: "SplInstruction" }),
|
||||||
|
raddr3: sectionRule("rv", { required: true, format: "SplInstruction" }), rlandmark: sectionRule("rv", { format: "SplInstruction" }),
|
||||||
|
rcity: sectionRule("rv", { required: true }), colr: sectionRule("rv", { required: true, format: "SplInstruction" }),
|
||||||
|
rpincode: sectionRule("rv", { format: "Pincode" }), rphone: sectionRule("rtv", { required: true, format: "Phone" }),
|
||||||
|
companyname: sectionRule("ov", { format: "SplInstruction" }), oaddr1: sectionRule("ov", { required: true, format: "SplInstruction" }),
|
||||||
|
oaddr2: sectionRule("ov", { format: "SplInstruction" }), oaddr3: sectionRule("ov", { required: true, format: "SplInstruction" }),
|
||||||
|
olandmark: sectionRule("ov", { format: "SplInstruction" }), ocity: sectionRule("ov", { required: true }),
|
||||||
|
colo: sectionRule("ov", { required: true, format: "SplInstruction" }), opincode: sectionRule("ov", { format: "Pincode" }),
|
||||||
|
department: sectionRule("ov", { format: "SplInstruction" }), designation: sectionRule("ov", { format: "SplInstruction" }),
|
||||||
|
ophone: sectionRule("otv", { required: true, format: "Phone" }), extension: sectionRule("otv", { format: "Extension" }),
|
||||||
|
paddr1: sectionRule("pv", { required: true, format: "SplInstruction" }), paddr2: sectionRule("pv", { format: "SplInstruction" }),
|
||||||
|
paddr3: sectionRule("pv", { required: true, format: "SplInstruction" }), plandmark: sectionRule("pv", { format: "SplInstruction" }),
|
||||||
|
pcity: sectionRule("pv", { required: true }), colp: sectionRule("pv", { required: true, format: "SplInstruction" }),
|
||||||
|
ppincode: sectionRule("pv", { format: "Pincode" }), refname1: sectionRule("refv", { required: true, format: "AlphaSpace" }),
|
||||||
|
refaddress1: sectionRule("refv", { format: "SplInstruction" }),
|
||||||
|
refcontactno1: sectionRule("refv", { required: true, format: "Phone" }),
|
||||||
|
refname2: sectionRule("refv", { format: "AlphaSpace" }), refaddress2: sectionRule("refv", { format: "SplInstruction" }),
|
||||||
|
refcontactno2: sectionRule("refv", { format: "Phone" })
|
||||||
|
};
|
||||||
|
|
||||||
|
function registerDynamicRules(form) {
|
||||||
|
if (!form) return;
|
||||||
|
form.querySelectorAll("#FormPanel6 [data-validation-required]").forEach(function (field) {
|
||||||
|
const label = field.closest(".widget")?.querySelector(".lblcontainer")?.textContent.trim();
|
||||||
|
RULES[field.id] = {
|
||||||
|
required: field.dataset.validationRequired === "true",
|
||||||
|
format: field.dataset.validationFormat || "",
|
||||||
|
requiredMessage: (label || "This dynamic field") + " is required."
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateField(field) {
|
||||||
|
const target = typeof field === "string" ? element(field) : field;
|
||||||
|
const rule = target && RULES[target.id];
|
||||||
|
return !target || !rule || window.CygnusFormValidation.validateElement(target, rule);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateForm() {
|
||||||
|
return window.CygnusFormValidation.validateRules(RULES);
|
||||||
|
}
|
||||||
|
|
||||||
|
function bind(form) {
|
||||||
|
if (!form || form.dataset.initiationValidationBound === "true") return;
|
||||||
|
registerDynamicRules(form);
|
||||||
|
form.dataset.initiationValidationBound = "true";
|
||||||
|
form.addEventListener("focusout", function (event) {
|
||||||
|
window.CygnusFormValidation.sanitizeElement(event.target);
|
||||||
|
validateField(event.target);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.CygnusInitiationValidation = Object.freeze({
|
||||||
|
rules: RULES,
|
||||||
|
bind: bind,
|
||||||
|
validateField: validateField,
|
||||||
|
validateForm: validateForm
|
||||||
|
});
|
||||||
|
}(window, document));
|
||||||
File diff suppressed because it is too large
Load Diff
150
cygnus-onprem-app/build/WebContent/js/lib/form-validation.js
Normal file
150
cygnus-onprem-app/build/WebContent/js/lib/form-validation.js
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
(function (window, document) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const FORMATS = Object.freeze({
|
||||||
|
Email: /^\S*\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,8}\b\S*$/,
|
||||||
|
Numeric: /^\d*$/,
|
||||||
|
AlphaNumeric: /^[a-zA-Z0-9_*\/\-]*$/,
|
||||||
|
AlphaSpace: /^[a-zA-Z0-9()\/ &]*$/,
|
||||||
|
LoanAmount: /^[a-zA-Z0-9. ]*$/,
|
||||||
|
SplInstruction: /^[a-zA-Z0-9():,#@.\-\/ ]*$/,
|
||||||
|
Remarks: /^[a-zA-Z0-9,(),:+&#@'.\-\/ ]*$/,
|
||||||
|
Pincode: /^\d{6}$/,
|
||||||
|
Phone: /^((\d{6,8}|\d{10}|\d{3}-\d{6,8})([\/](\d{6,8}|\d{10}|\d{3}-\d{6,8})){0,2})$/,
|
||||||
|
Extension: /^\d{3,4}$/
|
||||||
|
});
|
||||||
|
const DATE_PATTERN = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
|
||||||
|
|
||||||
|
function sanitize(value, options) {
|
||||||
|
const multiline = Boolean(options && options.multiline);
|
||||||
|
let sanitized = String(value == null ? "" : value).replace(/\t/g, "");
|
||||||
|
if (multiline) {
|
||||||
|
sanitized = sanitized.replace(/\r\n?/g, "\n").replace(/[^\x20-\x7E\n]/g, "");
|
||||||
|
} else {
|
||||||
|
sanitized = sanitized.replace(/[\r\n]/g, "").replace(/[^\x20-\x7E]/g, "");
|
||||||
|
}
|
||||||
|
return sanitized.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeElement(element) {
|
||||||
|
if (!element || typeof element.value !== "string") return "";
|
||||||
|
const tagName = element.tagName ? element.tagName.toLowerCase() : "";
|
||||||
|
const inputType = (element.type || "text").toLowerCase();
|
||||||
|
const sanitizableInput = tagName === "input" &&
|
||||||
|
["text", "search", "tel", "email", "url", "password"].includes(inputType);
|
||||||
|
if (tagName !== "textarea" && !sanitizableInput) return element.value;
|
||||||
|
const sanitized = sanitize(element.value, { multiline: tagName === "textarea" });
|
||||||
|
if (element.value !== sanitized) element.value = sanitized;
|
||||||
|
return sanitized;
|
||||||
|
}
|
||||||
|
|
||||||
|
function valueOf(element) {
|
||||||
|
return element && typeof element.value === "string" ? element.value.trim() : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEmpty(element) {
|
||||||
|
const value = valueOf(element);
|
||||||
|
return value === "" || (element.type === "select-one" && value === "-1");
|
||||||
|
}
|
||||||
|
|
||||||
|
function isDate(value) {
|
||||||
|
const parts = DATE_PATTERN.exec(value);
|
||||||
|
if (!parts) return false;
|
||||||
|
const day = Number(parts[1]);
|
||||||
|
const month = Number(parts[2]);
|
||||||
|
const year = Number(parts[3]);
|
||||||
|
if (year < 1900 || year > 2100 || month < 1 || month > 12) return false;
|
||||||
|
const date = new Date(year, month - 1, day);
|
||||||
|
return date.getFullYear() === year && date.getMonth() === month - 1 && date.getDate() === day;
|
||||||
|
}
|
||||||
|
|
||||||
|
function matchesFormat(value, format) {
|
||||||
|
if (!value || !format || format === "AllowWrong") return true;
|
||||||
|
const normalized = Object.keys(FORMATS).find((name) => name.toLowerCase() === format.toLowerCase());
|
||||||
|
if (format.toLowerCase() === "date") return isDate(value);
|
||||||
|
return normalized ? FORMATS[normalized].test(value) : true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorHost(element) {
|
||||||
|
let current = element.parentNode;
|
||||||
|
let host = current;
|
||||||
|
while (current && current !== document.body) {
|
||||||
|
if ((" " + (current.className || "") + " ").indexOf(" inputcontainer ") !== -1) return current;
|
||||||
|
current = current.parentNode;
|
||||||
|
}
|
||||||
|
return host;
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearError(element) {
|
||||||
|
if (!element) return;
|
||||||
|
const icon = document.getElementById("err" + element.id);
|
||||||
|
if (icon && icon.parentNode) icon.parentNode.removeChild(icon);
|
||||||
|
element.classList.remove("errtxt");
|
||||||
|
if (element.parentNode) element.parentNode.classList.remove("errdiv");
|
||||||
|
element.removeAttribute("aria-invalid");
|
||||||
|
element.removeAttribute("aria-describedby");
|
||||||
|
if (typeof element.setCustomValidity === "function") element.setCustomValidity("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError(element, message) {
|
||||||
|
if (!element) return;
|
||||||
|
clearError(element);
|
||||||
|
const host = errorHost(element);
|
||||||
|
const icon = document.createElement("img");
|
||||||
|
icon.src = "/matrix/images/exclamation.png";
|
||||||
|
icon.id = "err" + element.id;
|
||||||
|
icon.alt = message;
|
||||||
|
icon.title = message;
|
||||||
|
icon.className = "matrix-validation-error-icon" +
|
||||||
|
(element.type === "select-one" ? " matrix-validation-error-icon--select" : "");
|
||||||
|
icon.style.cssText = "position:absolute;right:" + (element.type === "select-one" ? "24px" : "5px") +
|
||||||
|
";top:50%;width:14px;height:14px;transform:translateY(-50%);z-index:3;pointer-events:none";
|
||||||
|
host.style.position = "relative";
|
||||||
|
host.appendChild(icon);
|
||||||
|
if (element.type === "select-one") element.parentNode.classList.add("errdiv");
|
||||||
|
else element.classList.add("errtxt");
|
||||||
|
element.setAttribute("aria-invalid", "true");
|
||||||
|
element.setAttribute("aria-describedby", icon.id);
|
||||||
|
if (typeof element.setCustomValidity === "function") element.setCustomValidity(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateElement(element, rule) {
|
||||||
|
if (!element) return true;
|
||||||
|
sanitizeElement(element);
|
||||||
|
if (typeof rule.when === "function" && !rule.when()) {
|
||||||
|
clearError(element);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const required = typeof rule.required === "function" ? rule.required() : Boolean(rule.required);
|
||||||
|
let message = "";
|
||||||
|
if (required && isEmpty(element)) message = rule.requiredMessage || "This field is required.";
|
||||||
|
else if (!isEmpty(element) && !matchesFormat(valueOf(element), rule.format)) {
|
||||||
|
message = rule.formatMessage || "Enter a valid value.";
|
||||||
|
}
|
||||||
|
if (message) showError(element, message);
|
||||||
|
else clearError(element);
|
||||||
|
return message === "";
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateLegacy(element, requiredFlag, format) {
|
||||||
|
return validateElement(element, { required: requiredFlag === "t", format: format });
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateRules(rules) {
|
||||||
|
const invalid = [];
|
||||||
|
Object.keys(rules).forEach(function (id) {
|
||||||
|
const element = document.getElementById(id);
|
||||||
|
if (!validateElement(element, rules[id])) invalid.push(element);
|
||||||
|
});
|
||||||
|
return { valid: invalid.length === 0, invalid: invalid };
|
||||||
|
}
|
||||||
|
|
||||||
|
window.CygnusFormValidation = Object.freeze({
|
||||||
|
clearError: clearError,
|
||||||
|
sanitize: sanitize,
|
||||||
|
sanitizeElement: sanitizeElement,
|
||||||
|
validateElement: validateElement,
|
||||||
|
validateLegacy: validateLegacy,
|
||||||
|
validateRules: validateRules
|
||||||
|
});
|
||||||
|
}(window, document));
|
||||||
@@ -74,5 +74,22 @@
|
|||||||
document.getElementById("cygnus-notifications")?.replaceChildren();
|
document.getElementById("cygnus-notifications")?.replaceChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.CygnusNotifications = Object.freeze({ show, clear });
|
function showLegacy(serialized, options) {
|
||||||
|
const text = String(serialized || "");
|
||||||
|
const firstSeparator = text.indexOf(":");
|
||||||
|
const secondSeparator = firstSeparator < 0 ? -1 : text.indexOf(":", firstSeparator + 1);
|
||||||
|
const settings = Object.assign({}, options);
|
||||||
|
if (secondSeparator > firstSeparator) {
|
||||||
|
settings.code = text.slice(0, firstSeparator);
|
||||||
|
const legacyType = text.slice(firstSeparator + 1, secondSeparator).toLowerCase();
|
||||||
|
settings.type = legacyType === "error" ? "danger" : legacyType;
|
||||||
|
settings.message = text.slice(secondSeparator + 1);
|
||||||
|
} else {
|
||||||
|
settings.type = settings.type || "danger";
|
||||||
|
settings.message = text;
|
||||||
|
}
|
||||||
|
return show(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
window.CygnusNotifications = Object.freeze({ show, showLegacy, clear });
|
||||||
}(window, document));
|
}(window, document));
|
||||||
|
|||||||
@@ -5,10 +5,14 @@ import java.io.InputStreamReader;
|
|||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class CommonFunctions {
|
public class CommonFunctions {
|
||||||
|
private static final Pattern DYNAMIC_VALIDATION = Pattern.compile(
|
||||||
|
"(?i)validate\\s*\\(\\s*this\\s*,\\s*'([tf])'\\s*,\\s*'([^']*)");
|
||||||
private String ErrMsg;
|
private String ErrMsg;
|
||||||
private String ErrCode;
|
private String ErrCode;
|
||||||
private String ErrDesc;
|
private String ErrDesc;
|
||||||
@@ -102,14 +106,15 @@ public class CommonFunctions {
|
|||||||
}
|
}
|
||||||
return GatewayList;
|
return GatewayList;
|
||||||
}
|
}
|
||||||
public String DynamicControls(String [] Controls,String ControlVal)
|
public String DynamicControls(String [] Controls,String ControlVal)
|
||||||
{
|
{
|
||||||
String CtrlHtml="";
|
String CtrlHtml="";
|
||||||
String CtrlStyle="";
|
String CtrlStyle="";
|
||||||
String CtrlClass="";
|
String CtrlClass="";
|
||||||
String CtrlEvents="";
|
String CtrlEvents="";
|
||||||
String isSelected="";
|
String isSelected="";
|
||||||
String maxLength="maxlength";
|
String maxLength="maxlength";
|
||||||
|
String validationAttributes=dynamicValidationAttributes(Controls[9]);
|
||||||
String unit="px";
|
String unit="px";
|
||||||
setCtrlType(Controls[14]);
|
setCtrlType(Controls[14]);
|
||||||
ControlVal=(ControlVal==null || ControlVal.equals("")) ? Controls[17] : ControlVal;
|
ControlVal=(ControlVal==null || ControlVal.equals("")) ? Controls[17] : ControlVal;
|
||||||
@@ -151,11 +156,11 @@ public class CommonFunctions {
|
|||||||
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
||||||
if(getCtrlType().equals("text"))
|
if(getCtrlType().equals("text"))
|
||||||
{
|
{
|
||||||
CtrlHtml=CtrlHtml+"<input type=\"text\" id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" value=\""+ControlVal+"\" />";
|
CtrlHtml=CtrlHtml+"<input type=\"text\" id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+validationAttributes+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" value=\""+ControlVal+"\" />";
|
||||||
}
|
}
|
||||||
else if(getCtrlType().equals("checkbox"))
|
else if(getCtrlType().equals("checkbox"))
|
||||||
{
|
{
|
||||||
CtrlHtml=CtrlHtml+"<input id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" value='"+ControlVal+"' />";
|
CtrlHtml=CtrlHtml+"<input id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+validationAttributes+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" value='"+ControlVal+"' />";
|
||||||
}
|
}
|
||||||
CtrlHtml=CtrlHtml+"</div></div>";
|
CtrlHtml=CtrlHtml+"</div></div>";
|
||||||
}
|
}
|
||||||
@@ -167,7 +172,7 @@ public class CommonFunctions {
|
|||||||
}
|
}
|
||||||
CtrlHtml="<div class='widget'><div class='lblcontainer'>"+Controls[1];
|
CtrlHtml="<div class='widget'><div class='lblcontainer'>"+Controls[1];
|
||||||
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
||||||
CtrlHtml=CtrlHtml+"<textarea id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" >"+ControlVal+"</textarea>";
|
CtrlHtml=CtrlHtml+"<textarea id='"+Controls[2]+"' name='"+Controls[2]+"' "+maxLength+" "+validationAttributes+" "+CtrlEvents+" "+CtrlStyle+" "+CtrlClass+" >"+ControlVal+"</textarea>";
|
||||||
CtrlHtml=CtrlHtml+"</div></div>";
|
CtrlHtml=CtrlHtml+"</div></div>";
|
||||||
}
|
}
|
||||||
else if(getCtrlType().equals("select"))
|
else if(getCtrlType().equals("select"))
|
||||||
@@ -194,7 +199,7 @@ public class CommonFunctions {
|
|||||||
CtrlHtml="<div class='widget'><div class='lblcontainer'>"+Controls[1];
|
CtrlHtml="<div class='widget'><div class='lblcontainer'>"+Controls[1];
|
||||||
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
CtrlHtml=CtrlHtml+"</div><div class='inputcontainer'>";
|
||||||
CtrlHtml=CtrlHtml+"<div "+CtrlClass+" id='div"+Controls[2]+"' "+CtrlStyle+" >";
|
CtrlHtml=CtrlHtml+"<div "+CtrlClass+" id='div"+Controls[2]+"' "+CtrlStyle+" >";
|
||||||
CtrlHtml=CtrlHtml+"<select id='"+Controls[2]+"' name='"+Controls[2]+"' "+CtrlEvents+" "+CtrlStyle1+" >";
|
CtrlHtml=CtrlHtml+"<select id='"+Controls[2]+"' name='"+Controls[2]+"' "+validationAttributes+" "+CtrlEvents+" "+CtrlStyle1+" >";
|
||||||
CtrlHtml=CtrlHtml+"<option value='-1' selected>NA</option>";
|
CtrlHtml=CtrlHtml+"<option value='-1' selected>NA</option>";
|
||||||
CtrlHtml=CtrlHtml+"<option value='"+Controls[19]+"' "+isSelected+" >"+Controls[19]+"</option></select></div></div></div>";
|
CtrlHtml=CtrlHtml+"<option value='"+Controls[19]+"' "+isSelected+" >"+Controls[19]+"</option></select></div></div></div>";
|
||||||
}
|
}
|
||||||
@@ -211,8 +216,18 @@ public class CommonFunctions {
|
|||||||
setGeneratedHtml(CtrlHtml);
|
setGeneratedHtml(CtrlHtml);
|
||||||
setDynamicCtrls(getDynamicCtrls()+Controls[2]+GlobalClass.ColDelim);
|
setDynamicCtrls(getDynamicCtrls()+Controls[2]+GlobalClass.ColDelim);
|
||||||
}
|
}
|
||||||
return Controls[4];
|
return Controls[4];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String dynamicValidationAttributes(String onBlur)
|
||||||
|
{
|
||||||
|
if(onBlur==null || onBlur.isBlank()) return "";
|
||||||
|
Matcher matcher=DYNAMIC_VALIDATION.matcher(onBlur);
|
||||||
|
if(!matcher.find()) return "";
|
||||||
|
String format=matcher.group(2).trim().replaceFirst("[^A-Za-z0-9]+$", "");
|
||||||
|
return "data-validation-required='"+(matcher.group(1).equalsIgnoreCase("t") ? "true" : "false")+
|
||||||
|
"' data-validation-format='"+format+"'";
|
||||||
|
}
|
||||||
public String DesignControls(String ControlType,String Controlid,String TypeScript,String ValidationScript,String Style, String CssClass,String Fieldid,DBFunctions DBFunc,StringFunctions SFunc,String ControlVal)
|
public String DesignControls(String ControlType,String Controlid,String TypeScript,String ValidationScript,String Style, String CssClass,String Fieldid,DBFunctions DBFunc,StringFunctions SFunc,String ControlVal)
|
||||||
{
|
{
|
||||||
String HtmlControl="";
|
String HtmlControl="";
|
||||||
|
|||||||
@@ -515,7 +515,7 @@ class RoleVisibleBatchMigrationTest {
|
|||||||
String initialCase = Files.readString(punching.resolve("initcase.jsp"));
|
String initialCase = Files.readString(punching.resolve("initcase.jsp"));
|
||||||
assertTrue(initialCase.contains("GotoRecord(this,'recno')"));
|
assertTrue(initialCase.contains("GotoRecord(this,'recno')"));
|
||||||
assertTrue(initialCase.contains("CygnusInitiation.save(event)"));
|
assertTrue(initialCase.contains("CygnusInitiation.save(event)"));
|
||||||
assertTrue(initialCase.contains("/matrix/js/edp/initiation.js"));
|
assertTrue(initialCase.contains("/matrix/js/edp/punching/initiation.js"));
|
||||||
assertTrue(initialCase.contains("AddNewRecord()"));
|
assertTrue(initialCase.contains("AddNewRecord()"));
|
||||||
|
|
||||||
String initialDocs = Files.readString(punching.resolve("initdocs.jsp"));
|
String initialDocs = Files.readString(punching.resolve("initdocs.jsp"));
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package matrix.nimble.utilities;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class CommonFunctionsTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void dynamicControlIncludesConfiguredValidationMetadata() {
|
||||||
|
CommonFunctions functions = functions();
|
||||||
|
functions.DynamicControls(control("validate(this,'t','SplInstruction')"), "");
|
||||||
|
|
||||||
|
assertTrue(functions.getGeneratedHtml().contains("data-validation-required='true'"));
|
||||||
|
assertTrue(functions.getGeneratedHtml().contains("data-validation-format='SplInstruction'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void dynamicControlNormalizesMalformedTrailingDateRule() {
|
||||||
|
CommonFunctions functions = functions();
|
||||||
|
functions.DynamicControls(control("validate(this,'f','Date)"), "");
|
||||||
|
|
||||||
|
assertTrue(functions.getGeneratedHtml().contains("data-validation-required='false'"));
|
||||||
|
assertTrue(functions.getGeneratedHtml().contains("data-validation-format='Date'"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private CommonFunctions functions() {
|
||||||
|
CommonFunctions functions = new CommonFunctions();
|
||||||
|
functions.setPrevControl("");
|
||||||
|
functions.setDynamicCtrls("");
|
||||||
|
functions.setGeneratedHtml("");
|
||||||
|
return functions;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String[] control(String onBlur) {
|
||||||
|
String[] control = new String[27];
|
||||||
|
Arrays.fill(control, "");
|
||||||
|
control[0] = "1";
|
||||||
|
control[1] = "Dynamic field";
|
||||||
|
control[2] = "field1";
|
||||||
|
control[5] = "40";
|
||||||
|
control[9] = onBlur;
|
||||||
|
control[14] = "text";
|
||||||
|
control[17] = "";
|
||||||
|
control[26] = "1";
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user