Commits

Sebastian Sdorra  committed 08d1702

added Sonia.rest.JsonStore

  • Participants
  • Parent commits 04e9946

Comments (0)

Files changed (3)

File scm-webapp/src/main/webapp/index.html

     <script type="text/javascript" src="resources/extjs/ext-all-debug.js"></script>
 
     <script type="text/javascript" src="resources/js/global.js"></script>
+    <script type="text/javascript" src="resources/js/sonia.rest.js"></script>
     <script type="text/javascript" src="resources/js/sonia.login.js"></script>
     <script type="text/javascript" src="resources/js/sonia.group.js"></script>
     <script type="text/javascript" src="resources/js/sonia.repository.js"></script>

File scm-webapp/src/main/webapp/resources/js/sonia.group.js

   singleSelect: true
 });
 
-var groupStore = new Ext.data.JsonStore({
+var groupStore = new Sonia.rest.JsonStore({
   url: restUrl + 'groups.json',
   root: 'groups',
   fields: [

File scm-webapp/src/main/webapp/resources/js/sonia.rest.js

+/* 
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+Ext.ns("Sonia.rest");
+
+Sonia.rest.JsonStore = Ext.extend( Ext.data.JsonStore, {
+
+  constructor: function(config) {
+    var baseConfig = {
+      autoLoad: true,
+      listeners: {
+        // fix jersey empty array problem
+        exception: {
+          fn: function(proxy, type, action, options, response, arg){
+            if ( action == "read" && response.responseText == "null" ){
+              this.removeAll();
+            }
+          },
+          scope: this
+        }
+      }
+    };
+    Sonia.rest.JsonStore.superclass.constructor.call(this, Ext.apply(config, baseConfig));
+  }
+
+});