=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Forms.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Forms.java 2012-10-15 10:20:17 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/webdomain/Forms.java 2012-10-15 12:37:39 +0000 @@ -31,9 +31,7 @@ import org.hisp.dhis.api.webdomain.form.Form; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; -import java.util.Set; /** * @author Morten Olav Hansen @@ -41,7 +39,7 @@ public class Forms { // maps ou.uid => org unit. - private Map organisationUnits = new HashMap( ); + private Map organisationUnits = new HashMap(); // maps dataSet.uid => form instance private Map forms = new HashMap(); === modified file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-09-29 03:50:36 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/WEB-INF/dhis-web-mobile-velocity/base.vm 2012-10-15 12:37:39 +0000 @@ -1,5 +1,5 @@ - + DHIS2 @@ -7,6 +7,7 @@ + - + @@ -40,7 +25,7 @@
@@ -51,330 +36,3 @@
- - - - - - - - - - - - - - - - === added file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js 2012-10-15 12:37:39 +0000 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2004-2012, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +var dhis2 = dhis2 || {}; +dhis2['storage'] = dhis2['storage'] || {}; + +dhis2.storage.FormManager = function ( args ) { + this._organisationUnits = undefined; + this._forms = undefined; + this._id = _.uniqueId('formManager'); +}; + +dhis2.storage.FormManager.prototype.initialize = function ( args ) { + $.ajax({ + url : '../api/currentUser/forms', + dataType : 'json' + }).success(function ( data ) { + localStorage['organisationUnits'] = JSON.stringify(data.organisationUnits); + localStorage['forms'] = JSON.stringify(data.forms); + }).error(function () { + // offline ? reuse meta-data already present + console.log("unable to load meta-data"); + }).complete(function() { + }); +}; + +dhis2.storage.FormManager.prototype.organisationUnits = function () { + if ( this._organisationUnits === undefined ) { + this._organisationUnits = JSON.parse(localStorage['organisationUnits']); + } + + return this._organisationUnits; +}; + +dhis2.storage.FormManager.prototype.organisationUnit = function (id) { + return this.organisationUnits()[id]; +}; + +dhis2.storage.FormManager.prototype.dataSets = function (id) { + var ou = this.organisationUnits()[id]; + return ou.dataSets; +}; + +dhis2.storage.FormManager.prototype.forms = function () { + if( this._forms === undefined ) { + this._forms = JSON.parse( localStorage['forms'] ); + } + + return this._forms; +}; + +dhis2.storage.FormManager.prototype.form = function ( id ) { + return this.forms()[id] +}; + +// global storage manager instance +(function () { + window.fm = new dhis2.storage.FormManager(); +}).call(); === added file 'dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/manifest.appcache' --- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/manifest.appcache 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/manifest.appcache 2012-10-15 12:37:39 +0000 @@ -0,0 +1,26 @@ +CACHE MANIFEST +# Version: 1 + +CACHE: +../mobile/index +../mobile/data-entry +../dhis-web-commons/javascripts/jQuery/jquery.min.js?v=1.7.1 +../dhis-web-commons/i18nJavaScript.action +../dhis-web-commons/javascripts/jQuery/jquery.glob.js +../dhis-web-commons/javascripts/jQuery/jquery.date.js +../dhis-web-commons/javascripts/date.js +../dhis-web-commons/javascripts/periodType.js +../dhis-web-commons/css/light_blue/logo_banner.png +css/jquery.mobile.min.css?v=1.1.1 +css/images/ajax-loader.gif +css/images/ajax-loader.png +css/images/icons-18-white.png +css/images/icons-18-black.png +css/images/icons-36-white.png +css/images/icons-36-black.png +js/underscore.min.js?v=1.3.3 +js/jquery.mobile.min.js?v=1.1.1 +js/dhis2.storage.js + +NETWORK: +*