dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #03450
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1158: Change JQuery by DHIS library - work in process
------------------------------------------------------------
revno: 1158
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Thu 2009-12-03 17:12:47 +0700
message:
Change JQuery by DHIS library - work in process
modified:
dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription.
=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2009-11-20 07:20:40 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js 2009-12-03 10:12:47 +0000
@@ -3,11 +3,23 @@
*/
function deleteReportExcelItem( id ){
if(window.confirm(i18n_confirm_delete)){
- $.get("deleteReportExcelItem.action",{id:id}, function(data){
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( Completed );
+ request.send("deleteReportExcelItem.action?id=" + id);
+
+
+ /* $.get("deleteReportExcelItem.action",{id:id}, function(data){
window.location.reload();
- });
+ }); */
}
}
+
+function Completed(xmlObject){
+ window.location.reload();
+}
+
/*
* Get Report Excel Item by Sheet
*/
@@ -19,8 +31,10 @@
* Open add report item
*/
function openAddReportItemForm(){
- $("#reportItemButton").click(validateAddReportExcelItem);
- $("#sheetNo").val($("#sheetNoFilter").val());
+ byId("reportItemButton").onclick = function(e){
+ validateAddReportExcelItem();
+ }
+ byId("sheetNo").value = byId("sheetNoFilter").value;
$("#report").showAtCenter( true );
}
@@ -29,7 +43,13 @@
*/
function openUpdateReportItem( id ){
- $.get("getReportExcelItem.action",{id:id}, function(data){
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( openUpdateReportItemReceived );
+ request.send("getReportExcelItem.action?id=" + id);
+
+ /* $.get("getReportExcelItem.action",{id:id}, function(data){
var reportItem = data.getElementsByTagName('reportItem')[0];
@@ -44,17 +64,48 @@
$("#reportItemButton").click(validateUpdateReportExcelItem);
$("#report").showAtCenter( true );
- },"xml");
+ },"xml"); */
}
+function openUpdateReportItemReceived(xmlObject){
+
+ byId("id").value = getElementValue (xmlObject, 'id');
+ byId("name").value = getElementValue (xmlObject, 'name');
+ byId("itemType").value = getElementValue (xmlObject, 'itemType');
+ byId("periodType").value = getElementValue (xmlObject, 'periodType');
+ byId("row").value = getElementValue (xmlObject, 'row');
+ byId("column").value = getElementValue (xmlObject, 'column');
+ byId("expression").value = getElementValue (xmlObject, 'expression');
+ byId("sheetNo").value = getElementValue (xmlObject, 'sheetNo');
+
+ byId("reportItemButton").onclick = function(e){
+ validateUpdateReportExcelItem();
+ };
+
+ $("#report").showAtCenter( true );
+}
+
/*
* Validate Add Report Excel Item
*/
function validateAddReportExcelItem(){
- $.post("validateAddReportExcelItem.action",{
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( validateAddReportExcelItemReceived );
+ var params = "name=" + byId("name").value;
+ params += "&expression=" + byId("expression").value;
+ params += "&row=" + byId("row").value;
+ params += "&column=" + byId("column").value;
+ params += "&sheetNo=" + byId("sheetNo").value;
+ params += "&reportId=" + byId("reportId").value;
+
+ request.sendAsPost(params);
+ request.send("validateAddReportExcelItem.action");
+
+ /* $.post("validateAddReportExcelItem.action",{
name:$("#name").val(),
expression:$("#expression").val(),
row:$("#row").val(),
@@ -72,12 +123,44 @@
{
addReportExcelItem();
}
- },'xml');
-
-}
-
+ },'xml'); */
+
+}
+
+function validateAddReportExcelItemReceived( xmlObject ){
+ var type = xmlObject.getAttribute( 'type' );
+ if(type=='error')
+ {
+ setMessage(xmlObject.firstChild.nodeValue);
+ }
+ if(type=='success')
+ {
+ addReportExcelItem();
+ }
+}
+
+/*
+* Add Report Excel Item
+*/
+
function addReportExcelItem(){
- $.post("addReportExcelItem.action",{
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( Completed );
+ var params = "name=" + byId("name").value;
+ params += "&expression=" + byId("expression").value;
+ params += "&row=" + byId("row").value;
+ params += "&column=" + byId("column").value;
+ params += "&reportId=" + reportId;
+ params += "&itemType=" + byId("itemType").value;
+ params += "&periodType=" + byId("periodType").value;
+ params += "&sheetNo=" + byId("sheetNo").value;
+
+ request.sendAsPost(params);
+ request.send("addReportExcelItem.action");
+
+ /* $.post("addReportExcelItem.action",{
name:$("#name").val(),
expression:$("#expression").val(),
row:$("#row").val(),
@@ -88,7 +171,7 @@
sheetNo:$("#sheetNo").val()
}, function (data){
window.location.reload();
- },'xml');
+ },'xml'); */
}
/*
@@ -96,8 +179,21 @@
*/
function validateUpdateReportExcelItem(){
-
- $.post("validateUpdateReportExcelItem.action",{
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( validateUpdateReportExcelItemReceived );
+ var params = "name=" + byId("name").value;
+ params += "&reportItemId=" + byId("id").value;
+ params += "&expression=" + byId("expression").value;
+ params += "&row=" + byId("row").value;
+ params += "&column=" + byId("column").value;
+ params += "&sheetNo=" + byId("sheetNo").value;
+ params += "&reportId=" + reportId;
+
+ request.sendAsPost(params);
+ request.send("validateUpdateReportExcelItem.action");
+
+ /* $.post("validateUpdateReportExcelItem.action",{
name:$("#name").val(),
reportItemId:$("#id").val(),
expression:$("#expression").val(),
@@ -116,12 +212,46 @@
{
updateReportExcelItem();
}
- },'xml');
-
-}
+ },'xml'); */
+
+}
+
+function validateUpdateReportExcelItemReceived( xmlObject ){
+
+ var type = xmlObject.getAttribute( 'type' );
+ if(type=='error')
+ {
+ setMessage(xmlObject.firstChild.nodeValue);
+ }
+ if(type=='success')
+ {
+ updateReportExcelItem();
+ }
+}
+
+/*
+* Update Report Excel Item
+*/
function updateReportExcelItem(){
- $.post("updateReportExcelItem.action",{
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( Completed );
+ var params = "id=" + byId("id").value;
+ params += "&name=" + byId("name").value;
+ params += "&expression=" + byId("expression").value;
+ params += "&row=" + byId("row").value;
+ params += "&column=" + byId("column").value;
+ params += "&reportId=" + reportId;
+ params += "&itemType=" + byId("itemType").value;
+ params += "&periodType=" + byId("periodType").value;
+ params += "&sheetNo=" + byId("sheetNo").value;
+
+ //request.sendAsPost(params);
+ request.send("updateReportExcelItem.action?" + params);
+
+/* $.post("updateReportExcelItem.action",{
id:$("#id").val(),
name:$("#name").val(),
expression:$("#expression").val(),
@@ -133,17 +263,17 @@
sheetNo:$("#sheetNo").val()
}, function (data){
window.location.reload();
- },'xml');
+ },'xml'); */
}
-function insertFormulaText(sourceId, targetId) {
- $("#" + targetId).html($("#"+targetId).html() + $("#"+sourceId).val());
+function insertFormulaText(sourceId, targetId) {
+ byId(targetId).value += byId(sourceId).value;
}
function insertOperation(target, value ){
- $("#" + target).html($("#" + target).html() + value);
+ byId(target).value += value;
}
function selectALL( checked ){
@@ -157,7 +287,13 @@
* COPY REPORT ITEM
*/
function copySelectedItem() {
- $.post("getAllReportExcels.action",{},
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( copySelectedItemReceived );
+ request.send("getAllReportExcels.action");
+
+ /* $.post("getAllReportExcels.action",{},
function (xmlObject){
xmlObject = xmlObject.getElementsByTagName('reports')[0];
var reports = xmlObject.getElementsByTagName("report");
@@ -170,9 +306,27 @@
options.add(new Option(name,id), null);
}
$("#copyTo").showAtCenter( true );
- },'xml');
-}
-
+ },'xml'); */
+
+}
+
+function copySelectedItemReceived(xmlObject){
+ var reports = xmlObject.getElementsByTagName("report");
+ var selectList = document.getElementById("targetReport");
+ var options = selectList.options;
+ options.length = 0;
+ for(i=0;i<reports.length;i++){
+ var id = reports[i].getElementsByTagName("id")[0].firstChild.nodeValue;
+ var name = reports[i].getElementsByTagName("name")[0].firstChild.nodeValue;
+ options.add(new Option(name,id), null);
+ }
+ $("#copyTo").showAtCenter( true );
+}
+
+
+/*
+* Validate Copy Report Items
+*/
sheetId = 0;
iReportItemsChecked = 0;
@@ -190,7 +344,15 @@
sheetId = $("#targetSheetNo").val();
- $.post("getReportExcelItems.action",
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( validateCopyReportItemsReceived );
+ var param = "reportId=" + byId("targetReport").value;
+ param += "sheetNo=" + sheetId;
+ request.sendAsPost(param);
+ request.send("getReportExcelItems.action");
+
+ /* $.post("getReportExcelItems.action",
{
reportId:$("#targetReport").val(),
sheetNo:sheetId
@@ -208,8 +370,21 @@
splitDuplicatedReportItems();
saveCopyItems();
- }, "xml");
-}
+ }, "xml"); */
+}
+
+function validateCopyReportItemsReceived(data){
+ var items = data.getElementsByTagName('reportItem');
+
+ for (var i = 0 ; i < items.length ; i ++)
+ {
+ reportItemsCurTarget.push(items[i].getElementsByTagName('name')[0].firstChild.nodeValue);
+ }
+
+ splitDuplicatedReportItems();
+ saveCopyItems();
+}
+
function splitDuplicatedReportItems() {
@@ -312,18 +487,22 @@
/**
-* DataElement Report type
+* Open dataelement expression
*/
function openDataElementExpression(){
- $("#formula").html($("#expression").val());
+ byId("formula").value = byId("expression").value;
getALLDataElementGroup();
getDataElementsByGroup();
- $("#dataElementGroup").attr("disabled", false);
- $("#availableDataElements").attr("disabled", false);
- $("#availableDataElements").change(getOptionCombos);
+ enable("dataElementGroup");
+ enable("availableDataElements");
+ byId("availableDataElements").onchange = function(e){getOptionCombos()};
$("#normal").showAtCenter( true );
}
+/**
+* Get All dataelement group
+*/
+
function getALLDataElementGroup(){
var list = byId('dataElementGroup');
list.options.length = 0;
@@ -334,6 +513,10 @@
}
}
+/**
+* Get DataElements By Group
+*/
+
function getDataElementsByGroup( )
{
var dataElementGroupId = $("#dataElementGroup").val();
@@ -366,7 +549,13 @@
}
function getOptionCombos(){
- $.get("getOptionCombos.action",{dataElementId:$("#availableDataElements").val()},
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( getOptionCombosReceived );
+ request.send( "getOptionCombos.action?dataElementId=" + byId("availableDataElements").value);
+
+ /* $.get("getOptionCombos.action",{dataElementId:$("#availableDataElements").val()},
function(xmlObject){
var xmlObject = xmlObject.getElementsByTagName('optionCombo')[0];
xmlObject = xmlObject.getElementsByTagName('categoryOptions')[0];
@@ -384,24 +573,41 @@
}
}
- ,'xml');
+ ,'xml'); */
+}
+
+function getOptionCombosReceived( xmlObject ){
+ xmlObject = xmlObject.getElementsByTagName('categoryOptions')[0];
+ var optionComboList = byId( "optionCombos" );
+ optionComboList.options.length = 0;
+ var optionCombos = xmlObject.getElementsByTagName( "categoryOption" );
+ for ( var i = 0; i < optionCombos.length; i++)
+ {
+ var id = optionCombos[ i ].getAttribute('id');
+ var name = optionCombos[ i ].firstChild.nodeValue;
+ var option = document.createElement( "option" );
+ option.value = id ;
+ option.text = name;
+ optionComboList.add( option, null );
+ }
}
function insertDataElementId(){
var dataElementComboId = "[" + $("#availableDataElements").val() + "." + $("#optionCombos").val() + "]";
- $("#formula").html($("#formula").html() + dataElementComboId);
+ byId("formula").value += dataElementComboId;
}
/**
* Indicator Report item type
*/
function openIndicatorExpression(){
- $("#formulaIndicator").html($("#expression").val());
+ byId("formulaIndicator").value = byId("expression").value;
getIndicatorGroups();
filterIndicators();
- $("#indicatorGroups").attr("disabled", false);
- $("#availableIndicators").attr("disabled", false);
- setPositionCenter( 'indicatorForm' );
+ enable("indicatorGroups");
+ enable("availableIndicators");
+ setPositionCenter( 'indicatorForm' );
+
$("#indicatorForm").show();
}
@@ -438,11 +644,18 @@
}
/**
-* Category Report item type
+* Open Category Expression
*/
function openCategoryExpression(){
- $("#categoryFormula").html($("#expression").val());
- $.get("getReportExcel.action",{id:reportId},
+
+ byId("categoryFormula").value = byId("expression").value;
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( openCategoryExpressionReceived );
+ request.send("getReportExcel.action?id=" + reportId);
+
+ /* $.get("getReportExcel.action",{id:reportId},
function(data){
var selectedDataElementGroups = document.getElementById('dataElementGroup_');
selectedDataElementGroups.options.length = 0;
@@ -460,12 +673,43 @@
showDivEffect();
$("#category").show();
- },'xml');
-
-}
+ },'xml'); */
+
+}
+
+function openCategoryExpressionReceived(data){
+ var selectedDataElementGroups = document.getElementById('dataElementGroup_');
+ selectedDataElementGroups.options.length = 0;
+ var dataElementGroups = data.getElementsByTagName('dataElementGroup');
+ for(var i=0;i<dataElementGroups.length;i++){
+ var id = dataElementGroups.item(i).getElementsByTagName('id')[0].firstChild.nodeValue;
+ var name = dataElementGroups.item(i).getElementsByTagName('name')[0].firstChild.nodeValue;
+ selectedDataElementGroups.options.add(new Option(name, id));
+ }
+ getDataElementGroupOrder();
+ setPositionCenter( 'category' );
+ enable("dataElementGroup_");
+ enable("availableDataElements_");
+ byId("availableDataElements_").onChange = function(e){getOptionCombos_()};
+
+ showDivEffect();
+ $("#category").show();
+}
+
+
+/**
+* Get DataElement Group Order
+*/
function getDataElementGroupOrder(){
- $.get("getDataElementGroupOrder.action",{id:$("#dataElementGroup_").val()},
+
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( getDataElementGroupOrderReceived );
+ request.send("getReportExcel.action?id=" + reportId);
+
+
+ /* $.get("getDataElementGroupOrder.action",{id:$("#dataElementGroup_").val()},
function( data ){
data = data.getElementsByTagName('dataElements')[0];
var availableDataElements = document.getElementById('availableDataElements_');
@@ -477,11 +721,29 @@
var name = dataelEments[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
availableDataElements.options.add(new Option(name, id));
}
- },'xml');
+ },'xml'); */
+}
+
+function getDataElementGroupOrderReceived(data){
+ var availableDataElements = document.getElementById('availableDataElements_');
+ availableDataElements.options.length = 0;
+ var dataelEments = data.getElementsByTagName( "dataElement" );
+ for ( var i = 0; i < dataelEments.length; i++ )
+ {
+ var id = dataelEments[ i ].getElementsByTagName( "id" )[0].firstChild.nodeValue;
+ var name = dataelEments[ i ].getElementsByTagName( "name" )[0].firstChild.nodeValue;
+ availableDataElements.options.add(new Option(name, id));
+ }
}
function getOptionCombos_(){
- $.get("getOptionCombos.action",{dataElementId:$("#availableDataElements_").val()},
+ var request = new Request();
+ request.setResponseTypeXML( 'xmlObject' );
+ request.setCallbackSuccess( getOptionCombos_Received );
+ request.send("getOptionCombos.action?dataElementId=" + byId("availableDataElements_").value);
+
+
+ /* $.get("getOptionCombos.action",{dataElementId:$("#availableDataElements_").val()},
function(xmlObject){
var xmlObject = xmlObject.getElementsByTagName('optionCombo')[0];
xmlObject = xmlObject.getElementsByTagName('categoryOptions')[0];
@@ -499,16 +761,26 @@
}
}
- ,'xml');
+ ,'xml'); */
+}
+
+function getOptionCombos_Received(xmlObject){
+ xmlObject = xmlObject.getElementsByTagName('categoryOptions')[0];
+ var optionComboList = byId( "optionCombos_" );
+ optionComboList.options.length = 0;
+ var optionCombos = xmlObject.getElementsByTagName( "categoryOption" );
+ for ( var i = 0; i < optionCombos.length; i++)
+ {
+ var id = optionCombos[ i ].getAttribute('id');
+ var name = optionCombos[ i ].firstChild.nodeValue;
+ var option = document.createElement( "option" );
+ option.value = id ;
+ option.text = name;
+ optionComboList.add( option, null );
+ }
}
function insertDataElementId_(){
- var dataElementComboId = "[*." + $("#optionCombos_").val() + "]";
- $("#categoryFormula").html($("#categoryFormula").html() + dataElementComboId);
-}
-
-/*
-* Organisation Unit Listing Report
-*/
-
-
+ var dataElementComboId = "[*." + byId("optionCombos_").value + "]";
+ byId("categoryFormula").value += dataElementComboId;
+}
\ No newline at end of file