← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18105: event-capture - force to scroll to top of page when clicking save-and-add-new

 

------------------------------------------------------------
revno: 18105
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-01-22 17:55:07 +0100
message:
  event-capture - force to scroll to top of page when clicking save-and-add-new
removed:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifest.java
added:
  dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.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-apps/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-apps/src/main/resources/struts.xml	2014-12-15 14:00:36 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/resources/struts.xml	2015-01-22 16:55:07 +0000
@@ -46,7 +46,7 @@
 		<action name="index" class="org.hisp.dhis.commons.action.NoAction">
 			<result name="success" type="redirect">index.html</result>
 		</action>
-		<action name="cacheManifest" class="org.hisp.dhis.appcache.CacheManifest">
+		<action name="cacheManifest" class="org.hisp.dhis.appcache.CacheManifestAction">
 			<param name="appPath">dhis-web-event-capture</param>
 			<param name="i18nPath">i18n</param>
 			<param name="appCache">event-capture.appcache</param>			

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-01-21 20:11:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-01-22 16:55:07 +0000
@@ -9,6 +9,7 @@
                 $modal,
                 $timeout,
                 $translate,
+                $anchorScroll,
                 storage,
                 Paginator,
                 OptionSetService,
@@ -559,6 +560,7 @@
                 //decide whether to stay in the current screen or not.
                 if(addingAnotherEvent){
                     $scope.showEventRegistration();
+                    $anchorScroll();
                 }
             }
         });

=== removed file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifest.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifest.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifest.java	1970-01-01 00:00:00 +0000
@@ -1,204 +0,0 @@
-package org.hisp.dhis.appcache;
-
-/*
- * Copyright (c) 2004-2015, 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.
- */
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.ServletContext;
-
-import org.apache.struts2.ServletActionContext;
-import org.hisp.dhis.system.SystemInfo;
-import org.hisp.dhis.system.SystemService;
-import org.hisp.dhis.user.UserSettingService;
-import org.springframework.beans.factory.annotation.Autowired;
-
-import com.opensymphony.xwork2.Action;
-
-/**
- * @author Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
- *
- */
-public class CacheManifest
-    implements Action
-{
-
-    @Autowired
-    private UserSettingService userSettingService;
-
-    @Autowired
-    private SystemService systemService;
-
-    private String appPath;
-
-    public void setAppPath( String appPath )
-    {
-        this.appPath = appPath;
-    }
-
-    private String i18nPath;
-
-    public void setI18nPath( String i18nPath )
-    {
-        this.i18nPath = i18nPath;
-    }
-
-    private String appCache;
-
-    public void setAppCache( String appCache )
-    {
-        this.appCache = appCache;
-    }
-
-    private InputStream inputStream;
-
-    public InputStream getInputStream()
-    {
-        return inputStream;
-    }
-
-    // -------------------------------------------------------------------------
-    // Action implementation
-    // -------------------------------------------------------------------------
-
-    @Override
-    public String execute()
-    {
-        File cacheManifest = null;
-        File i18nFolder = null;
-        StringBuffer stringBuffer = null;
-
-        String locale = userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE ).toString();
-        SystemInfo info = systemService.getSystemInfo();
-        String revisionTag = "#Revision:" + info.getRevision();
-
-        String defaultTranslationFile = "i18n_app.properties";
-        String translationFile = "";
-        if ( locale.equalsIgnoreCase( "en" ) )
-        {
-            translationFile = defaultTranslationFile;
-        }
-        else
-        {
-            translationFile = "i18n_app_" + locale + ".properties";
-        }
-
-        if ( appPath != null && appCache != null )
-        {
-
-            ServletContext servletContext = ServletActionContext.getServletContext();
-            String fullPath = servletContext.getRealPath( appPath );
-
-            File folder = new File( fullPath );
-            File[] files = folder.listFiles();
-
-            for ( int i = 0; i < files.length; i++ )
-            {
-                if ( files[i].isFile() && files[i].getName().equalsIgnoreCase( appCache ) )
-                {
-                    cacheManifest = new File( files[i].getAbsolutePath() );
-                }
-
-                if ( i18nPath != null && files[i].isDirectory() && files[i].getName().equalsIgnoreCase( i18nPath ) )
-                {
-                    i18nFolder = new File( files[i].getAbsolutePath() );
-                }
-            }
-        }
-
-        if ( cacheManifest != null )
-        {
-            try
-            {
-                FileReader fileReader = new FileReader( cacheManifest );
-                BufferedReader bufferedReader = new BufferedReader( fileReader );
-                stringBuffer = new StringBuffer();
-                String line;
-                while ( (line = bufferedReader.readLine()) != null )
-                {
-                    stringBuffer.append( line );
-                    stringBuffer.append( "\n" );
-                }
-                stringBuffer.append( revisionTag );
-                stringBuffer.append( "\n" );
-
-                fileReader.close();
-
-                if ( i18nFolder != null )
-                {
-                    File[] i18nfiles = i18nFolder.listFiles();
-                    Boolean fileExists = false;
-                    for ( int i = 0; i < i18nfiles.length; i++ )
-                    {
-                        if ( i18nfiles[i].isFile() && i18nfiles[i].getName().equalsIgnoreCase( translationFile ) )
-                        {
-                            fileExists = true;
-                            stringBuffer.append( i18nPath + "/" + translationFile );
-                            stringBuffer.append( "\n" );
-                            break;
-                        }
-                    }
-
-                    if ( !fileExists )
-                    {
-                        stringBuffer.append( i18nPath + "/" + defaultTranslationFile );
-                        stringBuffer.append( "\n" );
-
-                    }
-                }
-
-                inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
-
-                return SUCCESS;
-
-            }
-            catch ( IOException e )
-            {
-                e.printStackTrace();
-            }
-
-        }
-
-        stringBuffer = new StringBuffer();
-        stringBuffer.append( "CACHE MANIFEST" );
-        stringBuffer.append( revisionTag );
-        stringBuffer.append( "\n" );
-        stringBuffer.append( "NETWORK:" );
-        stringBuffer.append( "\n" );
-        stringBuffer.append( "*" );
-
-        inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
-
-        return SUCCESS;
-    }
-}
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/appcache/CacheManifestAction.java	2015-01-22 16:55:07 +0000
@@ -0,0 +1,204 @@
+package org.hisp.dhis.appcache;
+
+/*
+ * Copyright (c) 2004-2015, 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+
+import org.apache.struts2.ServletActionContext;
+import org.hisp.dhis.system.SystemInfo;
+import org.hisp.dhis.system.SystemService;
+import org.hisp.dhis.user.UserSettingService;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import com.opensymphony.xwork2.Action;
+
+/**
+ * @author Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
+ *
+ */
+public class CacheManifestAction
+    implements Action
+{
+
+    @Autowired
+    private UserSettingService userSettingService;
+
+    @Autowired
+    private SystemService systemService;
+
+    private String appPath;
+
+    public void setAppPath( String appPath )
+    {
+        this.appPath = appPath;
+    }
+
+    private String i18nPath;
+
+    public void setI18nPath( String i18nPath )
+    {
+        this.i18nPath = i18nPath;
+    }
+
+    private String appCache;
+
+    public void setAppCache( String appCache )
+    {
+        this.appCache = appCache;
+    }
+
+    private InputStream inputStream;
+
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+
+    // -------------------------------------------------------------------------
+    // Action implementation
+    // -------------------------------------------------------------------------
+
+    @Override
+    public String execute()
+    {
+        File cacheManifest = null;
+        File i18nFolder = null;
+        StringBuffer stringBuffer = null;
+        
+        String locale = userSettingService.getUserSetting( UserSettingService.KEY_UI_LOCALE ).toString();
+        SystemInfo info = systemService.getSystemInfo();
+        String revisionTag = "#Revision:" + info.getRevision();
+
+        String defaultTranslationFile = "i18n_app.properties";
+        String translationFile = "";
+        if ( locale.equalsIgnoreCase( "en" ) )
+        {
+            translationFile = defaultTranslationFile;
+        }
+        else
+        {
+            translationFile = "i18n_app_" + locale + ".properties";
+        }
+
+        if ( appPath != null && appCache != null )
+        {
+
+            ServletContext servletContext = ServletActionContext.getServletContext();
+            String fullPath = servletContext.getRealPath( appPath );
+
+            File folder = new File( fullPath );
+            File[] files = folder.listFiles();
+
+            for ( int i = 0; i < files.length; i++ )
+            {
+                if ( files[i].isFile() && files[i].getName().equalsIgnoreCase( appCache ) )
+                {
+                    cacheManifest = new File( files[i].getAbsolutePath() );
+                }
+
+                if ( i18nPath != null && files[i].isDirectory() && files[i].getName().equalsIgnoreCase( i18nPath ) )
+                {
+                    i18nFolder = new File( files[i].getAbsolutePath() );
+                }
+            }
+        }
+
+        if ( cacheManifest != null )
+        {
+            try
+            {
+                FileReader fileReader = new FileReader( cacheManifest );
+                BufferedReader bufferedReader = new BufferedReader( fileReader );
+                stringBuffer = new StringBuffer();
+                String line;
+                while ( (line = bufferedReader.readLine()) != null )
+                {
+                    stringBuffer.append( line );
+                    stringBuffer.append( "\n" );
+                }
+                stringBuffer.append( revisionTag );
+                stringBuffer.append( "\n" );
+
+                fileReader.close();
+
+                if ( i18nFolder != null )
+                {
+                    File[] i18nfiles = i18nFolder.listFiles();
+                    Boolean fileExists = false;
+                    for ( int i = 0; i < i18nfiles.length; i++ )
+                    {
+                        if ( i18nfiles[i].isFile() && i18nfiles[i].getName().equalsIgnoreCase( translationFile ) )
+                        {
+                            fileExists = true;
+                            stringBuffer.append( i18nPath + "/" + translationFile );
+                            stringBuffer.append( "\n" );
+                            break;
+                        }
+                    }
+
+                    if ( !fileExists )
+                    {
+                        stringBuffer.append( i18nPath + "/" + defaultTranslationFile );
+                        stringBuffer.append( "\n" );
+
+                    }
+                }
+
+                inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
+
+                return SUCCESS;
+
+            }
+            catch ( IOException e )
+            {
+                e.printStackTrace();
+            }
+
+        }
+
+        stringBuffer = new StringBuffer();
+        stringBuffer.append( "CACHE MANIFEST" );
+        stringBuffer.append( revisionTag );
+        stringBuffer.append( "\n" );
+        stringBuffer.append( "NETWORK:" );
+        stringBuffer.append( "\n" );
+        stringBuffer.append( "*" );
+
+        inputStream = new ByteArrayInputStream( stringBuffer.toString().getBytes() );
+
+        return SUCCESS;
+    }
+}
\ No newline at end of file