WIP Additional Fields api
This commit is contained in:
+303
-3
@@ -30,12 +30,21 @@
|
||||
|
||||
<div class="toc-section">
|
||||
<h3> </h3>
|
||||
<h4>Reports</h4>
|
||||
<h4><a href="#reports">Reports</a></h4>
|
||||
<ul>
|
||||
<li><a href="#listreports">List Reports</a></li>
|
||||
<li><a href="#runreport">Run a Report</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="toc-section">
|
||||
<h3> </h3>
|
||||
<h4><a href="#additionalfields">Additional Fields</a></h4>
|
||||
<ul>
|
||||
<li><a href="#listadditionalfields">List Additional Field Sources</a></li>
|
||||
<li><a href="#retrieveadditionalfields">Retrieve Additional Fields</a></li>
|
||||
<li><a href="#updateadditionalfields">Update Additional Fields</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="toc-section">
|
||||
<h4>Customers</h4>
|
||||
@@ -100,8 +109,8 @@
|
||||
<ul>
|
||||
<li>/v1/reports</li>
|
||||
<li>/v1/reports/{REPORTNAME}</li>
|
||||
<li>/v1/extradata</li>
|
||||
<li>/v1/extradata/{datasetType}/{datasetName}/{datasetPKValue}</li>
|
||||
<li>/v1/additionalfields</li>
|
||||
<li>/v1/additionalfields/{datasetType}/{datasetName}/{datasetPKValue}</li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
@@ -300,6 +309,291 @@ error is parameter-specific. You can use this to display a message near
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="additionalfields" name="additionalfields" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h3>Additional Fields</h3>
|
||||
<p>
|
||||
The additional fields resource allows you to run and receive output from pre-defined Mifos X additional fieldsreports.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The Mifos X Individual Lending client application uses a JQuery plugin called stretchydata which, itself, uses this additional fields resource to provide a pretty flexible additional fields User Interface (UI). Put a link to an example here.
|
||||
</p>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<a id="listadditionalfields" name="listadditionalfields" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>List Additional Fields</h4>
|
||||
<p>
|
||||
Lists the types of additional field data that has been defined in Mifox X. If an Additional Data Type has more than one Addition Data Set it will be listed the same number of times as it has Sets.
|
||||
</p>
|
||||
|
||||
<h5>Arguments</h5>
|
||||
<dl class="argument-list">
|
||||
<dt>exportCSV</dt>
|
||||
<dd>optional, <span>The only valid value is 'true'. If any other value is provided the argument will be ignored</span></dd>
|
||||
<dd>Output will be delivered as a CSV file instead of JSON.</dd>
|
||||
</dl>
|
||||
<p>Example Request:
|
||||
<a style="word-wrap: break-word;" href="http://localhost:8080/mifosng-provider/api/v1/reports">http://localhost:8080/mifosng-provider/api/v1/reports</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">GET https://thedomainname/v1/reports</code>
|
||||
<code class="method-response">{
|
||||
"columnHeaders": [
|
||||
{
|
||||
"columnName": "report_id",
|
||||
"columnType": "INT",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "report_name",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "report_type",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
... more "columnHeaders" entries
|
||||
],
|
||||
"data": [
|
||||
{
|
||||
"row": [
|
||||
"29",
|
||||
"Client Listing",
|
||||
"Table",
|
||||
null,
|
||||
null,
|
||||
"5",
|
||||
null,
|
||||
"selectOfficeId"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"42",
|
||||
"Client Listing - Additional and Unlikely",
|
||||
"Table",
|
||||
null,
|
||||
null,
|
||||
"5",
|
||||
null,
|
||||
"selectOfficeId"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"30",
|
||||
"Client Loans Listing",
|
||||
"Table",
|
||||
null,
|
||||
null,
|
||||
"5",
|
||||
null,
|
||||
"selectOfficeId"
|
||||
]
|
||||
},
|
||||
... more "Row" entries
|
||||
]
|
||||
}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="retrieveadditionalfields" name="retrieveadditionalfields" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Retrieve Additional Data</h4>
|
||||
<p>
|
||||
Runs a report and returns the report output.
|
||||
</p>
|
||||
<h5>Arguments</h5>
|
||||
<dl class="argument-list">
|
||||
<dt>R_'parameter names' ...</dt>
|
||||
<dd>optional, <span>No defaults</span></dd>
|
||||
<dd>The number and names of the parameters depend on the specific report and how it has been configured. R_officeId is an example parameter name.</dd>
|
||||
<dd>Note: the prefix R_ stands for Reporting</dd>
|
||||
<dt>parameterType</dt>
|
||||
<dd>optional, <span>The only valid value is 'true'. If any other value is provided the argument will be ignored</span></dd>
|
||||
<dd>Determines whether the request looks in the list of reports or the list of parameters for its data.</dd>
|
||||
<dt>exportCSV</dt>
|
||||
<dd>optional, <span>The only valid value is 'true'. If any other value is provided the argument will be ignored</span></dd>
|
||||
<dd>Output will be delivered as a CSV file instead of JSON. Doesn't apply to Pentaho reports.</dd>
|
||||
</dl>
|
||||
|
||||
<p>Example Request:
|
||||
<a style="word-wrap: break-word;" href="http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1">http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">GET https://thedomainname/v1/reports/{REPORTNAME}</code>
|
||||
<code class="method-response">{
|
||||
"columnHeaders": [
|
||||
{
|
||||
"columnName": "Office/Branch",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "Name",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "Joining Date",
|
||||
"columnType": "DATE",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
}
|
||||
],
|
||||
"data": [
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"O'Meara, Patrick",
|
||||
"2009-01-04"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"O'Meara, Dennis",
|
||||
"2009-01-04"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"Smith, John",
|
||||
"2009-01-11"
|
||||
]
|
||||
},
|
||||
... more "row" entries
|
||||
]
|
||||
}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<a id="updateadditionalfields" name="updateadditionalfields" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
<h4>Update Additional Data</h4>
|
||||
<p>
|
||||
Runs a report and returns the report output.
|
||||
</p>
|
||||
<h5>Arguments</h5>
|
||||
<dl class="argument-list">
|
||||
<dt>R_'parameter names' ...</dt>
|
||||
<dd>optional, <span>No defaults</span></dd>
|
||||
<dd>The number and names of the parameters depend on the specific report and how it has been configured. R_officeId is an example parameter name.</dd>
|
||||
<dd>Note: the prefix R_ stands for Reporting</dd>
|
||||
<dt>parameterType</dt>
|
||||
<dd>optional, <span>The only valid value is 'true'. If any other value is provided the argument will be ignored</span></dd>
|
||||
<dd>Determines whether the request looks in the list of reports or the list of parameters for its data.</dd>
|
||||
<dt>exportCSV</dt>
|
||||
<dd>optional, <span>The only valid value is 'true'. If any other value is provided the argument will be ignored</span></dd>
|
||||
<dd>Output will be delivered as a CSV file instead of JSON. Doesn't apply to Pentaho reports.</dd>
|
||||
</dl>
|
||||
|
||||
<p>Example Request:
|
||||
<a style="word-wrap: break-word;" href="http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1">http://localhost:8080/mifosng-provider/api/v1/reports/Client%20Listing?R_officeId=1</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="method-example">
|
||||
<code class="method-declaration">GET https://thedomainname/v1/reports/{REPORTNAME}</code>
|
||||
<code class="method-response">{
|
||||
"columnHeaders": [
|
||||
{
|
||||
"columnName": "Office/Branch",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "Name",
|
||||
"columnType": "VARCHAR",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
},
|
||||
{
|
||||
"columnName": "Joining Date",
|
||||
"columnType": "DATE",
|
||||
"columnLength": null,
|
||||
"columnDisplayType": null,
|
||||
"columnValues": []
|
||||
}
|
||||
],
|
||||
"data": [
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"O'Meara, Patrick",
|
||||
"2009-01-04"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"O'Meara, Dennis",
|
||||
"2009-01-04"
|
||||
]
|
||||
},
|
||||
{
|
||||
"row": [
|
||||
"Demo MFI Head Office",
|
||||
"Smith, John",
|
||||
"2009-01-11"
|
||||
]
|
||||
},
|
||||
... more "row" entries
|
||||
]
|
||||
}</code>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="reports" name="reports" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
@@ -501,6 +795,12 @@ The Mifos X Individual Lending client application uses a JQuery plugin called st
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<a id="create_customer" name="create_customer" class="old-syle-anchor"> </a>
|
||||
<div class="method-section">
|
||||
<div class="method-description">
|
||||
|
||||
@@ -1,535 +0,0 @@
|
||||
(function($) {
|
||||
|
||||
$.stretchyData = {};
|
||||
|
||||
$.stretchyData.displayAllExtraData = function(params) {
|
||||
|
||||
if (!(params.url)) {
|
||||
alert(doI18N("reportingInitError - url parameter"));
|
||||
return;
|
||||
}
|
||||
if (!(params.datasetType)) {
|
||||
alert(doI18N("reportingInitError - datasetType parameter"));
|
||||
return;
|
||||
}
|
||||
if (!(params.datasetPKValue)) {
|
||||
alert(doI18N("reportingInitError - datasetPKValue parameter"));
|
||||
return;
|
||||
}
|
||||
if (!(params.datasetTypeDiv)) {
|
||||
alert(doI18N("reportingInitError - datasetTypeDiv parameter"));
|
||||
return;
|
||||
}
|
||||
var headingPrefix = "";
|
||||
if (params.headingPrefix)
|
||||
headingPrefix = params.headingPrefix;
|
||||
var headingClass = "";
|
||||
if (params.headingClass)
|
||||
headingClass = params.headingClass;
|
||||
var labelClass = "";
|
||||
if (params.labelClass)
|
||||
labelClass = params.labelClass;
|
||||
var valueClass = "";
|
||||
if (params.valueClass)
|
||||
valueClass = params.valueClass;
|
||||
//displayAllExtraData(params.url, params.datasetType,
|
||||
displayAllExtraData("http://localhost:8080/mifosng-provider/", params.datasetType,
|
||||
params.datasetPKValue, params.datasetTypeDiv, headingPrefix,
|
||||
headingClass, labelClass, valueClass);
|
||||
};
|
||||
|
||||
$.stretchyData.popupEditDialog = function(url, datasetType, datasetName,
|
||||
datasetPKValue, dsnDivName, title, width, height) {
|
||||
popupEditDialog(url, datasetType, datasetName, datasetPKValue,
|
||||
dsnDivName, title, width, height);
|
||||
};
|
||||
|
||||
displayAllSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
|
||||
var headingClassStr = "";
|
||||
if (displayAllVars.headingClass > "")
|
||||
headingClassStr = ' class="' + displayAllVars.headingClass + '" ';
|
||||
|
||||
var extraDataNamesVar = "";
|
||||
for ( var i in data.extraDatasetRow) {
|
||||
var dsnDivName = generateDsnDivName(displayAllVars.datasetType, i, displayAllVars.datasetTypeDiv);
|
||||
extraDataNamesVar += '<br><span ' + headingClassStr + '><b>'
|
||||
+ doI18N(displayAllVars.headingPrefix)
|
||||
+ doI18N(data.extraDatasetRow[i].name) + ' - </span></b> ';
|
||||
|
||||
extraDataNamesVar += editExtraDataLink(displayAllVars.url,
|
||||
displayAllVars.datasetType, data.extraDatasetRow[i].name,
|
||||
displayAllVars.datasetPKValue, dsnDivName);
|
||||
|
||||
extraDataNamesVar += '<div id="' + dsnDivName + '">';
|
||||
extraDataNamesVar += '</div>';
|
||||
}
|
||||
$('#' + displayAllVars.datasetTypeDiv).html(extraDataNamesVar);
|
||||
for ( var i in data.extraDatasetRow) {
|
||||
var dsnDivName = generateDsnDivName(displayAllVars.datasetType, i, displayAllVars.datasetTypeDiv);
|
||||
viewExtraData(displayAllVars.url, displayAllVars.datasetType,
|
||||
data.extraDatasetRow[i].name, displayAllVars.datasetPKValue, dsnDivName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
displayAllErrorFunction = function(jqXHR, textStatus, errorThrown) {
|
||||
alert(jqXHR.responseText);
|
||||
};
|
||||
|
||||
function displayAllExtraData(url, datasetType, datasetPKValue,
|
||||
datasetTypeDiv, headingPrefix, headingClass, labelClass, valueClass) {
|
||||
|
||||
displayAllVars = {
|
||||
url : url,
|
||||
datasetType : datasetType,
|
||||
datasetPKValue : datasetPKValue,
|
||||
datasetTypeDiv : datasetTypeDiv,
|
||||
headingPrefix : headingPrefix,
|
||||
headingClass : headingClass,
|
||||
labelClass : labelClass,
|
||||
valueClass : valueClass
|
||||
};
|
||||
|
||||
displayAllUrl = url + "api/v1/extradata?type="
|
||||
+ encodeURIComponent(datasetType);
|
||||
getData(displayAllUrl, displayAllSuccessFunction,
|
||||
displayAllErrorFunction);
|
||||
}
|
||||
|
||||
function editExtraDataLink(url, datasetType, datasetName, datasetPKValue,
|
||||
dsnDivName) {
|
||||
|
||||
var popupVar = "jQuery.stretchyData.popupEditDialog('" + url + "', '"
|
||||
+ datasetType + "', '" + datasetName + "', " + datasetPKValue
|
||||
+ ", '" + dsnDivName + "', '" + doI18N("Edit") + " "
|
||||
+ doI18N(datasetName) + "', 900, 500)";
|
||||
var editLink = '<A HREF="#" onClick="' + popupVar + '">'
|
||||
+ doI18N("Edit") + '</A><br>';
|
||||
// alert(editLink);
|
||||
return editLink;
|
||||
}
|
||||
|
||||
function viewExtraDataset(data, dsnDivName) {
|
||||
|
||||
var dataLength = data.data.length;
|
||||
var extraDataViewVar = '<table width="100%"><tr>';
|
||||
|
||||
var colsPerRow = 2;
|
||||
var colsPerRowCount = 0;
|
||||
var labelClassStr = "";
|
||||
var valueClassStr = "";
|
||||
if (displayAllVars.labelClass > "")
|
||||
labelClassStr = ' class="' + displayAllVars.labelClass + '" ';
|
||||
if (displayAllVars.valueClass > "")
|
||||
valueClassStr = ' class="' + displayAllVars.valueClass + '" ';
|
||||
|
||||
for ( var i in data.columnHeaders) {
|
||||
if (!(data.columnHeaders[i].columnName == "id")) {
|
||||
colsPerRowCount += 1;
|
||||
if (colsPerRowCount > colsPerRow) {
|
||||
extraDataViewVar += '</tr><tr>';
|
||||
colsPerRowCount = 1;
|
||||
}
|
||||
var colVal = "";
|
||||
if (dataLength > 0)
|
||||
colVal = data.data[0].row[i];
|
||||
if (colVal == null)
|
||||
colVal = "";
|
||||
|
||||
if (colVal > "" && data.columnHeaders[i].columnType == "Text")
|
||||
colVal = '<textarea rows="3" cols="40" readonly="readonly">'
|
||||
+ colVal + '</textarea>';
|
||||
extraDataViewVar += '<td valign="top"><span ' + labelClassStr
|
||||
+ '>' + doI18N(data.columnHeaders[i].columnName)
|
||||
+ ':</span></td><td valign="top"><span '
|
||||
+ valueClassStr + '>' + colVal + '</span></td>';
|
||||
}
|
||||
}
|
||||
extraDataViewVar += '</tr></table>';
|
||||
$('#' + dsnDivName).html(extraDataViewVar);
|
||||
// alert(dsnDivName + ": " + dsnDivName + extraDataViewVar);
|
||||
}
|
||||
;
|
||||
viewExtraDataErrorFunction = function(jqXHR, textStatus, errorThrown) {
|
||||
alert(jqXHR.responseText);
|
||||
};
|
||||
|
||||
function viewExtraData(url, datasetType, datasetName, datasetPKValue,
|
||||
dsnDivName) {
|
||||
var viewExtraDataUrl = url + "api/v1/extradata/" + encodeURIComponent(datasetType)
|
||||
+ "/" + encodeURIComponent(datasetName) + "/"
|
||||
+ encodeURIComponent(datasetPKValue);
|
||||
|
||||
var evalViewExtraDataSuccessFunction = "var viewExtraDataSuccessFunction = function(data, textStatus, jqXHR){ viewExtraDataset(data, '"
|
||||
+ dsnDivName + "'); };"
|
||||
eval(evalViewExtraDataSuccessFunction);
|
||||
getData(viewExtraDataUrl, viewExtraDataSuccessFunction,
|
||||
viewExtraDataErrorFunction);
|
||||
}
|
||||
|
||||
popupEditErrorFunction = function(jqXHR, textStatus, errorThrown) {
|
||||
alert("error");
|
||||
handleXhrError(jqXHR, textStatus, errorThrown, "#formErrorsTemplate",
|
||||
"#formerrors");
|
||||
};
|
||||
popupEditSuccessFunction = function(data, textStatus, jqXHR) {
|
||||
currentEditPopup.dialogDiv.append(extraDataBuildTemplate(data));
|
||||
extraDataOpenDialog(currentEditPopup.url);
|
||||
extraDataFormatDates(data.columnHeaders);
|
||||
};
|
||||
function popupEditDialog(url, datasetType, datasetName, datasetPKValue,
|
||||
dsnDivName, title, width, height) {
|
||||
|
||||
currentEditPopup = {
|
||||
dialogDiv : $("<div id='dialog-form'></div>"),
|
||||
dsnDivName : dsnDivName,
|
||||
title : title,
|
||||
width : width,
|
||||
height : height,
|
||||
datasetType : datasetType,
|
||||
datasetName : datasetName,
|
||||
datasetPKValue : datasetPKValue,
|
||||
baseUrl : url,
|
||||
url : url + "api/v1/extradata/" + encodeURIComponent(datasetType) + "/"
|
||||
+ encodeURIComponent(datasetName) + "/"
|
||||
+ encodeURIComponent(datasetPKValue)
|
||||
};
|
||||
getData(currentEditPopup.url, popupEditSuccessFunction,
|
||||
popupEditErrorFunction);
|
||||
}
|
||||
|
||||
function generateDsnDivName(datasetType, i, uniqueDivid) {
|
||||
return extraDataUnderscore(datasetType) + "_" + i + "_" + extraDataUnderscore(uniqueDivid);
|
||||
}
|
||||
|
||||
/* start of code to fill data in edit form */
|
||||
|
||||
function extraDataUnderscore(colName) {
|
||||
return colName.replace(/ /g, "_")
|
||||
}
|
||||
|
||||
function extraDataColDisplayHTML(colName, colType, colLength,
|
||||
colDisplayType, colAllowedValues, colVal) {
|
||||
var displayHTML = '<td valign="top"><label>' + colName
|
||||
+ ':</label></td><td valign="top">';
|
||||
var valueAttr = ""
|
||||
if (colVal != null)
|
||||
valueAttr = 'value="' + colVal.replace(/"/g, """) + '"';
|
||||
var colNameUnderscore = extraDataUnderscore(colName);
|
||||
|
||||
switch (colType) {
|
||||
case "String":
|
||||
var colAllowedValuesLength = colAllowedValues.length;
|
||||
if (colDisplayType != "List") {
|
||||
var colSize = 40;
|
||||
if (colLength < colSize)
|
||||
colSize = colLength;
|
||||
displayHTML += '<input id="' + colNameUnderscore + '" name="'
|
||||
+ colNameUnderscore + '" size="' + colSize + '" '
|
||||
+ valueAttr + ' type="text"/>'
|
||||
} else
|
||||
displayHTML += extraDataSelectTag(colNameUnderscore,
|
||||
colAllowedValues, colVal);
|
||||
break;
|
||||
case "Text":
|
||||
var textVal = "";
|
||||
if (colVal != null)
|
||||
textVal = colVal;
|
||||
displayHTML += '<textarea id="' + colNameUnderscore + '" name="'
|
||||
+ colNameUnderscore + '" rows="4" cols="40">' + textVal
|
||||
+ '</textarea>';
|
||||
break;
|
||||
case "Date":
|
||||
displayHTML += '<input id="' + colNameUnderscore + '" name="'
|
||||
+ colNameUnderscore + '" size="12" ' + valueAttr
|
||||
+ ' type="text"/>';
|
||||
break;
|
||||
case "Decimal":
|
||||
displayHTML += '<input id="' + colNameUnderscore + '" name="'
|
||||
+ colNameUnderscore + '" size="12" ' + valueAttr
|
||||
+ ' type="text"/>';
|
||||
break;
|
||||
case "Integer":
|
||||
displayHTML += '<input id="' + colNameUnderscore + '" name="'
|
||||
+ colNameUnderscore + '" size="12" ' + valueAttr
|
||||
+ ' type="text"/>';
|
||||
break;
|
||||
default:
|
||||
displayHTML += "'" + colType + "'";
|
||||
}
|
||||
displayHTML += '</td>';
|
||||
return displayHTML;
|
||||
}
|
||||
|
||||
function extraDataSelectTag(colName, colAllowedValues, colVal) {
|
||||
|
||||
var selectedVal = "";
|
||||
var selectHtml = '<select id="' + colName + '" name="' + colName + '">';
|
||||
|
||||
if ((colVal == null) || (colVal == ""))
|
||||
selectedVal = ' selected="selected" '
|
||||
else
|
||||
selectedVal = "";
|
||||
selectHtml += '<option value=""' + selectedVal + '></option>';
|
||||
|
||||
for ( var i in colAllowedValues) {
|
||||
if (colVal == colAllowedValues[i])
|
||||
selectedVal = ' selected="selected" '
|
||||
else
|
||||
selectedVal = "";
|
||||
selectHtml += '<option value="' + colAllowedValues[i] + '"'
|
||||
+ selectedVal + '>' + colAllowedValues[i] + '</option>';
|
||||
}
|
||||
|
||||
selectHtml += '</select>';
|
||||
// alert(selectHtml);
|
||||
return selectHtml;
|
||||
}
|
||||
|
||||
function extraDataBuildTemplate(data) {
|
||||
|
||||
var dataLength = data.data.length;
|
||||
var transType = 'E';
|
||||
if (dataLength == 0)
|
||||
transType = 'A';
|
||||
|
||||
var extraDataTemplateVar = '<form id="entityform"> <div id="formerrors"></div>';
|
||||
extraDataTemplateVar += '<input id="ed_transType" name="ed_transType" type="hidden" value="'
|
||||
+ transType + '"/>';
|
||||
|
||||
extraDataTemplateVar += '<table width="100%"><tr>';
|
||||
|
||||
var colsPerRow = 2;
|
||||
var colsPerRowCount = 0;
|
||||
|
||||
for ( var i in data.columnHeaders) {
|
||||
|
||||
if (!(data.columnHeaders[i].columnName == "id")) {
|
||||
colsPerRowCount += 1;
|
||||
if (colsPerRowCount > colsPerRow) {
|
||||
extraDataTemplateVar += '</tr><tr>';
|
||||
colsPerRowCount = 1;
|
||||
}
|
||||
var colVal = "";
|
||||
if (dataLength > 0)
|
||||
colVal = data.data[0].row[i];
|
||||
extraDataTemplateVar += extraDataColDisplayHTML(
|
||||
data.columnHeaders[i].columnName,
|
||||
data.columnHeaders[i].columnType,
|
||||
data.columnHeaders[i].columnLength,
|
||||
data.columnHeaders[i].columnDisplayType,
|
||||
data.columnHeaders[i].columnValues, colVal);
|
||||
}
|
||||
}
|
||||
extraDataTemplateVar += '</tr>';
|
||||
return extraDataTemplateVar += '</table></form>';
|
||||
}
|
||||
|
||||
function extraDataFormatDates(columnHeaders) {
|
||||
|
||||
for ( var i in columnHeaders) {
|
||||
// alert("in loop: " +
|
||||
// extraDataUnderscore(columnHeaders[i].columnName) + " Type: " +
|
||||
// columnHeaders[i].columnType);
|
||||
switch (columnHeaders[i].columnType) {
|
||||
case "Date":
|
||||
$('#' + extraDataUnderscore(columnHeaders[i].columnName))
|
||||
.datepicker({
|
||||
|
||||
changeMonth : true,
|
||||
changeYear : true,
|
||||
dateFormat : 'yy-mm-dd'
|
||||
});
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$.fn.serializeObject = function()
|
||||
{
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
$.each(a, function() {
|
||||
if (o[this.name] !== undefined) {
|
||||
if (!o[this.name].push) {
|
||||
o[this.name] = [o[this.name]];
|
||||
}
|
||||
o[this.name].push(this.value || '');
|
||||
} else {
|
||||
o[this.name] = this.value || '';
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
|
||||
function extraDataOpenDialog(url) {
|
||||
|
||||
// var saveButton = jQuery.i18n.prop('dialog.button.save');
|
||||
// var cancelButton = jQuery.i18n.prop('dialog.button.cancel');
|
||||
var saveButton = "save";
|
||||
var cancelButton = "cancel"
|
||||
|
||||
var buttonsOpts = {};
|
||||
buttonsOpts[saveButton] = function() {
|
||||
$('.multiSelectedItems option').each(function(i) {
|
||||
$(this).attr("selected", "selected");
|
||||
});
|
||||
|
||||
var form_data = JSON.stringify($('#entityform').serializeObject());
|
||||
//console.log(form_data);
|
||||
var jqxhr = $.ajax({
|
||||
url : url,
|
||||
type : 'POST',
|
||||
contentType : "application/json; charset=utf-8",
|
||||
// dataType : 'jsonp',
|
||||
// crossDomain : true,
|
||||
dataType : 'json',
|
||||
data : form_data,
|
||||
success : function(data, textStatus, jqXHR) {
|
||||
currentEditPopup.dialogDiv.dialog("close");
|
||||
viewExtraData(currentEditPopup.baseUrl,
|
||||
currentEditPopup.datasetType,
|
||||
currentEditPopup.datasetName,
|
||||
currentEditPopup.datasetPKValue,
|
||||
currentEditPopup.dsnDivName)
|
||||
},
|
||||
error : function(jqXHR, textStatus, errorThrown) {
|
||||
handleXhrError(jqXHR, textStatus, errorThrown,
|
||||
"#formErrorsTemplate", "#formerrors");
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
buttonsOpts[cancelButton] = function() {
|
||||
$(this).dialog("close");
|
||||
};
|
||||
|
||||
currentEditPopup.dialogDiv
|
||||
.dialog(
|
||||
{
|
||||
// title: jQuery.i18n.prop(titleCode),
|
||||
title : currentEditPopup.title,
|
||||
width : currentEditPopup.width,
|
||||
height : currentEditPopup.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');
|
||||
});
|
||||
}
|
||||
}).dialog('open');
|
||||
}
|
||||
|
||||
/* end of code to fill data in edit form and display it */
|
||||
|
||||
function getData(url, successFunction, errorFunction) {
|
||||
|
||||
$.ajax({
|
||||
url : url,
|
||||
cache : false,
|
||||
type : 'GET',
|
||||
contentType : "application/json; charset=utf-8",
|
||||
// dataType : 'jsonp',
|
||||
// crossDomain : true,
|
||||
dataType : 'json',
|
||||
//crossDomain : false,
|
||||
success : successFunction,
|
||||
error : errorFunction
|
||||
});
|
||||
}
|
||||
|
||||
function handleXhrError(jqXHR, textStatus, errorThrown, templateSelector,
|
||||
placeholderDiv) {
|
||||
if (jqXHR.status === 0) {
|
||||
alert('Not connect.\n Verify Network.');
|
||||
} else if (jqXHR.status == 404) {
|
||||
alert('Requested page not found. [404]');
|
||||
} else if (jqXHR.status == 500) {
|
||||
alert('Internal Server Error [500].');
|
||||
} else if (errorThrown === 'parsererror') {
|
||||
alert('Requested JSON parse failed.');
|
||||
} else if (errorThrown === 'timeout') {
|
||||
alert('Time out error.');
|
||||
} else if (errorThrown === 'abort') {
|
||||
alert('Ajax request aborted.');
|
||||
} else {
|
||||
// remove error class from all input fields
|
||||
var $inputs = $('#entityform :input');
|
||||
|
||||
$inputs.each(function() {
|
||||
$(this).removeClass("ui-state-error");
|
||||
});
|
||||
|
||||
$(placeholderDiv).html("");
|
||||
|
||||
var jsonErrors = JSON.parse(jqXHR.responseText);
|
||||
|
||||
var errorArray = new Array();
|
||||
var arrayIndex = 0;
|
||||
$.each(jsonErrors, function() {
|
||||
var fieldId = '#' + this.field;
|
||||
$(fieldId).addClass("ui-state-error");
|
||||
|
||||
var errorObj = new Object();
|
||||
errorObj.field = this.field;
|
||||
errorObj.code = this.code;
|
||||
errorObj.message = this.code;
|
||||
errorObj.value = this.value;
|
||||
|
||||
errorArray[arrayIndex] = errorObj;
|
||||
arrayIndex++
|
||||
});
|
||||
|
||||
var templateArray = new Array();
|
||||
var templateErrorObj = new Object();
|
||||
templateErrorObj.title = "You have the following errors:";
|
||||
templateErrorObj.errors = errorArray;
|
||||
|
||||
templateArray[0] = templateErrorObj;
|
||||
|
||||
var formErrorsHtml = $(templateSelector).render(templateArray);
|
||||
|
||||
$(placeholderDiv).append(formErrorsHtml);
|
||||
}
|
||||
}
|
||||
|
||||
function doI18N(xlateStr, params) {
|
||||
/*
|
||||
* if (I18N_Needed == "Y") { if (highlightMissingXlations == "Y") return
|
||||
* jQuery.i18n.prop(xlateStr, params) else { var xlated =
|
||||
* jQuery.i18n.prop(xlateStr, params); if (xlated.substr(0,1) == "[" &&
|
||||
* xlated.substr(xlated.length - 1, 1) == "]") return xlated.substr(1,
|
||||
* xlated.length - 2) else return xlated; } } else { var retStr =
|
||||
* xlateStr; if (retStr == 'rpt_select_one') retStr = 'Select One'; if
|
||||
* (retStr == 'rpt_select_all') retStr = 'Select All'; return retStr; }
|
||||
*/
|
||||
return xlateStr;
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
+10
-10
@@ -424,7 +424,7 @@ $(document).ready(function() {
|
||||
var offsetToApprovalDate = 0;
|
||||
var offsetToDisbursalDate = 0;
|
||||
var maxOffset = 0; // today
|
||||
|
||||
|
||||
if (currentTabIndex < 1) {
|
||||
console.log("success: client tab.");
|
||||
var tableHtml = $("#clientDataTabTemplate").render(data);
|
||||
@@ -436,8 +436,8 @@ $(document).ready(function() {
|
||||
refreshLoanSummaryInfo();
|
||||
|
||||
// retrieve additional info
|
||||
var extraDataParams = {
|
||||
url: '${rootContext}',
|
||||
var additionalFieldsParams = {
|
||||
url: "http://localhost:8080/mifosng-provider/",
|
||||
datasetType: "portfolio_client",
|
||||
datasetPKValue: data.id,
|
||||
datasetTypeDiv: "clientadditionaldata",
|
||||
@@ -446,7 +446,7 @@ $(document).ready(function() {
|
||||
labelClass: "longrowlabel",
|
||||
valueClass: "rowvalue"
|
||||
};
|
||||
jQuery.stretchyData.displayAllExtraData(extraDataParams);
|
||||
jQuery.stretchyData.displayAllExtraData(additionalFieldsParams);
|
||||
|
||||
// bind click listeners to buttons.
|
||||
$('.casflowbtn').button().click(function(e) {
|
||||
@@ -489,14 +489,14 @@ $(document).ready(function() {
|
||||
refreshNoteWidget();
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
var tableHtml = $("#loanDataTabTemplate").render(data);
|
||||
|
||||
var currentTab = $("#newtabs").children(".ui-tabs-panel").not(".ui-tabs-hide");
|
||||
currentTab.html(tableHtml);
|
||||
|
||||
var extraDataParams = {
|
||||
url: '${rootContext}',
|
||||
|
||||
var additionalFieldsParams = {
|
||||
url: "http://localhost:8080/mifosng-provider/",
|
||||
datasetType: "portfolio_loan",
|
||||
datasetPKValue: data.id,
|
||||
datasetTypeDiv: "loanadditionaldata" + data.id,
|
||||
@@ -505,8 +505,8 @@ $(document).ready(function() {
|
||||
labelClass: "longrowlabel",
|
||||
valueClass: "rowvalue"
|
||||
};
|
||||
jQuery.stretchyData.displayAllExtraData(extraDataParams);
|
||||
|
||||
jQuery.stretchyData.displayAllExtraData(additionalFieldsParams);
|
||||
|
||||
var curTabID = currentTab.prop("id")
|
||||
|
||||
offsetToSubmittedDate = data.maxSubmittedOnOffsetFromToday;
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
<script type="text/javascript" src="${resValue}/libs/jquery.views.js"></script>
|
||||
<script type="text/javascript" src="${resValue}/libs/jquery.observable.min.js"></script>
|
||||
<script type="text/javascript" src="${resValue}/libs/globalize/globalize.js"></script>
|
||||
<script type="text/javascript" src="${resValue}/stretchydata-0.91.js"></script>
|
||||
<script type="text/javascript" src="${resValue}/stretchydata-0.92.js"></script>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${not empty language}">
|
||||
|
||||
@@ -1,131 +0,0 @@
|
||||
package org.mifosng.platform.api;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.MultivaluedMap;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.mifosng.data.EntityIdentifier;
|
||||
import org.mifosng.data.ErrorResponse;
|
||||
import org.mifosng.data.ErrorResponseList;
|
||||
import org.mifosng.data.ExtraDatasets;
|
||||
import org.mifosng.data.reports.GenericResultset;
|
||||
import org.mifosng.platform.InvalidSqlException;
|
||||
import org.mifosng.platform.ReadExtraDataAndReportingService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Path("/v1/extradata")
|
||||
@Component
|
||||
@Scope("singleton")
|
||||
public class ExtraDataApiResource {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(ExtraDataApiResource.class);
|
||||
|
||||
@Autowired
|
||||
private ReadExtraDataAndReportingService readExtraDataAndReportingService;
|
||||
|
||||
@GET
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response datasets(@Context UriInfo uriInfo) {
|
||||
|
||||
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
|
||||
String type = queryParams.getFirst("type");
|
||||
|
||||
ExtraDatasets result = this.readExtraDataAndReportingService.retrieveExtraDatasetNames(type);
|
||||
return Response.ok().entity(result).build();
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("{datasetType}/{datasetName}/{datasetPKValue}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response extraData(@PathParam("datasetType") final String datasetType,@PathParam("datasetName") final String datasetName, @PathParam("datasetPKValue") final String datasetPKValue, @Context UriInfo uriInfo) {
|
||||
|
||||
try {
|
||||
GenericResultset result = this.readExtraDataAndReportingService.retrieveExtraData(datasetType, datasetName, datasetPKValue);
|
||||
|
||||
return Response.ok().entity(result).build();
|
||||
} catch (InvalidSqlException e) {
|
||||
List<ErrorResponse> allErrors = new ArrayList<ErrorResponse>();
|
||||
|
||||
ErrorResponse err = new ErrorResponse("extradata.invalid.sql", "sql", e.getSql());
|
||||
allErrors.add(err);
|
||||
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity(new ErrorResponseList(allErrors)).build());
|
||||
}
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("{datasetType}/{datasetName}/{datasetPKValue}")
|
||||
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
|
||||
@Produces({ MediaType.APPLICATION_JSON})
|
||||
public Response saveExtraData(@PathParam("datasetType") final String datasetType,@PathParam("datasetName") final String datasetName, @PathParam("datasetPKValue") final String datasetPKValue, String reqbody) {
|
||||
|
||||
try {
|
||||
|
||||
Map<String, String> queryParams = new HashMap<String, String>();
|
||||
String pValue = "";
|
||||
String pName;
|
||||
try {
|
||||
JSONObject jsonObj = new JSONObject(reqbody);
|
||||
JSONArray jsonArr = jsonObj.names();
|
||||
if (jsonArr != null) {
|
||||
for (int i = 0; i < jsonArr.length(); i++) {
|
||||
pName = (String) jsonArr.get(i);
|
||||
pValue = jsonObj.getString(pName);
|
||||
logger.info( pName + " - " + pValue);
|
||||
queryParams.put(pName, pValue);
|
||||
}
|
||||
} else {
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity("JSON body empty").build());
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity("JSON body is wrong").build());
|
||||
}
|
||||
|
||||
|
||||
this.readExtraDataAndReportingService.tempSaveExtraData(datasetType, datasetName, datasetPKValue, queryParams);
|
||||
|
||||
EntityIdentifier entityIdentifier = new EntityIdentifier(Long.valueOf(datasetPKValue));
|
||||
|
||||
return Response.ok().entity(entityIdentifier).build();
|
||||
} catch (InvalidSqlException e) {
|
||||
List<ErrorResponse> allErrors = new ArrayList<ErrorResponse>();
|
||||
|
||||
ErrorResponse err = new ErrorResponse("extradata.invalid.sql", "sql", e.getSql());
|
||||
allErrors.add(err);
|
||||
|
||||
logger.info("way bad: " + err.toString());
|
||||
throw new WebApplicationException(Response
|
||||
.status(Status.BAD_REQUEST)
|
||||
.entity(new ErrorResponseList(allErrors)).build());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user