finish off integration of organisation admin functions in UI with backend services through cross origin request from jQuery.
This commit is contained in:
+1
-1
@@ -250,7 +250,7 @@ validation.msg.product.interest.rate.per.period.amount.cannot.be.empty=Nominal i
|
||||
|
||||
validation.msg.product.currency.digitsAfterDecimal.must.be.between.zero.and.six.inclusive=Decimal places must be a number between zero and six inclusive.
|
||||
validation.msg.product.principal.amount.must.be.greater.than.zero=Loan amount must be greater than zero.
|
||||
validation.msg.product.repayment.repaidEvery.outside.allowed.range=Repaid every is out of allowed range for selected repayment frequency type.
|
||||
validation.msg.product.repayment.repaidEvery.outside.allowed.range=Repaid every must be between {0} and {1} inclusive given the selected repayment frequency type.
|
||||
validation.msg.product.number.of.repayments.is.out.of.range=# of repayments is out of allowed range for selected repayment frequency type.
|
||||
validation.msg.product.arrears.tolerance.amount.cannot.be.negative=Arrears tolerance cannot be negative.
|
||||
validation.msg.product.interest.rate.per.period.amount.cannot.be.negative=Nominal interest rate % cannot be negative.
|
||||
|
||||
@@ -112,17 +112,28 @@
|
||||
removeErrors(placeholderDiv);
|
||||
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
|
||||
console.log(jsonErrors);
|
||||
var valErrors = jsonErrors.errors;
|
||||
console.log(valErrors);
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(jsonErrors, function() {
|
||||
var fieldId = '#' + this.field;
|
||||
$.each(valErrors, function() {
|
||||
var fieldId = '#' + this.parameterName;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.field;
|
||||
errorObj.code = this.code;
|
||||
errorObj.message = jQuery.i18n.prop(this.code, this.args);
|
||||
errorObj.field = this.parameterName;
|
||||
errorObj.code = this.userMessageGlobalisationCode;
|
||||
|
||||
var argArray = new Array();
|
||||
var argArrayIndex = 0;
|
||||
$.each(this.args, function() {
|
||||
argArray[argArrayIndex] = this.value;
|
||||
argArrayIndex++;
|
||||
});
|
||||
console.log(argArray);
|
||||
// hardcoded support for six arguments
|
||||
errorObj.message = jQuery.i18n.prop(this.userMessageGlobalisationCode, argArray[0], argArray[1], argArray[2], argArray[3], argArray[4], argArray[5]);
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
@@ -182,7 +193,7 @@
|
||||
return o;
|
||||
};
|
||||
|
||||
function popupDialogWithFormView(getUrl, postUrl, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
|
||||
var dialogDiv = $("<div id='dialog-form'></div>");
|
||||
var jqxhr = $.ajax({
|
||||
url: getUrl,
|
||||
@@ -218,7 +229,7 @@
|
||||
|
||||
var jqxhr = $.ajax({
|
||||
url: postUrl,
|
||||
type: 'POST',
|
||||
type: submitType,
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
data: newFormData,
|
||||
@@ -273,7 +284,6 @@
|
||||
$('#addloanproduct').click(function(e) {
|
||||
var getUrl = 'http://localhost:8085/mifosng-provider/api/v1/loanproducts/template';
|
||||
var postUrl = 'http://localhost:8085/mifosng-provider/api/v1/loanproducts';
|
||||
//var url = '${rootContext}portfolio/product/loan/new';
|
||||
var templateSelector = "#productFormTemplate";
|
||||
var width = 800;
|
||||
var height = 550;
|
||||
@@ -283,13 +293,13 @@
|
||||
refreshLoanProductsView();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(getUrl, postUrl, "dialog.title.add.loan.product", templateSelector, width, height, saveSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, postUrl, 'POST', "dialog.title.add.loan.product", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
function refreshLoanProductsView() {
|
||||
var jqxhr = $.ajax({
|
||||
url: '${allLoanProductsUrl}',
|
||||
url: 'http://localhost:8085/mifosng-provider/api/v1/loanproducts', //'${allLoanProductsUrl}',
|
||||
type: 'GET',
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
@@ -297,7 +307,7 @@
|
||||
success: function(data, textStatus, jqXHR) {
|
||||
|
||||
var productlistParent = new Object();
|
||||
productlistParent.items = data;
|
||||
productlistParent.items = data.products;
|
||||
|
||||
var productListHtml = $("#productListTemplate").render(productlistParent);
|
||||
$("#listplaceholder").html(productListHtml);
|
||||
@@ -305,7 +315,8 @@
|
||||
$("a.editproduct").click( function(e) {
|
||||
var linkId = this.id;
|
||||
var productId = linkId.replace("editproduct", "");
|
||||
var url = '${rootContext}portfolio/product/loan/' + productId;
|
||||
var getUrl = 'http://localhost:8085/mifosng-provider/api/v1/loanproducts/' + productId;
|
||||
var putUrl = 'http://localhost:8085/mifosng-provider/api/v1/loanproducts/' + productId;
|
||||
|
||||
var templateSelector = "#productFormTemplate";
|
||||
var width = 800;
|
||||
@@ -316,7 +327,7 @@
|
||||
refreshLoanProductsView();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(url, "dialog.title.product.details", templateSelector, width, height, saveSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, putUrl, 'PUT', "dialog.title.product.details", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
@@ -374,7 +385,7 @@
|
||||
refreshOfficesView();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(url, "dialog.title.add.office", templateSelector, width, height, saveSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, postUrl, 'POST', "dialog.title.add.office", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
@@ -399,7 +410,9 @@
|
||||
$("a.edit").click( function(e) {
|
||||
var linkId = this.id;
|
||||
var entityId = linkId.replace("edit", "");
|
||||
var url = '${rootContext}org/office/' + entityId;
|
||||
var getUrl = 'http://localhost:8085/mifosng-provider/api/v1/offices/' + entityId;
|
||||
var putUrl = 'http://localhost:8085/mifosng-provider/api/v1/offices/' + entityId;
|
||||
|
||||
var templateSelector = "#officeFormTemplate";
|
||||
var width = 600;
|
||||
var height = 400;
|
||||
@@ -409,7 +422,7 @@
|
||||
refreshOfficesView();
|
||||
}
|
||||
|
||||
popupDialogWithFormView(url, "dialog.title.office.details", templateSelector, width, height, saveSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, putUrl, 'PUT', "dialog.title.office.details", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
@@ -444,7 +457,8 @@
|
||||
|
||||
// currency configuration
|
||||
$('#editconfiguration').click(function(e) {
|
||||
var url = '${rootContext}org/configuration/edit';
|
||||
var getUrl = 'http://localhost:8085/mifosng-provider/api/v1/configurations/currency';
|
||||
var putUrl = 'http://localhost:8085/mifosng-provider/api/v1/configurations/currency';
|
||||
var templateSelector = "#configurationFormTemplate";
|
||||
var width = 900;
|
||||
var height = 400;
|
||||
@@ -453,7 +467,7 @@
|
||||
$("#dialog-form").dialog("close");
|
||||
}
|
||||
|
||||
popupDialogWithFormView(url, "dialog.title.configuration.currencies", templateSelector, width, height, saveSuccessFunction);
|
||||
popupDialogWithFormView(getUrl, putUrl, 'PUT', "dialog.title.configuration.currencies", templateSelector, width, height, saveSuccessFunction);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
|
||||
+18
-15
@@ -34,8 +34,8 @@
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><spring:message code="form.legend.loan.product.currency"/></legend>
|
||||
<label for="selectedCurrency"><spring:message code="form.label.loan.product.currency"/></label>
|
||||
<select id="selectedCurrency" name="selectedCurrency" title="" style="width: 300px;">
|
||||
<label for="currencyCode"><spring:message code="form.label.loan.product.currency"/></label>
|
||||
<select id="currencyCode" name="currencyCode" title="" style="width: 300px;">
|
||||
{{#each possibleCurrencies}}
|
||||
{{#if $parent.parent.data.principalMoney.currencyCode===code}}
|
||||
<option value="{{=code}}" selected="selected">{{=name}}</option>
|
||||
@@ -44,8 +44,8 @@
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</select>
|
||||
<label for="selectedDigitsAfterDecimal"><spring:message code="form.label.loan.product.decimalplaces"/></label>
|
||||
<input id="selectedDigitsAfterDecimal" name="selectedDigitsAfterDecimal" title="" style="width: 300px;" value="{{=$ctx.number(principalMoney.currencyDigitsAfterDecimal)}}" />
|
||||
<label for="digitsAfterDecimal"><spring:message code="form.label.loan.product.decimalplaces"/></label>
|
||||
<input id="digitsAfterDecimal" name="digitsAfterDecimal" title="" style="width: 300px;" value="{{=$ctx.number(principalMoney.currencyDigitsAfterDecimal)}}" />
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend><spring:message code="form.legend.loan.product.loan.terms"/></legend>
|
||||
@@ -57,15 +57,15 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.loan.amount"/></td>
|
||||
<td>
|
||||
<input id="amount" name="amount" title="" style="width: 125px;" value="{{=$ctx.money(principalMoney)}}" />
|
||||
<input id="principal" name="principal" title="" style="width: 125px;" value="{{=$ctx.money(principalMoney)}}" />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.repaidevery"/></td>
|
||||
<td>
|
||||
<input id="repaidEvery" name="repaidEvery" title="" style="width: 50px;" value="{{=$ctx.number(repaidEvery)}}"/>
|
||||
<input id="repaymentEvery" name="repaymentEvery" title="" style="width: 50px;" value="{{=$ctx.number(repaidEvery)}}"/>
|
||||
|
||||
<select id="selectedRepaymentFrequencyOption" name="selectedRepaymentFrequencyOption" title="" style="width: 121px;">
|
||||
<select id="repaymentFrequency" name="repaymentFrequency" title="" style="width: 121px;">
|
||||
{{#each repaymentFrequencyOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.repaymentPeriodFrequency)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -89,9 +89,9 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.nominal.interestrate"/></td>
|
||||
<td>
|
||||
<input id="nominalInterestRate" name="nominalInterestRate" title="" style="width: 70px;" value="{{=$ctx.decimal(interestRatePerPeriod, 4)}}" />
|
||||
<input id="interestRatePerPeriod" name="interestRatePerPeriod" title="" style="width: 70px;" value="{{=$ctx.decimal(interestRatePerPeriod, 4)}}" />
|
||||
|
||||
<select id="selectedInterestFrequencyOption" name="selectedInterestFrequencyOption" title="" style="width: 139px;">
|
||||
<select id="interestRateFrequencyMethod" name="interestRateFrequencyMethod" title="" style="width: 139px;">
|
||||
{{#each interestFrequencyOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.interestRatePeriod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -105,7 +105,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.amortization"/></td>
|
||||
<td>
|
||||
<select id="selectedAmortizationMethodOption" name="selectedAmortizationMethodOption" title="" style="width: 220px;">
|
||||
<select id="amortizationMethod" name="amortizationMethod" title="" style="width: 220px;">
|
||||
{{#each possibleAmortizationOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.amortizationMethod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -119,7 +119,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.interest.method"/></td>
|
||||
<td>
|
||||
<select id="selectedInterestMethodOption" name="selectedInterestMethodOption" title="" style="width: 220px;">
|
||||
<select id="interestMethod" name="interestMethod" title="" style="width: 220px;">
|
||||
{{#each possibleInterestOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.interestMethod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -133,7 +133,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.interest.rate.calcutated.in.period"/></td>
|
||||
<td>
|
||||
<select id="interestRateCalculatedInPeriod" name="interestRateCalculatedInPeriod" title="" style="width: 220px;">
|
||||
<select id="interestCalculationPeriodMethod" name="interestCalculationPeriodMethod" title="" style="width: 220px;">
|
||||
{{#each possibleInterestRateCalculatedInPeriodOptions}}
|
||||
{{#if $ctx.number($parent.parent.data.interestRateCalculatedInPeriod)===$ctx.number(id)}}
|
||||
<option value="{{=$ctx.number(id)}}" selected="selected">{{=value}}</option>
|
||||
@@ -147,7 +147,7 @@
|
||||
<tr>
|
||||
<td><spring:message code="form.label.loan.product.arrears.tolerance"/></td>
|
||||
<td>
|
||||
<input id="inArrearsTolerance" name="inArrearsTolerance" title="" style="width: 215px;" value="{{=$ctx.money(inArrearsTolerance)}}" />
|
||||
<input id="inArrearsToleranceAmount" name="inArrearsToleranceAmount" title="" style="width: 215px;" value="{{=$ctx.money(inArrearsTolerance)}}" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -240,10 +240,13 @@
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</select>
|
||||
{{#else}}
|
||||
<input type="hidden" id="rootOffice" name="rootOffice" value="true" />
|
||||
{{/if}}
|
||||
|
||||
<label for="openingDate"><spring:message code="form.label.office.openedon"/></label>
|
||||
<input id="openingDate" name="openingDate" title="" type="text" value="{{=$ctx.globalDate(openingDate)}}" size="75" class="datepickerfield" />
|
||||
<input type="hidden" id="dateFormat" name="dateFormat" value="dd MMMM yyyy" />
|
||||
<label for="openingDateFormatted"><spring:message code="form.label.office.openedon"/></label>
|
||||
<input id="openingDateFormatted" name="openingDateFormatted" title="" type="text" value="{{=$ctx.globalDate(openingDate)}}" size="75" class="datepickerfield" />
|
||||
|
||||
<label for="externalId"><spring:message code="form.label.office.externalid"/></label>
|
||||
<input id="externalId" name="externalId" title="" type="text" value="{{=externalId}}" size="75"/>
|
||||
|
||||
Reference in New Issue
Block a user