← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17447: moved out js from dxf2MetaDataExport.vm

 

------------------------------------------------------------
revno: 17447
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-12 12:37:35 +0545
message:
  moved out js from dxf2MetaDataExport.vm
added:
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/dxf2MetaDataExport.js
modified:
  dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm


--
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/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2014-10-10 14:24:37 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/resources/struts.xml	2014-11-12 06:52:35 +0000
@@ -315,6 +315,7 @@
       <result name="success" type="velocity">/main.vm</result>
       <param name="menu">/dhis-web-importexport/mainMenu.vm</param>
       <param name="page">/dhis-web-importexport/dxf2MetaDataExport.vm</param>
+      <param name="javascripts">javascript/dxf2MetaDataExport.js</param>
       <param name="requiredAuthorities">F_METADATA_EXPORT</param>
     </action>
 

=== modified file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm	2014-11-11 20:57:25 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/dxf2MetaDataExport.vm	2014-11-12 06:52:35 +0000
@@ -1,114 +1,3 @@
-<script type="text/javascript">
-  jQuery(document).ready(function() {
-    $.ajax({
-      url: '../api/schemas.json',
-      dataType: 'json'
-    }).done(function( data ) {
-      var metadata = [];
-
-      $.each(data.schemas, function( idx ) {
-        if( this.metadata ) {
-          var o = {
-            name: this.displayName,
-            id: this.plural
-          }
-
-          metadata.push(o);
-        }
-      });
-
-      metadata.sort(function( a, b ) {
-        if( a.name < b.name )
-          return -1;
-        if( a.name > b.name )
-          return 1;
-        return 0;
-      });
-
-      $.each(metadata, function( idx ) {
-        var type = $('<div />').css({
-          width: '200px',
-          float: 'left'
-        });
-
-        var checkbox = $('<input type="checkbox"/>').attr('id', this.id).attr('value', true);
-        var labelFor = $('<label />').attr('for', this.id).text(this.name);
-
-        type.append(checkbox).append(labelFor);
-        $('#metadata').append(type);
-      });
-
-      selectAll();
-    })
-  });
-
-  function selectAll() {
-    $("#exportForm").find("input:checkbox").attr("checked", true);
-  }
-
-  function selectNone() {
-    $("#exportForm").find("input:checkbox").attr("checked", false);
-  }
-
-  function exportMetaData() {
-    if( $('#dataSets').is(':checked') ) {
-      $('#sections').attr('checked', true);
-    }
-    else {
-      $('#sections').removeAttr('checked');
-    }
-
-    if( $('#categories').is(':checked') ) {
-      $('#categoryCombos').attr('checked', true);
-      $('#categoryOptionCombos').attr('checked', true);
-      $('#categoryOptions').attr('checked', true);
-    }
-    else {
-      $('#categoryCombos').removeAttr('checked');
-      $('#categoryOptionCombos').removeAttr('checked');
-      $('#categoryOptions').removeAttr('checked');
-    }
-
-    if( $('#mapLegendSets').is(':checked') ) {
-      $('#mapLegends').attr('checked', true);
-    }
-    else {
-      $('#mapLegends').removeAttr('checked');
-    }
-
-    if( $('#maps').is(':checked') ) {
-      $('#mapViews').attr('checked', true);
-    }
-    else {
-      $('#mapViews').removeAttr('checked');
-    }
-
-    var url = "../api/metaData";
-    var format = $("#format").val();
-    var compression = $("#compression").val();
-
-    url += "." + format;
-
-    if( compression == "zip" ) {
-      url += ".zip";
-    }
-    else if( compression == "gz" ) {
-      url += ".gz";
-    }
-
-    var selected = {};
-
-    $("#exportForm").find('input:checked').each(function( idx ) {
-      selected[this.id] = this.value;
-    });
-
-    url += "?assumeTrue=false&" + $.param(selected);
-
-    log("url" + url);
-    window.location = url;
-  }
-</script>
-
 <h3>$i18n.getString( "metadata_export" )</h3>
 
 <form id="exportForm" name="exportForm">

=== added file 'dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/dxf2MetaDataExport.js'
--- dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/dxf2MetaDataExport.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-importexport/src/main/webapp/dhis-web-importexport/javascript/dxf2MetaDataExport.js	2014-11-12 06:52:35 +0000
@@ -0,0 +1,108 @@
+$(document).ready(function() {
+  $.ajax({
+    url: '../api/schemas.json',
+    dataType: 'json'
+  }).done(function( data ) {
+    var metadata = [];
+
+    $.each(data.schemas, function( idx ) {
+      if( this.metadata ) {
+        var o = {
+          name: this.displayName,
+          id: this.plural
+        }
+
+        metadata.push(o);
+      }
+    });
+
+    metadata.sort(function( a, b ) {
+      if( a.name < b.name )
+        return -1;
+      if( a.name > b.name )
+        return 1;
+      return 0;
+    });
+
+    $.each(metadata, function( idx ) {
+      var type = $('<div />').css({
+        width: '200px',
+        float: 'left'
+      });
+
+      var checkbox = $('<input type="checkbox"/>').attr('id', this.id).attr('value', true);
+      var labelFor = $('<label />').attr('for', this.id).text(this.name);
+
+      type.append(checkbox).append(labelFor);
+      $('#metadata').append(type);
+    });
+
+    selectAll();
+  })
+});
+
+function selectAll() {
+  $("#exportForm").find("input:checkbox").attr("checked", true);
+}
+
+function selectNone() {
+  $("#exportForm").find("input:checkbox").attr("checked", false);
+}
+
+function exportMetaData() {
+  if( $('#dataSets').is(':checked') ) {
+    $('#sections').attr('checked', true);
+  }
+  else {
+    $('#sections').removeAttr('checked');
+  }
+
+  if( $('#categories').is(':checked') ) {
+    $('#categoryCombos').attr('checked', true);
+    $('#categoryOptionCombos').attr('checked', true);
+    $('#categoryOptions').attr('checked', true);
+  }
+  else {
+    $('#categoryCombos').removeAttr('checked');
+    $('#categoryOptionCombos').removeAttr('checked');
+    $('#categoryOptions').removeAttr('checked');
+  }
+
+  if( $('#mapLegendSets').is(':checked') ) {
+    $('#mapLegends').attr('checked', true);
+  }
+  else {
+    $('#mapLegends').removeAttr('checked');
+  }
+
+  if( $('#maps').is(':checked') ) {
+    $('#mapViews').attr('checked', true);
+  }
+  else {
+    $('#mapViews').removeAttr('checked');
+  }
+
+  var url = "../api/metaData";
+  var format = $("#format").val();
+  var compression = $("#compression").val();
+
+  url += "." + format;
+
+  if( compression == "zip" ) {
+    url += ".zip";
+  }
+  else if( compression == "gz" ) {
+    url += ".gz";
+  }
+
+  var selected = {};
+
+  $("#exportForm").find('input:checked').each(function( idx ) {
+    selected[this.id] = this.value;
+  });
+
+  url += "?assumeTrue=false&" + $.param(selected);
+
+  log("url" + url);
+  window.location = url;
+}