dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31837
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16259: Meta data detailed export, fixed export function, did not work at all
------------------------------------------------------------
revno: 16259
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-07-27 17:13:21 +0200
message:
Meta data detailed export, fixed export function, did not work at all
modified:
dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.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-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js 2014-07-27 14:56:46 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/filter.js 2014-07-27 15:13:21 +0000
@@ -1,14 +1,6 @@
-// Global Variables
-var filters = [];
-
-// -----------------------------------------------------------------------------
-// Document ready
-// -----------------------------------------------------------------------------
-
jQuery( function() {
tableSorter( "filterList" );
- loadFilters();
dhis2.contextmenu.makeContextMenu({
menuId: 'contextMenu',
@@ -17,34 +9,12 @@
});
} );
-// Create a new Filter form
function submitFilterForm( command )
{
$( "input[name='command']" ).val( command );
$( "#formFilter" ).submit();
}
-// -----------------------------------------------------------------------------
-// Load Filters
-// -----------------------------------------------------------------------------
-
-// Load Filters
-function loadFilters()
-{
- $.ajax( {
- type: "GET",
- url: "../api/filteredMetaData/getMetaDataFilters",
- dataType: "json",
- success: function( response ) {
- filters = response;
- },
- error: function( request, status, error ) {
- alert("Getting filters process failed.");
- }
- });
-}
-
-// Show Filter details
function showFilterDetails( context )
{
var filter = $.getJSON( "../api/metaDataFilters/" + context.uid, function( json ) {
@@ -54,29 +24,17 @@
} );
}
-// -----------------------------------------------------------------------------
-// Export Filtered MetaData
-// -----------------------------------------------------------------------------
-
-// Start export
function exportFilterButton( context )
{
- var filterUid = context.uid;
-
- for ( var i = 0; i < filters.length; i++ )
- {
- if ( filters[i].id == filterUid )
- {
- $( "#exportJson" ).attr( "value", filters[i].jsonFilter );
- jQuery( "#exportDialog" ).dialog( {
- title: i18n_export,
- modal: true
- } );
- }
- }
+ var filter = $.getJSON( "../api/metaDataFilters/" + context.uid, function( json ) {
+ $( "#exportJson" ).attr( "value", json.jsonFilter );
+ jQuery( "#exportDialog" ).dialog( {
+ title: i18n_export,
+ modal: true
+ } );
+ } );
}
-// Export MetaData
function exportFilteredMetaData()
{
var exportJson = {};
@@ -90,7 +48,6 @@
$( "#exportDialog" ).dialog( "close" );
}
-// Generate Export URL
function getURL()
{
var url = "../api/filteredMetaData";
@@ -110,74 +67,22 @@
return url;
}
-// -----------------------------------------------------------------------------
-// Edit a Filter
-// -----------------------------------------------------------------------------
-
-// Edit a Filter
function editFilterButton( context )
{
- var filterUid = context.uid;
-
- for ( var i = 0; i < filters.length; i++ )
- {
- if ( filters[i].id == filterUid )
- {
- $( "input[name='name']" ).val( filters[i].name );
- $( "input[name='description']" ).val( filters[i].description );
- $( "input[name='uid']" ).val( filters[i].id );
- $( "input[name='jsonFilter']" ).val( filters[i].jsonFilter );
- $( "input[name='command']" ).val( "update" );
- }
- }
+ //TODO this must be done properly
$( "#formFilter" ).submit();
}
-// -----------------------------------------------------------------------------
-// Delete a Filter
-// -----------------------------------------------------------------------------
-
-// Delete a Filter
function removeFilterButton( context )
{
- var filterUid = context.uid;
+ // TODO this must be done properly
- var filter = {};
- for ( var i = 0; i < filters.length; i++ )
- {
- if ( filters[i].id == filterUid )
- {
- filter = filters[i];
- }
- }
-
- var json = JSON.stringify( replaceIdWithUid( filter ) );
-
- $.ajax( {
- type: "POST",
- url: "../api/filteredMetaData/deleteFilter",
- contentType: "application/json",
- data: json,
- success: function ()
- {
- $( "#tr" + filter.uid ).remove();
- },
- error: function ( request, status, error )
- {
- alert( "Remove filter process failed." );
- }
- } );
-}
-
-// -----------------------------------------------------------------------------
-// Utils
-// -----------------------------------------------------------------------------
-
-// Replace id with uid
-function replaceIdWithUid( object )
-{
- object.uid = object.id;
- delete object.id;
- return object;
+ $.ajax( {
+ url: '../api/metaDataFilters/' + context.uid,
+ type: 'delete',
+ success: function() {
+ window.location.href = 'dxf2FilteredMetaDataExport.action'
+ }
+ } );
}