Add dynamic mandatory fields display (for ease of testing - in FF at least;

This commit is contained in:
John Woodlock
2012-05-29 14:58:05 +10:00
parent 25bbd36ee1
commit 4fd921147c
4 changed files with 130 additions and 12 deletions
+119 -4
View File
@@ -3,9 +3,82 @@
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" href="apidocs.css" type="text/css" media="screen" title="Mifos X API Docs" charset="utf-8"/>
<script type="text/javascript" src="jquery-1.7.min.js"></script>
<title>Mifos X API Documentation</title>
</head>
<script type="text/javascript">
setBasicAuthKey();
function showMandatoryFields(url, resultDiv) {
var jqxhr = $.ajax({
url : url,
type : 'POST',
contentType : "application/json; charset=utf-8",
dataType : 'json',
data : "{}",
cache : false,
beforeSend : function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
},
success : function(data, textStatus, jqXHR) {
$('#' + resultDiv).html("Strangely, There Are No Mandatory Fields");
},
error : function(jqXHR, textStatus, errorThrown) {
if (jqXHR.status === 400) {
errJSON = eval("(" + jqXHR.responseText + ')');
var mandFields = ""
for ( var i in errJSON.errors) {
if (i == 0) mandFields = errJSON.errors[i].parameterName;
else mandFields += ", " + errJSON.errors[i].parameterName;
}
$('#' + resultDiv).html(mandFields);
return;
}
if (jqXHR.status === 0) {
$('#' + resultDiv).html('No connection.\n Verify Network.');
} else if (jqXHR.status == 404) {
$('#' + resultDiv).html('Requested page not found. [404]');
} else if (jqXHR.status == 500) {
$('#' + resultDiv).html('Internal Server Error [500].');
} else if (errorThrown === 'parsererror') {
$('#' + resultDiv).html('Requested JSON parse failed.');
} else if (errorThrown === 'timeout') {
$('#' + resultDiv).html('Time out error.');
} else if (errorThrown === 'abort') {
$('#' + resultDiv).html('Ajax request aborted.');
} else $('#' + resultDiv).html('Unknown Ajax request problem - jqXHR.status: ' + jqXHR.status);
}
});
}
function setBasicAuthKey() {
var jqxhr = $.ajax({
url : "https://localhost:8443/mifosng-provider/api/v1/authentication?username=mifos&password=password",
type : 'POST',
contentType : "application/json; charset=utf-8",
dataType : 'json',
data : "{}",
cache : false,
//beforeSend : function(xhr) {
// xhr.setRequestHeader("Authorization", "Basic " + basicAuthKey);
//},
success : function(data, textStatus, jqXHR) {
basicAuthKey = data.base64EncodedAuthenticationKey;
//alert("success");
},
error : function(jqXHR, textStatus, errorThrown) {
alert("error - Might be an SSL certificate problem.\nTry to run a List Offices example (which should force your browser to Proceed Anyway).\nThen Click Back to return to this page and all should be good.");
}
});
}
</script>
<body>
<div id="page-wrapper">
@@ -493,6 +566,11 @@
<div class="method-section">
<div class="method-description">
<h4>Create a Client</h4>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/clients', 'clients_mandatory');">Show Mandatory Fields</button>
<br>
<div id=clients_mandatory></div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/clients</code>
@@ -1627,6 +1705,11 @@ Request Body:
<div class="method-section">
<div class="method-description">
<h4>Create a New Loan/Submit a Loan Application</h4>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/loans', 'loans_mandatory');">Show Mandatory Fields</button>
<br>
<div id=loans_mandatory></div>
<br>
<h5>Arguments</h5>
<dl class="argument-list">
<dt>command</dt>
@@ -1934,6 +2017,11 @@ Request Body:
<div class="method-section">
<div class="method-description">
<h4>Create an Office</h4>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/offices', 'offices_mandatory');">Show Mandatory Fields</button>
<br>
<div id=offices_mandatory></div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/offices</code>
@@ -2266,6 +2354,11 @@ Request Body:
<div class="method-section">
<div class="method-description">
<h4>Create a Loan Product</h4>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/loanproducts', 'loanproducts_mandatory');">Show Mandatory Fields</button>
<br>
<div id=loanproducts_mandatory></div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/loanproducts</code>
@@ -2387,12 +2480,22 @@ Request Body:
<code class="method-declaration">PUT https://thedomainname/api/v1/configurations/currency</code>
<code class="method-request">PUT https://localhost:8443/mifosng-provider/api/v1/configurations/currency
Content-Type: application/json
Request Body:
{
"currencies": ["USD", "GBP","XOF","ETB"]
Request Body:{
"currencies": ["KES", "BND", "LBP", "GHC", "USD", "XOF", "AED", "AMD"]
}
</code>
<code class="method-response">Question Outstanding
<code class="method-response">{
"currencies": [
"KES",
"BND",
"LBP",
"GHC",
"USD",
"XOF",
"AED",
"AMD"
]
}
</code>
</div>
</div>
@@ -2982,6 +3085,12 @@ No Request Body
<div class="method-description">
<h4>Create a User</h4>
<p>Adds new application user.</p>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/users', 'users_mandatory');">Show Mandatory Fields</button>
<br>
<div id=users_mandatory></div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/users</code>
@@ -3185,6 +3294,12 @@ No Request Body
<div class="method-section">
<div class="method-description">
<h4>Create a New Role</h4>
<br>
<button type="button" onclick="showMandatoryFields('https://localhost:8443/mifosng-provider/api/v1/roles', 'roles_mandatory');">Show Mandatory Fields</button>
<br>
<div id=roles_mandatory></div>
<br>
</div>
<div class="method-example">
<code class="method-declaration">POST https://thedomainname/api/v1/roles</code>
+7 -7
View File
@@ -8,13 +8,6 @@ new loan template ... is it 2 templates... one to pick product... and 2nd to ret
Configuration
All Good!
Offices (creates and updates not working with last commit)
When creating new offices.. do i have to supply "dateFormat": & "openingDateFormatted" for openingDate? What is list of dateFormats?
openingDate seems mandatory... but when the 'pair' not supplied I get NullPointerException
could just openingDate be used?
Note that openingData is passed as openingDateFormatted and a dateFormat is provided to convert the date from the way your UI records it to a common format.
hierarchy update results in exception (prob solved by using unrecognized parameter exception)
Users
template: allowedOffices (only id 1 came back)... does allowedOffices and available Roles depending on requested permissions?
@@ -26,6 +19,13 @@ create new user... didn't check repeatPassword (see example in docs) but does in
update: give hardtofigureout error msg when using equivalent to create parameters...worked ok with ones in docs tho.
delete: does delete (I delete super1), no 200 ok returned, "org.springframework.dao.InvalidDataAccessApiUsageException: attempt to create merge event with null entity; " if delete a non-existant user
Offices (creates and updates not working with last commit)
When creating new offices.. do i have to supply "dateFormat": & "openingDateFormatted" for openingDate? What is list of dateFormats?
openingDate seems mandatory... but when the 'pair' not supplied I get NullPointerException
could just openingDate be used?
Note that openingData is passed as openingDateFormatted and a dateFormat is provided to convert the date from the way your UI records it to a common format.
hierarchy update results in exception (prob solved by using unrecognized parameter exception)
Loan Product
List - interestRateCalculatedInPeriod is it usefult to show this field...also enums questionsor show only a few cos on loan template
Create - get NullPointerException when creating using values in api doc (? about using principal or principal formatted or the right locale values)
+4
View File
File diff suppressed because one or more lines are too long
@@ -468,7 +468,6 @@
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector,
placeholderDiv) {
alert("Status: " + jqXHR.status + " textStatus: " + textStatus + " errorThrown: " + errorThrown + " templateSelector: " + templateSelector + " placeholderDiv: " + placeholderDiv);
if (jqXHR.status === 0) {
alert('Not connect.\n Verify Network.');
} else if (jqXHR.status == 404) {