]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager/dc/GroupView.js
add htmlEncode to various comment/description fields
[pve-manager.git] / www / manager / dc / GroupView.js
index b60f1935a1a9b9ef29f4231fc0cc62897e6924a3..0864b7a961ed5d5d0c19dfbacabf458edb63a9ba 100644 (file)
@@ -8,10 +8,6 @@ Ext.define('PVE.dc.GroupView', {
 
        var store = new Ext.data.Store({
            model: 'pve-groups',
-           proxy: {
-                type: 'pve',
-               url: "/api2/json/access/groups"
-           },
            sorters: { 
                property: 'groupid', 
                order: 'DESC' 
@@ -22,58 +18,68 @@ Ext.define('PVE.dc.GroupView', {
             store.load();
         };
 
-       var remove_btn = new Ext.Button({
-           text: 'Delete',
-           disabled: true,
-           handler: function() {
-               var sm = me.getSelectionModel();
-               var rec = sm.getSelection()[0];
-               if (!rec) {
-                   return;
-               }
-               var groupid = rec.data.groupid;
+       var sm = Ext.create('Ext.selection.RowModel', {});
 
-               var msg = 'Are you sure you want to permanently delete the group: ' + groupid;
-               Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
-                   if (btn !== 'yes') {
-                       return;
+       var remove_btn = new PVE.button.Button({
+           text: gettext('Remove'),
+           disabled: true,
+           selModel: sm,
+           confirmMsg: function (rec) {
+               return Ext.String.format(gettext('Are you sure you want to remove entry {0}'),
+                                        "'" + rec.data.groupid + "'");
+           },
+           handler: function(btn, event, rec) {
+               PVE.Utils.API2Request({
+                   url: '/access/groups/' + rec.data.groupid,
+                   method: 'DELETE',
+                   waitMsgTarget: me,
+                   callback: function() {
+                       reload();
+                   },
+                   failure: function (response, opts) {
+                       Ext.Msg.alert(gettext('Error'), response.htmlStatus);
                    }
-                   PVE.Utils.API2Request({
-                       url: '/access/groups/' + groupid,
-                       method: 'DELETE',
-                       waitMsgTarget: me,
-                       callback: function() {
-                           reload();
-                       },
-                       failure: function (response, opts) {
-                           Ext.Msg.alert('Error',response.htmlStatus);
-                       }
-                   });
                });
            }
        });
 
+       var run_editor = function() {
+           var rec = sm.getSelection()[0];
+           if (!rec) {
+               return;
+           }
+
+            var win = Ext.create('PVE.dc.GroupEdit',{
+                groupid: rec.data.groupid
+            });
+            win.on('destroy', reload);
+            win.show();
+       };
+
+       var edit_btn = new PVE.button.Button({
+           text: gettext('Edit'),
+           disabled: true,
+           selModel: sm,
+           handler: run_editor
+       });
+
        var tbar = [
             {
-               text: 'Create',
+               text: gettext('Create'),
                handler: function() {
-                   var win = Ext.create('PVE.dc.GroupEdit', {
-                   });
+                   var win = Ext.create('PVE.dc.GroupEdit', {});
                    win.on('destroy', reload);
                    win.show();
                }
             },
-           remove_btn
+           edit_btn, remove_btn
         ];
 
-       var set_button_status = function() {
-           var sm = me.getSelectionModel();
-           var rec = sm.getSelection()[0];
-           remove_btn.setDisabled(!rec);
-       };
+       PVE.Utils.monStoreErrors(me, store);
 
        Ext.apply(me, {
            store: store,
+           selModel: sm,
            stateful: false,
            tbar: tbar,
            viewConfig: {
@@ -81,32 +87,25 @@ Ext.define('PVE.dc.GroupView', {
            },
            columns: [
                {
-                   header: 'Group name',
+                   header: gettext('Name'),
                    width: 200,
                    sortable: true,
                    dataIndex: 'groupid'
                },
                {
-                   header: 'Comment',
+                   header: gettext('Comment'),
                    sortable: false,
                    dataIndex: 'comment',
+                   renderer: Ext.String.htmlEncode,
                    flex: 1
                }
            ],
            listeners: {
                show: reload,
-               selectionchange: set_button_status
+               itemdblclick: run_editor
            }
        });
 
        me.callParent();
     }
-}, function() {
-
-    Ext.define('pve-groups', {
-       extend: 'Ext.data.Model',
-       fields: [ 'groupid', 'comment' ],
-       idProperty: 'groupid'
-    });
-
 });