WIP javascript app

This commit is contained in:
John Woodlock
2012-06-28 14:37:38 +10:00
parent 17dac4ae03
commit 170aed05b2
+19 -11
View File
@@ -297,10 +297,19 @@ function jsViewsRegisterHelpers() {
}; };
function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) { function popupDialogWithFormView(getUrl, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
var dialogDiv = $("<div id='dialog-form'></div>");
var successFunction = function(data, textStatus, jqXHR) { var successFunction = function(data, textStatus, jqXHR) {
console.log(data); console.log(data);
popupDialogWithFormViewData(data, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction);
};
if (getUrl == "") popupDialogWithFormViewData("", postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction)
else executeAjaxRequest(getUrl, "GET", "", base64, successFunction, formErrorFunction);
}
function popupDialogWithFormViewData(data, postUrl, submitType, titleCode, templateSelector, width, height, saveSuccessFunction) {
var dialogDiv = $("<div id='dialog-form'></div>");
var formHtml = $(templateSelector).render(data); var formHtml = $(templateSelector).render(data);
dialogDiv.append(formHtml); dialogDiv.append(formHtml);
@@ -354,15 +363,15 @@ function jsViewsRegisterHelpers() {
$('#entityform input').first().focus(); $('#entityform input').first().focus();
} }
}).dialog('open'); }).dialog('open');
};
executeAjaxRequest(getUrl, "GET", "", base64, successFunction, formErrorFunction);
} }
//all the code for the various functions //all the code for the various functions
function showILClientListing(baseApiUrl) { function showILClientListing(baseApiUrl) {
@@ -476,18 +485,17 @@ alert("here");
$('.addnotebtn').button().click(function(e) { $('.addnotebtn').button().click(function(e) {
var linkId = this.id; var linkId = this.id;
var clientId = linkId.replace("addnotebtn", ""); var clientId = linkId.replace("addnotebtn", "");
var getAndPostUrl = baseApiUrl + 'clients/' + clientId + '/notes'; var postUrl = baseApiUrl + 'clients/' + clientId + '/notes';
var templateSelector = "#noteFormTemplate"; var templateSelector = "#noteFormTemplate";
var width = 600; var width = 600;
var height = 400; var height = 400;
var saveSuccessFunction = function(data, textStatus, jqXHR) { var saveSuccessFunction = function(data, textStatus, jqXHR) {
$("#dialog-form").dialog("close"); $("#dialog-form").dialog("close");
refreshNoteWidget(); refreshNoteWidget(baseApiUrl + 'clients/' + clientId);
} }
popupDialogWithFormView(getAndPostUrl, getAndPostUrl, 'POST', "dialog.title.add.note", templateSelector, width, height, saveSuccessFunction); popupDialogWithFormView("", postUrl, 'POST', "dialog.title.add.note", templateSelector, width, height, saveSuccessFunction);
e.preventDefault(); e.preventDefault();
}); });
$('button.addnotebtn span').text(jQuery.i18n.prop('dialog.button.add.note')); $('button.addnotebtn span').text(jQuery.i18n.prop('dialog.button.add.note'));
@@ -715,6 +723,8 @@ alert("here");
} }
// function to retrieve and display loan summary information in it placeholder // function to retrieve and display loan summary information in it placeholder
function refreshLoanSummaryInfo(clientUrl) { function refreshLoanSummaryInfo(clientUrl) {
@@ -743,7 +753,7 @@ alert("here");
} }
function genRefreshNoteWidgetSuccessVar(clientUrl) { function genRefreshNoteWidgetSuccessVar(clientUrl) {
var retVar = 'var successFunction = function(data, textStatus, jqXHR) { ' + return 'var successFunction = function(data, textStatus, jqXHR) { ' +
' var noteParent = new Object();' + ' var noteParent = new Object();' +
' noteParent.title = jQuery.i18n.prop("widget.notes.heading");' + ' noteParent.title = jQuery.i18n.prop("widget.notes.heading");' +
' noteParent.notes = data;' + ' noteParent.notes = data;' +
@@ -764,8 +774,6 @@ alert("here");
' e.preventDefault();' + ' e.preventDefault();' +
' });' + ' });' +
' };' ' };'
alert(retVar);
return retVar;
} }