← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 1159: Change JQuery by DHIS library - work in process

 

------------------------------------------------------------
revno: 1159
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: trunk
timestamp: Fri 2009-12-04 11:47:48 +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/dataElementGroup.js
  dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitemgroups.js
  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/reports.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/dataElementGroup.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/dataElementGroup.js	2009-12-03 04:08:58 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/dataElementGroup.js	2009-12-04 04:47:48 +0000
@@ -84,7 +84,7 @@
 * 	Add Data Element Group Order
 */
 function submitDataElementGroupOrder(){
-	if($("#name").val()=='') setMesaage(i18n_name_is_null);	
+	if(byId("name").value =='') setMessage(i18n_name_is_null);	
 	else{
 		selectAllById('selectedDataElements');
 		document.forms['dataElementGroups'].submit();

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitemgroups.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitemgroups.js	2009-12-03 04:08:58 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/excelitemgroups.js	2009-12-04 04:47:48 +0000
@@ -22,19 +22,6 @@
 	request.setCallbackSuccess( openUpdateExcelItemGroupReceived );
 	request.send("getExcelItemGroup.action?id=" + id);
 	
-	/*$.post("getExcelItemGroup.action",{id:id},
-	function ( xmlObject ){
-		
-		$("#id").val(id);
-		$("#name").val( xmlObject.getElementsByTagName('name')[0].firstChild.nodeValue );
-		$("#type").val( xmlObject.getElementsByTagName('type')[0].firstChild.nodeValue);
-		$("#periodType").val( xmlObject.getElementsByTagName('periodType')[0].firstChild.nodeValue);
-		
-		$("#divExcelitemGroup").showAtCenter( true );
-		$("#name").attr("disabled", true);
-		$("#type").attr("disabled", true);
-		
-	},'xml'); */	
 }
 
 function openUpdateExcelItemGroupReceived(xmlObject){
@@ -56,27 +43,11 @@
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
 	request.setCallbackSuccess( validateExcelItemGroupReceived );
-	request.send("validateExcelItemGroup.action?name=" + byId('name').value + "&type=" + byId('type').value);
+	var params = "name=" + byId('name').value;
+		params += "&type=" + byId('type').value
+	request.sendAsPost(params);
+	request.send( "validateExcelItemGroup.action" );
 	
-	/*$.post("validateExcelItemGroup.action",{		
-		name:$("#name").val(),
-		type:$("#type").val()
-	},function(xmlObject){
-		var xmlObject = xmlObject.getElementsByTagName('message')[0];
-		var type = xmlObject.getAttribute( 'type' );
-		if(type=='error')
-		{
-			setMessage(xmlObject.firstChild.nodeValue);
-		}else if(type=='success')
-		{
-			if(mode == 'add'){
-				addExcelItemGroup();
-			}else{
-				updateExcelItemGroup();
-			}
-			
-		}
-	},'xml');	*/
 }
 
 function validateExcelItemGroupReceived(xmlObject){
@@ -101,18 +72,12 @@
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
 	request.setCallbackSuccess( addExcelItemGroupReceived );
-	request.send("addExcelItemGroup.action?name=" + byId('name').value + 
-		"&type=" + byId('type').value + 
-		"&periodTypeName=" + byId('periodType').value );
-	
-	
-	/* $.post("addExcelItemGroup.action",{
-		name:$("#name").val(),
-		type:$("#type").val(),
-		periodTypeName:$("#periodType").val()
-	},function(data){
-		window.location.reload();
-	},'xml');	*/
+	var params = "name=" + byId('name').value;
+		params += "&type=" + byId('type').value;
+		params += "&periodTypeName=" + byId('periodType').value;
+	request.sendAsPost(params);
+	request.send("addExcelItemGroup.action");
+	
 }
 
 function addExcelItemGroupReceived(){
@@ -124,10 +89,12 @@
 	var request = new Request();
 	request.setResponseTypeXML( 'xmlObject' );
 	request.setCallbackSuccess( addExcelItemGroupReceived );
-	request.send("updateExcelItemGroup.action?id=" + byId('id').value + 
-		"&name=" + byId('name').value +
-		"&type=" + byId('type').value +
-		"&periodTypeName=" + byId('periodType').value );
+	var params = "id=" + byId('id').value;
+		params += "&name=" + byId('name').value;
+		params += "&type=" + byId('type').value
+		params += "&periodTypeName=" + byId('periodType').value;
+	request.sendAsPost(params);
+	request.send( "updateExcelItemGroup.action" );
 	
 	/* $.post("updateExcelItemGroup.action",{
 		id:$("#id").val(),
@@ -223,27 +190,6 @@
 	request.setCallbackSuccess( getALLDataElementGroupsReceived );	
 	request.send( "getAllDataElementGroups.action" );	
 	
-	/* $.get("getAllDataElementGroups.action",{},
-	function(data){
-		
-		var availableDataElementGroups = document.getElementById('availableDataElementGroups');
-		
-		availableDataElementGroups.options.length = 0;
-		
-		var dataElementGroups = data.getElementsByTagName('dataElementGroups')[0].getElementsByTagName('dataElementGroup');
-		
-		availableDataElementGroups.options.add(new Option("ALL", null));	
-		
-		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;
-			
-			var option = new Option( name, id );
-			availableDataElementGroups.add(option, null);
-		}			
-		getDataElementsByGroup($("#availableDataElementGroups").val());
-	},'xml'); */
 }
 
 function getALLDataElementGroupsReceived(data){
@@ -263,6 +209,6 @@
 		
 		var option = new Option( name, id );
 		availableDataElementGroups.add(option, null);
-	}			
+	}
 	getDataElementsByGroup(byId("availableDataElementGroups").value);
 }
\ No newline at end of file

=== 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-12-03 10:12:47 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reportItem.js	2009-12-04 04:47:48 +0000
@@ -239,17 +239,16 @@
 	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);
+		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");
 	
 /*	$.post("updateReportExcelItem.action",{
 		id:$("#id").val(),
@@ -266,8 +265,6 @@
 	},'xml');	*/
 }
 
-
-
 function insertFormulaText(sourceId, targetId) {
 	byId(targetId).value += byId(sourceId).value;
 }

=== modified file 'dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reports.js'
--- dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reports.js	2009-11-09 05:52:46 +0000
+++ dhis-2/dhis-web/dhis-web-excel-reporting/src/main/webapp/dhis-web-excel-reporting/javascript/reports.js	2009-12-04 04:47:48 +0000
@@ -9,9 +9,9 @@
 *	Open Add Report Excel Window
 */
 function openAddReportExcel(){		
-	$("#reportExcelAddUpdateButton").click(validateAddReportExcel);
-	$("#name").attr("disabled", false);	
-	$("#reportType").attr("disabled", false);	
+	byId("reportExcelAddUpdateButton").onclick = function (e) {validateAddReportExcel();};
+	enable("name");	
+	enable("reportType");
 	$("#report").showAtCenter( true );
 }
 
@@ -19,8 +19,24 @@
 *	Validate Add Report Excel
 */
 function validateAddReportExcel(){
-	strReportType = $("#reportType").val();
-	$.post("validateAddReportExcel.action",{		
+	
+	strReportType = byId("reportType").value;
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( validateAddReportExcelReceived );
+	var params = "name=" + byId("name").value;
+		params += "&excel=" + byId("excelTemplateFile").value;
+		params += "&reportType=" + byId("reportType").value;
+		params += "&periodRow=" + byId("periodRow").value;
+		params += "&periodCol=" + byId("periodColumn").value;
+		params += "&organisationRow=" + byId("organisationRow").value;
+		params += "&organisationCol=" + byId("organisationColumn").value;
+		params += "&groupName=" + byId("group").value;
+	request.sendAsPost(params);
+	request.send( "validateAddReportExcel.action" );
+	
+	/* $.post("validateAddReportExcel.action",{
 		name:$("#name").val(),
 		excel:$("#excelTemplateFile").val(),
 		reportType:$("#reportType").val(),
@@ -37,16 +53,44 @@
 			setMessage(xmlObject.firstChild.nodeValue);
 		}else if(type=='success')
 		{		
-			addReportExcel();			
+			addReportExcel();
 		}
-	},'xml');	
+	},'xml');	*/
+}
+
+function validateAddReportExcelReceived(xmlObject){
+	var type = xmlObject.getAttribute( 'type' );
+	if(type=='error')
+	{
+		setMessage(xmlObject.firstChild.nodeValue);
+	}else if(type=='success')
+	{		
+		addReportExcel();			
+	}
 }
 
 /*
 *	Add Report Excel
 */
 function addReportExcel(){	
-	$.post("addReportExcel.action",{		
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( Completed );
+	var params = "name=" + byId("name").value;
+		params += "&excel=" + byId("excelTemplateFile").value;
+		params += "&reportType=" + byId("reportType").value;
+		params += "&periodRow=" + byId("periodRow").value;
+		params += "&periodCol=" + byId("periodColumn").value;
+		params += "&organisationRow=" + byId("organisationRow").value;
+		params += "&organisationCol=" + byId("organisationColumn").value;
+		params += "&group=" + byId("group").value;
+	
+	request.sendAsPost(params);
+	request.send( "addReportExcel.action" );	
+
+	
+/*	$.post("addReportExcel.action",{		
 		name:$("#name").val(),
 		excel:$("#excelTemplateFile").val(),
 		reportType:$("#reportType").val(),
@@ -57,16 +101,20 @@
 		group:$("#group").val()
 	},function(data){
 		window.location.reload();
-	},'xml');	
+	},'xml');	*/
 	
 }
+
+function Completed(xmlObject){
+	window.location.reload();
+}
 /*
 *	Delete Report Excel
 */
 function deleteReportExcel( id ){
 	if(window.confirm(i18n_confirm_delete)){
 		window.location = "deleteReportExcel.action?id=" + id;
-	}		
+	}
 }
 
 
@@ -75,6 +123,13 @@
 *	Open Update Report Excel Window
 */
 function openUpdateReportReportExcel( id ){
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( openUpdateReportReportExcelReceived );
+	request.send( "getReportExcel.action?id=" + id );
+	
+	/* 
 	$.post("getReportExcel.action",{id:id},
 	function ( xmlObject ){
 		var report = xmlObject.getElementsByTagName('report')[0];
@@ -92,15 +147,50 @@
 		$("#report").showAtCenter( true );	
 		$("#name").attr("disabled", false);	
 		$("#reportType").attr("disabled", true);
-	},'xml');	
+	},'xml');	*/
+}
+
+function openUpdateReportReportExcelReceived(xmlObject){
+	reportId = getElementValue(xmlObject, 'id') ;
+	byId("name").value = getElementValue(xmlObject, 'name') ;
+	byId("excelTemplateFile").value = getElementValue(xmlObject, 'excelTemplateFile') ;
+	byId("periodRow").value = getElementValue(xmlObject, 'periodRow') ;
+	byId("periodColumn").value = getElementValue(xmlObject, 'periodColumn') ;
+	byId("organisationRow").value = getElementValue(xmlObject, 'organisationRow') ;
+	byId("organisationColumn").value = getElementValue(xmlObject, 'organisationColumn') ;
+	byId("reportType").value = getElementValue(xmlObject, 'reportType') ;
+	byId("group").value = getElementValue(xmlObject, 'group') ;	
+	
+	byId("reportExcelAddUpdateButton").onclick = function(e){ validateUpdateReportExcel();};		
+	$("#report").showAtCenter( true );	
+	enable("name");	
+	disable("reportType");
 }
 
 /*
 *	Validate Update Report Excel
 */
 function validateUpdateReportExcel(){
-	strReportType = $("#reportType").val();
-	$.post("validateUpdateReportExcel.action",{		
+	
+	strReportType = byId("reportType").value;
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( validateUpdateReportExcelReceived );
+	var params = "id=" + reportId;
+		params += "&name=" + byId("name").value;
+		params += "&excel=" + byId("excelTemplateFile").value;
+		params += "&reportType=" + byId("reportType").value;
+		params += "&periodRow=" + byId("periodRow").value;
+		params += "&periodCol=" + byId("periodColumn").value;
+		params += "&organisationRow=" + byId("organisationRow").value;
+		params += "&organisationCol=" + byId("organisationColumn").value;
+		params += "&groupName=" + byId("group").value;
+	request.sendAsPost(params);
+	request.send( "validateUpdateReportExcel.action" );
+	
+	
+	/*$.post("validateUpdateReportExcel.action",{		
 		id:reportId,
 		name:$("#name").val(),
 		excel:$("#excelTemplateFile").val(),
@@ -120,11 +210,40 @@
 		{		
 			updateReportExcel();			
 		}
-	},'xml');	
+	},'xml');	*/
+}
+
+function validateUpdateReportExcelReceived (xmlObject){
+	
+	var type = xmlObject.getAttribute( 'type' );
+	if(type=='error')
+	{
+		setMessage(xmlObject.firstChild.nodeValue);
+	}else if(type=='success')
+	{		
+		updateReportExcel();			
+	}
 }
 
 function updateReportExcel(){
-	$.post("updateReportExcel.action",{
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( Completed );
+	var params = "id=" + reportId;
+		params += "&name=" + byId("name").value;
+		params += "&excel=" + byId("excelTemplateFile").value;
+		params += "&periodRow=" + byId("periodRow").value;
+		params += "&periodCol=" + byId("periodColumn").value;
+		params += "&organisationRow=" + byId("organisationRow").value;
+		params += "&organisationCol=" + byId("organisationColumn").value;
+		params += "&group=" + byId("group").value;
+	request.sendAsPost(params);
+	
+	request.send( "updateReportExcel.action" );
+	
+	
+	/* $.post("updateReportExcel.action",{
 		id:reportId,	
 		name:$("#name").val(),
 		excel:$("#excelTemplateFile").val(),		
@@ -135,7 +254,7 @@
 		group:$("#group").val()
 	},function(data){
 		window.location.reload();
-	},'xml');	
+	},'xml');	*/
 }
 
 
@@ -158,7 +277,14 @@
 */
 
 function getALLDataElementGroups(){
-	$.get("getAllDataElementGroups.action",{},
+	
+	var request = new Request();
+	request.setResponseTypeXML( 'datalement' );
+	request.setCallbackSuccess( getALLDataElementGroupsReceived );
+	request.send( "getAllDataElementGroups.action" );
+	
+	
+	/* $.get("getAllDataElementGroups.action",{},
 	function(data){
 		var availableDataElementGroups = document.getElementById('availableDataElementGroups');
 		availableDataElementGroups.options.length = 0;
@@ -169,15 +295,33 @@
 			availableDataElementGroups.options.add(new Option(name, id));			
 		}
 		getReportDataElementGroups(reportId);
-	},'xml');
+	},'xml'); */
 }
 
+function getALLDataElementGroupsReceived( data ){
+	var availableDataElementGroups = document.getElementById('availableDataElementGroups');
+	availableDataElementGroups.options.length = 0;
+	var dataElementGroups = data.getElementsByTagName('dataElementGroups')[0].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;
+		availableDataElementGroups.options.add(new Option(name, id));			
+	}
+	getReportDataElementGroups(reportId);
+}
 /*
 * Get DataElement Order of Report Excel
 */
 
 function getReportDataElementGroups( id ){
-	$.get("getReportExcel.action",{id:id},		
+	
+	var request = new Request();
+    request.setResponseTypeXML( 'xmlObject' );
+    request.setCallbackSuccess( getReportDataElementGroupsReceived );
+	request.send( "getReportExcel.action?id=" + id );	
+	
+	
+	/* $.get("getReportExcel.action",{id:id},		
 	function(data){
 		var selectedDataElementGroups = document.getElementById('selectedDataElementGroups');
 		selectedDataElementGroups.options.length = 0;
@@ -197,7 +341,28 @@
 			}
 		}	
 		$("#dataElementGroups").showAtCenter( true );
-	},'xml');	
+	},'xml');	*/
+}
+
+function getReportDataElementGroupsReceived(data){
+	var selectedDataElementGroups = document.getElementById('selectedDataElementGroups');
+	selectedDataElementGroups.options.length = 0;
+	var dataElementGroups = data.getElementsByTagName('dataElementGroups')[0].getElementsByTagName('dataElementGroup');
+	for(var i=0;i<dataElementGroups.length;i++){
+		var id = dataElementGroups.item(i).getElementsByTagName('dataElementGroupId')[0].firstChild.nodeValue;
+		var name = dataElementGroups.item(i).getElementsByTagName('name')[0].firstChild.nodeValue;
+		selectedDataElementGroups.options.add(new Option(name, id));
+	}		
+	var availableDataElementGroups = document.getElementById('availableDataElementGroups');
+	var selectedDataElementGroups = document.getElementById('selectedDataElementGroups');
+	for(var i=0;i<availableDataElementGroups.options.length;i++){
+		for(var j=0;j<selectedDataElementGroups.options.length;j++){				
+			if(availableDataElementGroups.options[i].value==selectedDataElementGroups.options[j].value){					
+				availableDataElementGroups.options[i] = null;
+			}
+		}
+	}	
+	$("#dataElementGroups").showAtCenter( true );
 }
 
 /*
@@ -216,13 +381,28 @@
 
 
 function backupReportExcel( id ){
-	$.post("backupReportExcel.action",{id:id},function(data){
+	var request = new Request();
+    request.setResponseTypeXML( 'xmlObject' );
+    request.setCallbackSuccess( backupReportExcelReceived );
+	request.send( "backupReportExcel.action?id=" + id );	
+	
+	/* $.post("backupReportExcel.action",{id:id},function(data){
 		window.location = "downloadFile.action?outputFormat=application/xml-external-parsed-entity";
-	},'xml');
+	},'xml'); */
+}
+
+function backupReportExcelReceived(data){
+	window.location = "downloadFile.action?outputFormat=application/xml-external-parsed-entity";
 }
 
 function restoreReportExcel(){
-	$.post("restoreReportExcel.action",{},function(xmlObject){
+	
+	var request = new Request();
+    request.setResponseTypeXML( 'xmlObject' );
+    request.setCallbackSuccess( restoreReportExcelReceived );
+	request.send( "restoreReportExcel.action");	
+	
+	/* $.post("restoreReportExcel.action",{},function(xmlObject){
 		var xmlObject = xmlObject.getElementsByTagName('message')[0];
 		var type = xmlObject.getAttribute( 'type' );
 		if(type=='error')
@@ -232,13 +412,16 @@
 		{		
 			window.location.reload();	
 		}
-	},'xml');	
+	},'xml');	*/
 }
 
-
-
-
-
-
-
-
+function restoreReportExcelReceived(xmlObject){
+	var type = xmlObject.getAttribute( 'type' );
+	if(type=='error')
+	{
+		setMessage(xmlObject.firstChild.nodeValue);
+	}else if(type=='success')
+	{		
+		window.location.reload();	
+	}
+}
\ No newline at end of file