Commits

Sebastian Sdorra committed 644a968

display categories in plugin overview

Comments (0)

Files changed (1)

scm-webapp/src/main/webapp/resources/js/plugin/sonia.plugin.grid.js

   colVersionText: 'Version',
   colActionText: 'Action',
   colUrlText: 'Url',
+  // TODO i18n
+  colCategoryText: 'Category',
   emptyText: 'No plugins avaiable',
 
   actionLinkTemplate: '<a style="cursor: pointer;" onclick="Sonia.plugin.CenterInstance.{1}(\'{2}\')">{0}</a>',
         {id: 'description', header: this.colDescriptionText, dataIndex: 'description'},
         {id: 'version', header: this.colVersionText, dataIndex: 'version'},
         {id: 'action', header: this.colActionText, renderer: this.renderActionColumn},
-        {id: 'Url', header: this.colUrlText, dataIndex: 'url', renderer: this.renderUrl, width: 150}
+        {id: 'Url', header: this.colUrlText, dataIndex: 'url', renderer: this.renderUrl, width: 150},
+        {id: 'Category', header: this.colCategoryText, dataIndex: 'category', hidden: true, hideable: false}
       ]
     });
+    
+    var pluginStore = new Ext.data.GroupingStore({
+      proxy: new Ext.data.HttpProxy({
+        url: restUrl + 'plugins/overview.json',
+        disableCaching: false
+      }),
+      reader: new Ext.data.JsonReader({
+        fields: [ 'name', 'author', 'description', 'url', 'version', 'state', 'groupId', 'artifactId', {
+          name: 'category',
+          convert: this.convertCategory,
+          scope: this
+        }]
+      }),
+      sortInfo: {
+        field: 'name'
+      },
+      autoLoad: true,
+      autoDestroy: true,
+      remoteGroup: false,
+      groupOnSort: false,
+      groupField: 'category',
+      groupDir: 'AES'
+    });
 
     var config = {
       title: main.tabPluginsText,
       autoExpandColumn: 'description',
-      store: new Sonia.plugin.Store({
-        url: restUrl + 'plugins/overview.json'
-      }),
+      store: pluginStore,
       colModel: pluginColModel,
-      emptyText: this.emptyText
+      emptyText: this.emptyText,
+      view: new Ext.grid.GroupingView({
+        forceFit: true,
+        enableGroupingMenu: false,
+        groupTextTpl: '{group} ({[values.rs.length]} {[values.rs.length > 1 ? "Plugins" : "Plugin"]})'
+      })
     };
 
     Sonia.plugin.CenterInstance.addListener('changed', function(){
     Ext.apply(this, Ext.apply(this.initialConfig, config));
     Sonia.plugin.Grid.superclass.initComponent.apply(this, arguments);
   },
+  
+  convertCategory: function(category){
+    return category ? category : 'Miscellaneous';
+  },
 
   renderActionColumn: function(val, meta, record){
     var out = "";
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.