From bc1b6c8a4b0ff50a99eb5baf476ef06b7c8c7a59 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Tue, 22 Mar 2016 15:15:49 +0800 Subject: [PATCH] Pman.Tab.AdminContactsGroup.bjs Pman.Tab.AdminContactsGroup.js --- Pman.Tab.AdminContactsGroup.bjs | 320 ++++++------ Pman.Tab.AdminContactsGroup.js | 872 ++++++++++++++++---------------- 2 files changed, 614 insertions(+), 578 deletions(-) diff --git a/Pman.Tab.AdminContactsGroup.bjs b/Pman.Tab.AdminContactsGroup.bjs index 9eb580b..6aa982b 100644 --- a/Pman.Tab.AdminContactsGroup.bjs +++ b/Pman.Tab.AdminContactsGroup.bjs @@ -1,161 +1,169 @@ { - "id": "roo-file-71", - "name": "Pman.Tab.AdminContactsGroup", - "parent": "Pman.Tab.AdminContactsManager", - "title": "Pman.Tab.AdminContactsGroup", - "path": "/home/chris/gitlive/Pman.Admin/Pman.Tab.AdminContactsGroup.bjs", - "items": [ + "name" : "Pman.Tab.AdminContactsGroup", + "parent" : "Pman.Tab.AdminContactsManager", + "title" : "Pman.Tab.AdminContactsGroup", + "path" : "/home/alan/gitlive/Pman.Admin/Pman.Tab.AdminContactsGroup.bjs", + "permname" : "", + "modOrder" : "001", + "strings" : { + "ec211f7c20af43e742bf2570c3cb84f9" : "Add", + "a37ede293936e29279ed543129451ec3" : "Groups", + "7dce122004969d56ae2e0245cb754d35" : "Edit", + "4d1c8263ba1036754f8db14a98f9f006" : "Reload", + "f2a6c498fb90ee345d997f888fce3b18" : "Delete", + "49ee3087348e8d44e1feda1917443987" : "Name", + "aba9f7d7443652e858969bfc280690b1" : "Manage Groups" + }, + "items" : [ + { + "listeners" : { + "|activate" : "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.ds.load({});\n }\n}" + }, + "fitToframe" : true, + "background" : true, + "region" : "west", + "title" : "Groups", + "xtype" : "GridPanel", + "fitContainer" : true, + "$ xns" : "Roo", + "tableName" : "Groups", + "items" : [ + { + "listeners" : { + "|rowdblclick" : "function (_self, rowIndex, e)\n{\n if (!_this.dialog) return;\n var s = this.getDataSource().getAt(rowIndex);\n if (s.data.id < 1 ) {\n return;\n }\n _this.dialog.show( s.data, function() {\n _this.ds.load({});\n }); \n}\n", + "|render" : "function() \n{\n _this.grid = this; \n _this.dialog = Pman.Dialog.Groups;\n if (_this.panel.active) {\n _this.grid.ds.load({});\n }\n}" + }, + "autoExpandColumn" : "name", + "enableDrop" : true, + "xtype" : "Grid", + "ddGroup" : "groupDD", + "loadMask" : true, + "$ xns" : "Roo.grid", + "* prop" : "grid", + "items" : [ + { + "listeners" : { + "beforeload" : "function (_self, o)\n{\n o.params = o.params || {};\n o.params.type =2;\n}", + "load" : "function (_self, records, options)\n{\n var sm = _this.grid.getSelectionModel();\n if (!sm.getSelections().length) {\n sm.selectFirstRow();\n }\n Pman.Tab.AdminContacts.grid.footer.onClick('first');\n}" + }, + "xtype" : "Store", + "remoteSort" : true, + "$ sortInfo" : "{ field : 'name', direction: 'ASC' }", + "$ xns" : "Roo.data", + "* prop" : "dataSource", + "items" : [ { - "listeners": { - "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.ds.load({});\n }\n}" + "$ url" : "baseURL + '/Roo/Groups.php'", + "method" : "GET", + "xtype" : "HttpProxy", + "$ xns" : "Roo.data", + "* prop" : "proxy" + }, + { + "id" : "id", + "root" : "data", + "xtype" : "JsonReader", + "$ xns" : "Roo.data", + "$ fields" : "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'name',\n 'type': 'string'\n },\n {\n 'name': 'type',\n 'type': 'int'\n },\n {\n 'name': 'leader',\n 'type': 'int'\n },\n {\n 'name': 'leader_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_office_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_name',\n 'type': 'string'\n },\n {\n 'name': 'leader_phone',\n 'type': 'string'\n },\n {\n 'name': 'leader_fax',\n 'type': 'string'\n },\n {\n 'name': 'leader_email',\n 'type': 'string'\n },\n {\n 'name': 'leader_company_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_role',\n 'type': 'string'\n },\n {\n 'name': 'leader_active',\n 'type': 'int'\n },\n {\n 'name': 'leader_remarks',\n 'type': 'string'\n },\n {\n 'name': 'leader_passwd',\n 'type': 'string'\n },\n {\n 'name': 'leader_owner_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_lang',\n 'type': 'string'\n },\n {\n 'name': 'leader_no_reset_sent',\n 'type': 'int'\n },\n {\n 'name': 'leader_action_type',\n 'type': 'string'\n },\n {\n 'name': 'leader_project_id',\n 'type': 'int'\n }\n]", + "* prop" : "reader", + "totalProperty" : "total" + } + ] + }, + { + "xtype" : "Toolbar", + "$ xns" : "Roo", + "* prop" : "toolbar", + "items" : [ + { + "text" : "Manage Groups", + "xtype" : "Button", + "$ xns" : "Roo.Toolbar", + "items" : [ + { + "xtype" : "Menu", + "$ xns" : "Roo.menu", + "* prop" : "menu", + "items" : [ + { + "listeners" : { + "|click" : "function()\n{\n if (!_this.dialog) return;\n _this.dialog.show( { id : 0, type: 2 } , function() {\n _this.grid.ds.load({});\n }); \n}\n" + }, + "text" : "Add", + "xtype" : "Item", + "cls" : "x-btn-text-icon", + "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'", + "$ xns" : "Roo.menu" + }, + { + "listeners" : { + "|click" : "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n }\n if (s[0].data.id < 1 ) {\n return;\n }\n if (!_this.dialog) return;\n _this.dialog.show(s[0].data, function() {\n _this.grid.ds.load({});\n }); \n \n}\n" + }, + "text" : "Edit", + "xtype" : "Item", + "cls" : "x-btn-text-icon", + "$ icon" : "Roo.rootURL + 'images/default/tree/leaf.gif'", + "$ xns" : "Roo.menu" + }, + { + "listeners" : { + "|click" : "function()\n{\n Pman.genericDelete(_this, 'Groups'); \n}\n " + }, + "text" : "Delete", + "xtype" : "Item", + "cls" : "x-btn-text-icon", + "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'", + "$ xns" : "Roo.menu" + }, + { + "xtype" : "Separator", + "$ xns" : "Roo.menu" }, - "background": true, - "fitContainer": true, - "fitToframe": true, - "region": "west", - "tableName": "Groups", - "title": "Groups", - "xtype": "GridPanel", - "|xns": "Roo", - "items": [ - { - "listeners": { - "|render": "function() \n{\n _this.grid = this; \n _this.dialog = Pman.Dialog.Groups;\n if (_this.panel.active) {\n _this.grid.ds.load({});\n }\n}", - "|rowdblclick": "function (_self, rowIndex, e)\n{\n if (!_this.dialog) return;\n var s = this.getDataSource().getAt(rowIndex);\n if (s.data.id < 1 ) {\n return;\n }\n _this.dialog.show( s.data, function() {\n _this.ds.load({});\n }); \n}\n" - }, - "*prop": "grid", - "autoExpandColumn": "name", - "ddGroup": "groupDD", - "enableDrop": true, - "loadMask": true, - "xtype": "Grid", - "|xns": "Roo.grid", - "items": [ - { - "listeners": { - "beforeload": "function (_self, o)\n{\n o.params = o.params || {};\n o.params.type =2;\n}", - "load": "function (_self, records, options)\n{\n var sm = _this.grid.getSelectionModel();\n if (!sm.getSelections().length) {\n sm.selectFirstRow();\n }\n Pman.Tab.AdminContacts.grid.footer.onClick('first');\n}" - }, - "*prop": "dataSource", - "remoteSort": true, - "xtype": "Store", - "|sortInfo": "{ field : 'name', direction: 'ASC' }", - "|xns": "Roo.data", - "items": [ - { - "*prop": "proxy", - "xtype": "HttpProxy", - "method": "GET", - "|url": "baseURL + '/Roo/Groups.php'", - "|xns": "Roo.data" - }, - { - "|xns": "Roo.data", - "xtype": "JsonReader", - "totalProperty": "total", - "root": "data", - "*prop": "reader", - "id": "id", - "|fields": "[\n {\n 'name': 'id',\n 'type': 'int'\n },\n {\n 'name': 'name',\n 'type': 'string'\n },\n {\n 'name': 'type',\n 'type': 'int'\n },\n {\n 'name': 'leader',\n 'type': 'int'\n },\n {\n 'name': 'leader_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_office_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_name',\n 'type': 'string'\n },\n {\n 'name': 'leader_phone',\n 'type': 'string'\n },\n {\n 'name': 'leader_fax',\n 'type': 'string'\n },\n {\n 'name': 'leader_email',\n 'type': 'string'\n },\n {\n 'name': 'leader_company_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_role',\n 'type': 'string'\n },\n {\n 'name': 'leader_active',\n 'type': 'int'\n },\n {\n 'name': 'leader_remarks',\n 'type': 'string'\n },\n {\n 'name': 'leader_passwd',\n 'type': 'string'\n },\n {\n 'name': 'leader_owner_id',\n 'type': 'int'\n },\n {\n 'name': 'leader_lang',\n 'type': 'string'\n },\n {\n 'name': 'leader_no_reset_sent',\n 'type': 'int'\n },\n {\n 'name': 'leader_action_type',\n 'type': 'string'\n },\n {\n 'name': 'leader_project_id',\n 'type': 'int'\n }\n]" - } - ] - }, - { - "*prop": "toolbar", - "xtype": "Toolbar", - "|xns": "Roo", - "items": [ - { - "text": "Manage Groups", - "xtype": "Button", - "|xns": "Roo.Toolbar", - "items": [ - { - "|xns": "Roo.menu", - "xtype": "Menu", - "*prop": "menu", - "items": [ - { - "listeners": { - "|click": "function()\n{\n if (!_this.dialog) return;\n _this.dialog.show( { id : 0, type: 2 } , function() {\n _this.grid.ds.load({});\n }); \n}\n" - }, - "cls": "x-btn-text-icon", - "text": "Add", - "xtype": "Item", - "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'", - "|xns": "Roo.menu" - }, - { - "listeners": { - "|click": "function()\n{\n var s = _this.grid.getSelectionModel().getSelections();\n if (!s.length || (s.length > 1)) {\n Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n return;\n }\n if (s[0].data.id < 1 ) {\n return;\n }\n if (!_this.dialog) return;\n _this.dialog.show(s[0].data, function() {\n _this.grid.ds.load({});\n }); \n \n}\n" - }, - "cls": "x-btn-text-icon", - "text": "Edit", - "xtype": "Item", - "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", - "|xns": "Roo.menu" - }, - { - "listeners": { - "|click": "function()\n{\n Pman.genericDelete(_this, 'Groups'); \n}\n " - }, - "cls": "x-btn-text-icon", - "text": "Delete", - "xtype": "Item", - "|icon": "rootURL + '/Pman/templates/images/trash.gif'", - "|xns": "Roo.menu" - }, - { - "|xns": "Roo.menu", - "xtype": "Separator" - }, - { - "listeners": { - "click": "function (_self, e)\n{\n _this.grid.ds.load({});\n}" - }, - "text": "Reload", - "xtype": "Item", - "|xns": "Roo.menu" - } - ] - } - ] - } - ] - }, - { - "*prop": "colModel[]", - "dataIndex": "name", - "header": "Name", - "width": 200, - "xtype": "ColumnModel", - "|renderer": "function(v,x,r) { \n if (r.data.id == -1) {\n return '' + \"Not in a Group\" + '';\n }\n if ((r.data.id == 0) && (_this.type == 0)) {\n return '' + \"All Staff (Default Permissions)\" + '';\n }\n if ((r.data.id == 0) && (_this.type == 2)) {\n return '' + \"Everybody\" + '';\n }\n if (r.data.id == 0) {\n return '' + \"All Staff\" + '';\n }\n if (v == 'Administrators') {\n return '' + \"Adminstrators\" + '';\n }\n if (r.data.leader) {\n return v + ' (' + r.data.leader_name + ')';\n }\n \n return v;\n}", - "|xns": "Roo.grid" - }, - { - "listeners": { - "afterselectionchange": "function (_self)\n{\n// Pman.Tab.AdminContacts.grid.footer.onClick('first');\n var c = Pman.Tab.AdminContactsManager.layout.getRegion('center');\n c.getActivePanel().grid.footer.onClick('first');\n \n}" - }, - "*prop": "sm", - "singleSelect": true, - "xtype": "RowSelectionModel", - "|xns": "Roo.grid" - }, - { - "listeners": { - "drop": "function (source, e, data)\n{\n // Roo.log(\"DROP\");\n var t = Roo.lib.Event.getTarget(e); \n var ri = _this.grid.view.findRowIndex(t);\n var rid = false;\n if (ri !== false) {\n rid = _this.grid.getDataSource().getAt(ri).data;\n }\n var s = _this.grid.getSelectionModel().getSelections();\n \n //console.log(data);\n var isFromGroup = s.length ? s[0].data.id > 0 : false;\n\n var isToGroup = rid && rid.id > 0;\n this.success = false;\n if (isFromGroup && isToGroup) {\n return;\n }\n if (!isFromGroup && !isToGroup) {\n return;\n }\n var action = 'add';\n if (isFromGroup && !isToGroup) {\n action = 'sub';\n //return 'x-dd-drop-ok-sub'; \n }\n // build a list of selections.\n var sels = [];\n for (var i=0; i < data.selections.length; i++) {\n sels.push(data.selections[i].data.id);\n }\n\n new Pman.Request({\n url: baseURL + '/Core/GroupMembers.php',\n params: {\n action : action,\n group_id: action =='add' ? rid.id : s[0].data.id,\n type: _this.type,\n user_ids : sels.join(',')\n \n }, \n method: 'POST', \n success : function(res) {\n \n var data = res.data\n //refreshPager();\n // \n // do we need to do anything??\n if (isFromGroup) {\n Pman.Tab.AdminContacts.grid.footer.onClick('refresh');\n }\n }, \n \n failure: function() {\n //Ext.get(document.body).unmask();\n //if (cb) {\n // cb.call(false);\n //}\n \n }\n });\n\n this.success = true;\n\n //if (!isFromGroup && isToGroup) {\n //return 'x-dd-drop-ok-add'; \n return;\n //}\n}", - "over": "function (source, e, data)\n{\n // Roo.log(\"dragover\");\n \n //Roo.log(e);\n var t = Roo.lib.Event.getTarget(e); \n // Roo.log(t);\n var ri = _this.grid.view.findRowIndex(t);\n // Roo.log(ri);\n \n var rid = false;\n if (ri !== false) {\n rid = _this.grid.getDataSource().getAt(ri).data;\n }\n \n var s = _this.grid.getSelectionModel().getSelections();\n \n var isFromGroup = s.length ? s[0].data.id > 0 : false;\n \n var isToGroup = rid && rid.id > 0;\n \n// Roo.log(\"isToGroup:\" + isToGroup + \", isFromGroup\" + isFromGroup);\n \n if (isFromGroup && isToGroup) {\n this.valid = false;\n// Roo.log('not valid');\n return;\n }\n if (!isFromGroup && !isToGroup) {\n this.valid = false;\n// Roo.log('not valid');\n return \n }\n if (isFromGroup && !isToGroup) {\n this.valid = 'ok-sub'; \n return;\n } \n //if (!isFromGroup && isToGroup) {\n this.valid = 'ok-add';\n// Roo.log('add'); \n //}\n}" - }, - "*prop": "dropTarget", - "ddGroup": "groupDD", - "xtype": "DropTarget", - "|xns": "Roo.dd" - } - ] - } - ] + { + "listeners" : { + "click" : "function (_self, e)\n{\n _this.grid.ds.load({});\n}" + }, + "text" : "Reload", + "xtype" : "Item", + "$ xns" : "Roo.menu" + } + ] + } + ] } - ], - "permname": "", - "modOrder": "001" + ] + }, + { + "xtype" : "ColumnModel", + "header" : "Name", + "width" : 200, + "$ renderer" : "function(v,x,r) { \n if (r.data.id == -1) {\n return '' + \"Not in a Group\" + '';\n }\n if ((r.data.id == 0) && (_this.type == 0)) {\n return '' + \"All Staff (Default Permissions)\" + '';\n }\n if ((r.data.id == 0) && (_this.type == 2)) {\n return '' + \"Everybody\" + '';\n }\n if (r.data.id == 0) {\n return '' + \"All Staff\" + '';\n }\n if (v == 'Administrators') {\n return '' + \"Adminstrators\" + '';\n }\n if (r.data.leader) {\n return v + ' (' + r.data.leader_name + ')';\n }\n \n return v;\n}", + "$ xns" : "Roo.grid", + "* prop" : "colModel[]", + "dataIndex" : "name" + }, + { + "listeners" : { + "afterselectionchange" : "function (_self)\n{\n// Pman.Tab.AdminContacts.grid.footer.onClick('first');\n var c = Pman.Tab.AdminContactsManager.layout.getRegion('center');\n c.getActivePanel().grid.footer.onClick('first');\n \n}" + }, + "xtype" : "RowSelectionModel", + "singleSelect" : true, + "$ xns" : "Roo.grid", + "* prop" : "sm" + }, + { + "listeners" : { + "over" : "function (source, e, data)\n{\n // Roo.log(\"dragover\");\n \n //Roo.log(e);\n var t = Roo.lib.Event.getTarget(e); \n // Roo.log(t);\n var ri = _this.grid.view.findRowIndex(t);\n // Roo.log(ri);\n \n var rid = false;\n if (ri !== false) {\n rid = _this.grid.getDataSource().getAt(ri).data;\n }\n \n var s = _this.grid.getSelectionModel().getSelections();\n \n var isFromGroup = s.length ? s[0].data.id > 0 : false;\n \n var isToGroup = rid && rid.id > 0;\n \n// Roo.log(\"isToGroup:\" + isToGroup + \", isFromGroup\" + isFromGroup);\n \n if (isFromGroup && isToGroup) {\n this.valid = false;\n// Roo.log('not valid');\n return;\n }\n if (!isFromGroup && !isToGroup) {\n this.valid = false;\n// Roo.log('not valid');\n return \n }\n if (isFromGroup && !isToGroup) {\n this.valid = 'ok-sub'; \n return;\n } \n //if (!isFromGroup && isToGroup) {\n this.valid = 'ok-add';\n// Roo.log('add'); \n //}\n}", + "drop" : "function (source, e, data)\n{\n // Roo.log(\"DROP\");\n var t = Roo.lib.Event.getTarget(e); \n var ri = _this.grid.view.findRowIndex(t);\n var rid = false;\n if (ri !== false) {\n rid = _this.grid.getDataSource().getAt(ri).data;\n }\n var s = _this.grid.getSelectionModel().getSelections();\n \n //console.log(data);\n var isFromGroup = s.length ? s[0].data.id > 0 : false;\n\n var isToGroup = rid && rid.id > 0;\n this.success = false;\n if (isFromGroup && isToGroup) {\n return;\n }\n if (!isFromGroup && !isToGroup) {\n return;\n }\n var action = 'add';\n if (isFromGroup && !isToGroup) {\n action = 'sub';\n //return 'x-dd-drop-ok-sub'; \n }\n // build a list of selections.\n var sels = [];\n for (var i=0; i < data.selections.length; i++) {\n sels.push(data.selections[i].data.id);\n }\n\n new Pman.Request({\n url: baseURL + '/Core/GroupMembers.php',\n params: {\n action : action,\n group_id: action =='add' ? rid.id : s[0].data.id,\n type: _this.type,\n user_ids : sels.join(',')\n \n }, \n method: 'POST', \n success : function(res) {\n \n var data = res.data;\n //refreshPager();\n // \n // do we need to do anything??\n if (isFromGroup) {\n Pman.Tab.AdminContacts.grid.footer.onClick('refresh');\n }\n }, \n \n failure: function() {\n //Ext.get(document.body).unmask();\n //if (cb) {\n // cb.call(false);\n //}\n \n }\n });\n\n this.success = true;\n\n //if (!isFromGroup && isToGroup) {\n //return 'x-dd-drop-ok-add'; \n return;\n //}\n}" + }, + "xtype" : "DropTarget", + "ddGroup" : "groupDD", + "$ xns" : "Roo.dd", + "* prop" : "dropTarget" + } + ] + } + ] + } + ] } \ No newline at end of file diff --git a/Pman.Tab.AdminContactsGroup.js b/Pman.Tab.AdminContactsGroup.js index fd1f497..bfe914a 100644 --- a/Pman.Tab.AdminContactsGroup.js +++ b/Pman.Tab.AdminContactsGroup.js @@ -2,430 +2,458 @@ // Auto generated file - created by app.Builder.js- do not edit directly (at present!) +Roo.namespace('Pman.Tab'); + Pman.Tab.AdminContactsGroup = new Roo.XComponent({ - part : ["Admin","ContactsGroup"], - order : '001-Pman.Tab.AdminContactsGroup', - region : 'center', - parent : 'Pman.Tab.AdminContactsManager', - name : "Pman.Tab.AdminContactsGroup", - disabled : false, - permname : '', - _tree : function() - { - var _this = this; - var MODULE = this; - return { - xtype: 'GridPanel', - xns: Roo, - listeners : { - activate : function() { - _this.panel = this; - if (_this.grid) { - _this.grid.ds.load({}); - } + + _strings : { + 'ec211f7c20af43e742bf2570c3cb84f9' :"Add", + 'a37ede293936e29279ed543129451ec3' :"Groups", + '7dce122004969d56ae2e0245cb754d35' :"Edit", + '4d1c8263ba1036754f8db14a98f9f006' :"Reload", + 'f2a6c498fb90ee345d997f888fce3b18' :"Delete", + '49ee3087348e8d44e1feda1917443987' :"Name", + 'aba9f7d7443652e858969bfc280690b1' :"Manage Groups" + }, + + part : ["Admin", "ContactsGroup" ], + order : '001-Pman.Tab.AdminContactsGroup', + region : 'center', + parent : 'Pman.Tab.AdminContactsManager', + name : "Pman.Tab.AdminContactsGroup", + disabled : false, + permname : '', + _tree : function() + { + var _this = this; + var MODULE = this; + return { + background : true, + fitContainer : true, + fitToframe : true, + region : 'west', + tableName : 'Groups', + title : _this._strings['a37ede293936e29279ed543129451ec3'] /* Groups */, + xns : Roo, + '|xns' : 'Roo', + xtype : 'GridPanel', + listeners : { + activate : function() { + _this.panel = this; + if (_this.grid) { + _this.grid.ds.load({}); + } + } + }, + grid : { + autoExpandColumn : 'name', + ddGroup : 'groupDD', + enableDrop : true, + loadMask : true, + xns : Roo.grid, + '|xns' : 'Roo.grid', + xtype : 'Grid', + listeners : { + render : function() + { + _this.grid = this; + _this.dialog = Pman.Dialog.Groups; + if (_this.panel.active) { + _this.grid.ds.load({}); + } + }, + rowdblclick : function (_self, rowIndex, e) + { + if (!_this.dialog) return; + var s = this.getDataSource().getAt(rowIndex); + if (s.data.id < 1 ) { + return; + } + _this.dialog.show( s.data, function() { + _this.ds.load({}); + }); + } + }, + toolbar : { + xns : Roo, + '|xns' : 'Roo', + xtype : 'Toolbar', + items : [ + { + text : _this._strings['aba9f7d7443652e858969bfc280690b1'] /* Manage Groups */, + xns : Roo.Toolbar, + '|xns' : 'Roo.Toolbar', + xtype : 'Button', + menu : { + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Menu', + items : [ + { + cls : 'x-btn-text-icon', + icon : Roo.rootURL + 'images/default/dd/drop-add.gif', + text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */, + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Item', + listeners : { + click : function() + { + if (!_this.dialog) return; + _this.dialog.show( { id : 0, type: 2 } , function() { + _this.grid.ds.load({}); + }); + } + } + }, + { + cls : 'x-btn-text-icon', + icon : Roo.rootURL + 'images/default/tree/leaf.gif', + text : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */, + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Item', + listeners : { + click : function() + { + var s = _this.grid.getSelectionModel().getSelections(); + if (!s.length || (s.length > 1)) { + Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row"); + return; } - }, - background : true, - fitContainer : true, - fitToframe : true, - region : 'west', - tableName : 'Groups', - title : "Groups", - grid : { - xtype: 'Grid', - xns: Roo.grid, - listeners : { - render : function() - { - _this.grid = this; - _this.dialog = Pman.Dialog.Groups; - if (_this.panel.active) { - _this.grid.ds.load({}); - } - }, - rowdblclick : function (_self, rowIndex, e) - { - if (!_this.dialog) return; - var s = this.getDataSource().getAt(rowIndex); - if (s.data.id < 1 ) { - return; - } - _this.dialog.show( s.data, function() { - _this.ds.load({}); - }); - } - }, - autoExpandColumn : 'name', - ddGroup : 'groupDD', - enableDrop : true, - loadMask : true, - dataSource : { - xtype: 'Store', - xns: Roo.data, - listeners : { - beforeload : function (_self, o) - { - o.params = o.params || {}; - o.params.type =2; - }, - load : function (_self, records, options) - { - var sm = _this.grid.getSelectionModel(); - if (!sm.getSelections().length) { - sm.selectFirstRow(); - } - Pman.Tab.AdminContacts.grid.footer.onClick('first'); - } - }, - remoteSort : true, - sortInfo : { field : 'name', direction: 'ASC' }, - proxy : { - xtype: 'HttpProxy', - xns: Roo.data, - method : 'GET', - url : baseURL + '/Roo/Groups.php' - }, - reader : { - xtype: 'JsonReader', - xns: Roo.data, - totalProperty : 'total', - root : 'data', - id : 'id', - fields : [ - { - 'name': 'id', - 'type': 'int' - }, - { - 'name': 'name', - 'type': 'string' - }, - { - 'name': 'type', - 'type': 'int' - }, - { - 'name': 'leader', - 'type': 'int' - }, - { - 'name': 'leader_id', - 'type': 'int' - }, - { - 'name': 'leader_office_id', - 'type': 'int' - }, - { - 'name': 'leader_name', - 'type': 'string' - }, - { - 'name': 'leader_phone', - 'type': 'string' - }, - { - 'name': 'leader_fax', - 'type': 'string' - }, - { - 'name': 'leader_email', - 'type': 'string' - }, - { - 'name': 'leader_company_id', - 'type': 'int' - }, - { - 'name': 'leader_role', - 'type': 'string' - }, - { - 'name': 'leader_active', - 'type': 'int' - }, - { - 'name': 'leader_remarks', - 'type': 'string' - }, - { - 'name': 'leader_passwd', - 'type': 'string' - }, - { - 'name': 'leader_owner_id', - 'type': 'int' - }, - { - 'name': 'leader_lang', - 'type': 'string' - }, - { - 'name': 'leader_no_reset_sent', - 'type': 'int' - }, - { - 'name': 'leader_action_type', - 'type': 'string' - }, - { - 'name': 'leader_project_id', - 'type': 'int' - } - ] - } - }, - toolbar : { - xtype: 'Toolbar', - xns: Roo, - items : [ - { - xtype: 'Button', - xns: Roo.Toolbar, - text : "Manage Groups", - menu : { - xtype: 'Menu', - xns: Roo.menu, - items : [ - { - xtype: 'Item', - xns: Roo.menu, - listeners : { - click : function() - { - if (!_this.dialog) return; - _this.dialog.show( { id : 0, type: 2 } , function() { - _this.grid.ds.load({}); - }); - } - }, - cls : 'x-btn-text-icon', - text : "Add", - icon : Roo.rootURL + 'images/default/dd/drop-add.gif' - }, - { - xtype: 'Item', - xns: Roo.menu, - listeners : { - click : function() - { - var s = _this.grid.getSelectionModel().getSelections(); - if (!s.length || (s.length > 1)) { - Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row"); - return; - } - if (s[0].data.id < 1 ) { - return; - } - if (!_this.dialog) return; - _this.dialog.show(s[0].data, function() { - _this.grid.ds.load({}); - }); - - } - }, - cls : 'x-btn-text-icon', - text : "Edit", - icon : Roo.rootURL + 'images/default/tree/leaf.gif' - }, - { - xtype: 'Item', - xns: Roo.menu, - listeners : { - click : function() - { - Pman.genericDelete(_this, 'Groups'); - } - }, - cls : 'x-btn-text-icon', - text : "Delete", - icon : rootURL + '/Pman/templates/images/trash.gif' - }, - { - xtype: 'Separator', - xns: Roo.menu - }, - { - xtype: 'Item', - xns: Roo.menu, - listeners : { - click : function (_self, e) - { - _this.grid.ds.load({}); - } - }, - text : "Reload" - } - ] - } - } - ] - }, - colModel : [ - { - xtype: 'ColumnModel', - xns: Roo.grid, - dataIndex : 'name', - header : 'Name', - width : 200, - renderer : function(v,x,r) { - if (r.data.id == -1) { - return '' + "Not in a Group" + ''; - } - if ((r.data.id == 0) && (_this.type == 0)) { - return '' + "All Staff (Default Permissions)" + ''; - } - if ((r.data.id == 0) && (_this.type == 2)) { - return '' + "Everybody" + ''; - } - if (r.data.id == 0) { - return '' + "All Staff" + ''; - } - if (v == 'Administrators') { - return '' + "Adminstrators" + ''; - } - if (r.data.leader) { - return v + ' (' + r.data.leader_name + ')'; - } - - return v; - } - } - ], - sm : { - xtype: 'RowSelectionModel', - xns: Roo.grid, - listeners : { - afterselectionchange : function (_self) - { - // Pman.Tab.AdminContacts.grid.footer.onClick('first'); - var c = Pman.Tab.AdminContactsManager.layout.getRegion('center'); - c.getActivePanel().grid.footer.onClick('first'); - - } - }, - singleSelect : true - }, - dropTarget : { - xtype: 'DropTarget', - xns: Roo.dd, - listeners : { - drop : function (source, e, data) - { - // Roo.log("DROP"); - var t = Roo.lib.Event.getTarget(e); - var ri = _this.grid.view.findRowIndex(t); - var rid = false; - if (ri !== false) { - rid = _this.grid.getDataSource().getAt(ri).data; - } - var s = _this.grid.getSelectionModel().getSelections(); - - //console.log(data); - var isFromGroup = s.length ? s[0].data.id > 0 : false; - - var isToGroup = rid && rid.id > 0; - this.success = false; - if (isFromGroup && isToGroup) { - return; - } - if (!isFromGroup && !isToGroup) { - return; - } - var action = 'add'; - if (isFromGroup && !isToGroup) { - action = 'sub'; - //return 'x-dd-drop-ok-sub'; - } - // build a list of selections. - var sels = []; - for (var i=0; i < data.selections.length; i++) { - sels.push(data.selections[i].data.id); - } - - new Pman.Request({ - url: baseURL + '/Core/GroupMembers.php', - params: { - action : action, - group_id: action =='add' ? rid.id : s[0].data.id, - type: _this.type, - user_ids : sels.join(',') - - }, - method: 'POST', - success : function(res) { - - var data = res.data - //refreshPager(); - // - // do we need to do anything?? - if (isFromGroup) { - Pman.Tab.AdminContacts.grid.footer.onClick('refresh'); - } - }, - - failure: function() { - //Ext.get(document.body).unmask(); - //if (cb) { - // cb.call(false); - //} - - } - }); - - this.success = true; - - //if (!isFromGroup && isToGroup) { - //return 'x-dd-drop-ok-add'; - return; - //} - }, - over : function (source, e, data) - { - // Roo.log("dragover"); - - //Roo.log(e); - var t = Roo.lib.Event.getTarget(e); - // Roo.log(t); - var ri = _this.grid.view.findRowIndex(t); - // Roo.log(ri); - - var rid = false; - if (ri !== false) { - rid = _this.grid.getDataSource().getAt(ri).data; - } - - var s = _this.grid.getSelectionModel().getSelections(); - - var isFromGroup = s.length ? s[0].data.id > 0 : false; - - var isToGroup = rid && rid.id > 0; - - // Roo.log("isToGroup:" + isToGroup + ", isFromGroup" + isFromGroup); - - if (isFromGroup && isToGroup) { - this.valid = false; - // Roo.log('not valid'); - return; - } - if (!isFromGroup && !isToGroup) { - this.valid = false; - // Roo.log('not valid'); - return - } - if (isFromGroup && !isToGroup) { - this.valid = 'ok-sub'; - return; - } - //if (!isFromGroup && isToGroup) { - this.valid = 'ok-add'; - // Roo.log('add'); - //} - } - }, - ddGroup : 'groupDD' + if (s[0].data.id < 1 ) { + return; } + if (!_this.dialog) return; + _this.dialog.show(s[0].data, function() { + _this.grid.ds.load({}); + }); + + } + } + }, + { + cls : 'x-btn-text-icon', + icon : rootURL + '/Pman/templates/images/trash.gif', + text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */, + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Item', + listeners : { + click : function() + { + Pman.genericDelete(_this, 'Groups'); + } + } + }, + { + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Separator' + }, + { + text : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */, + xns : Roo.menu, + '|xns' : 'Roo.menu', + xtype : 'Item', + listeners : { + click : function (_self, e) + { + _this.grid.ds.load({}); } - }; - } + } + } + ] + } + } + ] + }, + dataSource : { + remoteSort : true, + sortInfo : { field : 'name', direction: 'ASC' }, + xns : Roo.data, + '|xns' : 'Roo.data', + xtype : 'Store', + listeners : { + beforeload : function (_self, o) + { + o.params = o.params || {}; + o.params.type =2; + }, + load : function (_self, records, options) + { + var sm = _this.grid.getSelectionModel(); + if (!sm.getSelections().length) { + sm.selectFirstRow(); + } + Pman.Tab.AdminContacts.grid.footer.onClick('first'); + } + }, + proxy : { + method : 'GET', + url : baseURL + '/Roo/Groups.php', + xns : Roo.data, + '|xns' : 'Roo.data', + xtype : 'HttpProxy' + }, + reader : { + fields : [ + { + 'name': 'id', + 'type': 'int' + }, + { + 'name': 'name', + 'type': 'string' + }, + { + 'name': 'type', + 'type': 'int' + }, + { + 'name': 'leader', + 'type': 'int' + }, + { + 'name': 'leader_id', + 'type': 'int' + }, + { + 'name': 'leader_office_id', + 'type': 'int' + }, + { + 'name': 'leader_name', + 'type': 'string' + }, + { + 'name': 'leader_phone', + 'type': 'string' + }, + { + 'name': 'leader_fax', + 'type': 'string' + }, + { + 'name': 'leader_email', + 'type': 'string' + }, + { + 'name': 'leader_company_id', + 'type': 'int' + }, + { + 'name': 'leader_role', + 'type': 'string' + }, + { + 'name': 'leader_active', + 'type': 'int' + }, + { + 'name': 'leader_remarks', + 'type': 'string' + }, + { + 'name': 'leader_passwd', + 'type': 'string' + }, + { + 'name': 'leader_owner_id', + 'type': 'int' + }, + { + 'name': 'leader_lang', + 'type': 'string' + }, + { + 'name': 'leader_no_reset_sent', + 'type': 'int' + }, + { + 'name': 'leader_action_type', + 'type': 'string' + }, + { + 'name': 'leader_project_id', + 'type': 'int' + } + ], + id : 'id', + root : 'data', + totalProperty : 'total', + xns : Roo.data, + '|xns' : 'Roo.data', + xtype : 'JsonReader' + } + }, + dropTarget : { + ddGroup : 'groupDD', + xns : Roo.dd, + '|xns' : 'Roo.dd', + xtype : 'DropTarget', + listeners : { + drop : function (source, e, data) + { + // Roo.log("DROP"); + var t = Roo.lib.Event.getTarget(e); + var ri = _this.grid.view.findRowIndex(t); + var rid = false; + if (ri !== false) { + rid = _this.grid.getDataSource().getAt(ri).data; + } + var s = _this.grid.getSelectionModel().getSelections(); + + //console.log(data); + var isFromGroup = s.length ? s[0].data.id > 0 : false; + + var isToGroup = rid && rid.id > 0; + this.success = false; + if (isFromGroup && isToGroup) { + return; + } + if (!isFromGroup && !isToGroup) { + return; + } + var action = 'add'; + if (isFromGroup && !isToGroup) { + action = 'sub'; + //return 'x-dd-drop-ok-sub'; + } + // build a list of selections. + var sels = []; + for (var i=0; i < data.selections.length; i++) { + sels.push(data.selections[i].data.id); + } + + new Pman.Request({ + url: baseURL + '/Core/GroupMembers.php', + params: { + action : action, + group_id: action =='add' ? rid.id : s[0].data.id, + type: _this.type, + user_ids : sels.join(',') + + }, + method: 'POST', + success : function(res) { + + var data = res.data; + //refreshPager(); + // + // do we need to do anything?? + if (isFromGroup) { + Pman.Tab.AdminContacts.grid.footer.onClick('refresh'); + } + }, + + failure: function() { + //Ext.get(document.body).unmask(); + //if (cb) { + // cb.call(false); + //} + + } + }); + + this.success = true; + + //if (!isFromGroup && isToGroup) { + //return 'x-dd-drop-ok-add'; + return; + //} + }, + over : function (source, e, data) + { + // Roo.log("dragover"); + + //Roo.log(e); + var t = Roo.lib.Event.getTarget(e); + // Roo.log(t); + var ri = _this.grid.view.findRowIndex(t); + // Roo.log(ri); + + var rid = false; + if (ri !== false) { + rid = _this.grid.getDataSource().getAt(ri).data; + } + + var s = _this.grid.getSelectionModel().getSelections(); + + var isFromGroup = s.length ? s[0].data.id > 0 : false; + + var isToGroup = rid && rid.id > 0; + + // Roo.log("isToGroup:" + isToGroup + ", isFromGroup" + isFromGroup); + + if (isFromGroup && isToGroup) { + this.valid = false; + // Roo.log('not valid'); + return; + } + if (!isFromGroup && !isToGroup) { + this.valid = false; + // Roo.log('not valid'); + return + } + if (isFromGroup && !isToGroup) { + this.valid = 'ok-sub'; + return; + } + //if (!isFromGroup && isToGroup) { + this.valid = 'ok-add'; + // Roo.log('add'); + //} + } + } + }, + sm : { + singleSelect : true, + xns : Roo.grid, + '|xns' : 'Roo.grid', + xtype : 'RowSelectionModel', + listeners : { + afterselectionchange : function (_self) + { + // Pman.Tab.AdminContacts.grid.footer.onClick('first'); + var c = Pman.Tab.AdminContactsManager.layout.getRegion('center'); + c.getActivePanel().grid.footer.onClick('first'); + + } + } + }, + colModel : [ + { + dataIndex : 'name', + header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */, + renderer : function(v,x,r) { + if (r.data.id == -1) { + return '' + "Not in a Group" + ''; + } + if ((r.data.id == 0) && (_this.type == 0)) { + return '' + "All Staff (Default Permissions)" + ''; + } + if ((r.data.id == 0) && (_this.type == 2)) { + return '' + "Everybody" + ''; + } + if (r.data.id == 0) { + return '' + "All Staff" + ''; + } + if (v == 'Administrators') { + return '' + "Adminstrators" + ''; + } + if (r.data.leader) { + return v + ' (' + r.data.leader_name + ')'; + } + + return v; + }, + width : 200, + xns : Roo.grid, + '|xns' : 'Roo.grid', + xtype : 'ColumnModel' + } + ] + } + }; } }); -- 2.39.2