WIP javascript UI

This commit is contained in:
John Woodlock
2012-06-29 15:06:00 +10:00
parent 607a3d4637
commit 0eef469fea
2 changed files with 131 additions and 28 deletions
+3 -3
View File
@@ -407,7 +407,7 @@
<span class="longrowlabel">Awaiting disbursal loans ({{=$ctx.number(awaitingDisbursalLoanCount)}}):</span> <span class="longrowlabel">Awaiting disbursal loans ({{=$ctx.number(awaitingDisbursalLoanCount)}}):</span>
<span class="rowvalue"> <span class="rowvalue">
{{#each awaitingDisbursalLoans}} {{#each awaitingDisbursalLoans}}
<span class="loanaccount"><a href="https://localhost:8443/mifosng-provider/api/v1/loans/{{=id}}?associations=ALL" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span> <span class="loanaccount"><a href="unknown.html" onclick="showILLoan(baseApiUrl, {{=id}}, '{{=loanProductName}}');return false ;" >{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}} {{/each}}
</span> </span>
</div> </div>
@@ -418,7 +418,7 @@
<span class="longrowlabel">Active loans ({{=$ctx.number(activeLoanCount)}}):</span> <span class="longrowlabel">Active loans ({{=$ctx.number(activeLoanCount)}}):</span>
<span class="rowvalue"> <span class="rowvalue">
{{#each openLoans}} {{#each openLoans}}
<span class="loanaccount"><a href="https://localhost:8443/mifosng-provider/api/v1/loans/{{=id}}?associations=ALL" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span> <span class="loanaccount"><a href="unknown.html" onclick="showILLoan(baseApiUrl, {{=id}}, '{{=loanProductName}}');return false ;" >{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}} {{/each}}
</span> </span>
</div> </div>
@@ -429,7 +429,7 @@
<div class="longrowlabel">Closed loans ({{=$ctx.number(closedLoanCount)}}):</div> <div class="longrowlabel">Closed loans ({{=$ctx.number(closedLoanCount)}}):</div>
<div class="rowvalue"> <div class="rowvalue">
{{#each closedLoans}} {{#each closedLoans}}
<span class="loanaccount"><a href="https://localhost:8443/mifosng-provider/api/v1/loans/{{=id}}?associations=ALL" id="loan{{=id}}" class="openloanaccount" title="{{=loanProductName}}: &#35;{{=id}}">{{=loanProductName}}: &#35;{{=id}}</a></span> <span class="loanaccount"><a href="unknown.html" onclick="showILLoan(baseApiUrl, {{=id}}, '{{=loanProductName}}');return false ;" >{{=loanProductName}}: &#35;{{=id}}</a></span>
{{/each}} {{/each}}
</div> </div>
</div> </div>
+107 -4
View File
@@ -318,11 +318,8 @@ function jsViewsRegisterHelpers() {
} }
function popupDialogWithFormViewData(data, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) { function popupDialogWithFormViewData(data, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
var dialogDiv = $("<div id='dialog-form'></div>"); var dialogDiv = $("<div id='dialog-form'></div>");
var formHtml = $(templateSelector).render(data); var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml); dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save'); var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel'); var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
@@ -372,7 +369,94 @@ function jsViewsRegisterHelpers() {
$('#entityform input').first().focus(); $('#entityform input').first().focus();
} }
}).dialog('open'); }).dialog('open');
}
function popupDialogWithPostOnlyFormView(postUrl, titleCode, templateSelector, width, height, tabIndex, minOffset, defaultOffset, maxOffset) {
var dialogDiv = $("<div id='dialog-form'></div>");
var data = new Object();
var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml);
var saveButton = jQuery.i18n.prop('dialog.button.save');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[saveButton] = function() {
$('.multiSelectedItems option').each(function(i) {
$(this).attr("selected", "selected");
});
var newFormData = JSON.stringify($('#entityform').serializeObject());
console.log(newFormData);
var saveSuccessFunction = function(data, textStatus, jqXHR) {
dialogDiv.dialog("close");
//$newtabs.tabs('load', tabIndex);
alert("should be reloaded this loan tab");
};
executeAjaxRequest(postUrl, "POST", newFormData, base64, saveSuccessFunction, formErrorFunction);
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {
$('.multiadd').click(function() {
return !$('.multiNotSelectedItems option:selected').remove().appendTo('#selectedItems');
});
$('.multiremove').click(function() {
return !$('.multiSelectedItems option:selected').remove().appendTo('#notSelectedItems');
});
$('.datepickerfield').datepicker({constrainInput: true, minDate: minOffset, defaultDate: defaultOffset, maxDate: maxOffset, dateFormat: 'dd MM yy'});
$("#entityform textarea").first().focus();
$('#entityform input').first().focus();
}
}).dialog('open');
}
function popupConfirmationDialogAndPost(url, submitType, titleCode, width, height, tabIndex, redirectUrl) {
var dialogDiv = $("<div id='dialog-form'><div id='formerrors'></div>" + jQuery.i18n.prop('text.confirmation.required') + "</div>");
var confirmButton = jQuery.i18n.prop('dialog.button.confirm');
var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
var buttonsOpts = {};
buttonsOpts[confirmButton] = function() {
var saveSuccessFunction = function(data, textStatus, jqXHR) {
dialogDiv.dialog("close");
//$newtabs.tabs('load', tabIndex);
alert("should be reloaded this loan tab");
}
executeAjaxRequest(url, submitType, "", base64, saveSuccessFunction, formErrorFunction);
};
buttonsOpts[cancelButton] = function() {$(this).dialog( "close" );};
dialogDiv.dialog({
title: jQuery.i18n.prop(titleCode),
width: width,
height: height,
modal: true,
buttons: buttonsOpts,
close: function() {
// if i dont do this, theres a problem with errors being appended to dialog view second time round
$(this).remove();
},
open: function (event, ui) {}
}).dialog('open');
} }
@@ -889,7 +973,8 @@ function showILLoan(baseApiUrl, loanId, product) {
var saveSuccessFunction = function(data, textStatus, jqXHR) { var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close"); $("#dialog-form").dialog("close");
$newtabs.tabs('load', currentTabIndex); //$newtabs.tabs('load', currentTabIndex);
alert('repaymment - reload current tab');
} }
popupDialogWithFormView(getUrl, postUrl, 'POST', "dialog.title.loan.repayment", templateSelector, width, height, saveSuccessFunction); popupDialogWithFormView(getUrl, postUrl, 'POST', "dialog.title.loan.repayment", templateSelector, width, height, saveSuccessFunction);
@@ -962,3 +1047,21 @@ function showILLoan(baseApiUrl, loanId, product) {
executeAjaxRequest(loanUrl, 'GET', "", base64, successFunction, errorFunction); executeAjaxRequest(loanUrl, 'GET', "", base64, successFunction, errorFunction);
} }
/* dont use
function showLoanChangeForm(loanAction, loanId){
alert("Action: " + loanAction + " loanId: " + loanId);
var currentTabIndex = $newtabs.tabs('option', 'selected');
var postUrl = baseApiUrl + 'loans/' + loanId + '?command=reject';
var templateSelector = "#stateTransitionLoanFormTemplate";
var width = 500;
var height = 350;
var defaultOffset = offsetToSubmittedDate;
popupDialogWithPostOnlyFormView(postUrl, 'dialog.title.reject.loan', templateSelector, width, height, currentTabIndex, offsetToSubmittedDate, defaultOffset, maxOffset);
//e.preventDefault();
}
*/