2 //<script type="text/javascript">
4 // generic groups listing tab
7 Pman.Tab.GroupsList = function(config) {
8 Ext.apply(this, config);
11 Pman.Tab.GroupsList.prototype = {
19 add : function(parentLayout, region) {
23 var refreshPager = function() {
28 parentLayout.getRegion(region).showPanel(this.panel);
32 var refreshCenterPanel = function()
34 var actpan = parentLayout.getRegion('center').getActivePanel();
35 if (actpan && actpan.controller) {
36 actpan.controller.refresh();
44 Pman.Tab[agid].refresh();
47 var frm = parentLayout.getRegion(region).getEl().createChild({tag:'div'});
48 //this.grid = new Ext.grid.EditorGrid(frm, {
49 this.grid = new Ext.grid.Grid(frm, {
50 id: _this.id + '-groups',
52 //enableDragDrop:true,
60 ds: new Ext.data.Store({
64 proxy: new Ext.data.HttpProxy({
65 url: baseURL + '/Roo/Groups.html',
69 reader: Pman.Readers.Groups,
71 field: 'name', direction: 'ASC'
75 beforeload: function(t, o) {
76 //console.log(o.params);
80 o.params.type = _this.type;
86 var sm = _this.grid.getSelectionModel();
87 if (!sm.getSelections().length) {
91 // Pman.Tab.Documents_In.delayedCreate();
92 // Pman.Tab.Documents_Out.delayedCreate();
94 loadexception : Pman.loadException
98 sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
99 cm: new Ext.grid.ColumnModel(
101 id : _this.id + '-name',
106 renderer : function(v,x,r) {
107 if (r.data.id == -1) {
108 return '<b>' + "Not in a Group" + '</b>';
110 if ((r.data.id == 0) && (_this.type == 0)) {
111 return '<b>' + "All Staff (Default Permissions)" + '</b>';
113 if ((r.data.id == 0) && (_this.type == 2)) {
114 return '<b>' + "Everybody" + '</b>';
116 if (r.data.id == 0) {
117 return '<b>' + "All Staff" + '</b>';
119 if (v == 'Administrators') {
120 return '<b>' + "Adminstrators" + '</b>';
123 return v + ' (' + r.data.leader_name + ')';
130 return '<b>' + "All Staff (Default Perms.)" + '</b>';
131 case 'Administrators':
132 return '<b>' + "Administrators" + '</b>';
141 autoExpandColumn: _this.id + '-name' , // fixme!!!!
146 rowclick: function(g, ri, e)
148 refreshCenterPanel();
153 // add selection changed...
155 this.panel = parentLayout.add(region, new Ext.GridPanel(this.grid ,
156 { fitToframe: true,fitContainer: true, title: _this.title, id : _this.id, background: true})
158 Roo.log('test!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!');
163 new Ext.dd.DropTarget(_this.grid.getView().mainBody, {
167 notifyOver : function(dd, e, data){
168 var t = Roo.lib.Event.getTarget(e);
169 var ri = _this.grid.view.findRowIndex(t);
172 rid = _this.grid.getDataSource().getAt(ri).data;
175 var s = _this.grid.getSelectionModel().getSelections();
177 var isFromGroup = s.length ? s[0].data.id > 0 : false;
179 var isToGroup = rid && rid.id > 0;
181 if (isFromGroup && isToGroup) {
182 return this.dropNotAllowed;
184 if (!isFromGroup && !isToGroup) {
185 return this.dropNotAllowed;
187 if (isFromGroup && !isToGroup) {
188 return 'x-dd-drop-ok-sub';
190 //if (!isFromGroup && isToGroup) {
191 return 'x-dd-drop-ok-add';
196 notifyDrop : function(dd, e, data){
198 var t = Roo.lib.Event.getTarget(e);
199 var ri = _this.grid.view.findRowIndex(t);
202 rid = _this.grid.getDataSource().getAt(ri).data;
204 var s = _this.grid.getSelectionModel().getSelections();
207 var isFromGroup = s.length ? s[0].data.id > 0 : false;
209 var isToGroup = rid && rid.id > 0;
211 if (isFromGroup && isToGroup) {
214 if (!isFromGroup && !isToGroup) {
218 if (isFromGroup && !isToGroup) {
220 //return 'x-dd-drop-ok-sub';
222 // build a list of selections.
224 for (var i=0; i < data.selections.length; i++) {
225 sels.push(data.selections[i].data.id);
229 url: baseURL + '/Core/GroupMembers.php',
232 group_id: action =='add' ? rid.id : s[0].data.id,
234 user_ids : sels.join(',')
238 success : function(data) {
242 failure: function() {
243 //Ext.get(document.body).unmask();
253 //if (!isFromGroup && isToGroup) {
254 //return 'x-dd-drop-ok-add';
263 var gridFoot = this.grid.getView().getFooterPanel(true);
265 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
272 var grid = this.grid;
274 var gridHead = this.grid.getView().getHeaderPanel(true);
275 this.toolbar = new Ext.Toolbar(gridHead);
278 var _dialog= this.getDialog();
281 text: "Manage Groups",
282 cls: 'x-btn-text-icon',
283 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
289 cls: 'x-btn-text-icon',
290 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
291 hidden : !Pman.hasPerm('Core.Groups', 'A'),
292 handler : function(){
293 _dialog.show( { id : 0, type: _this.type }, refreshPager );
298 cls: 'x-btn-text-icon',
299 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
300 hidden : !Pman.hasPerm('Core.Groups', 'E'),
301 handler : function() {
302 var s = grid.getSelectionModel().getSelections();
303 if (!s.length || (s.length > 1)) {
304 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
307 if ((s[0].data.name == 'Administrators') ||(s[0].data.name == 'Default')) {
308 Ext.MessageBox.alert("Error", "You can not rename that group");
311 if (s[0].data.id < 1) {
312 Ext.MessageBox.alert("Error", "You can not rename that group");
315 _dialog.show(s[0].data, refreshPager);
321 cls: 'x-btn-text-icon',
322 icon: rootURL + '/Pman/templates/images/trash.gif',
323 hidden : !Pman.hasPerm('Core.Groups', 'D'),
324 handler : function(){
325 var s = grid.getSelectionModel().getSelections();
327 for(var i = 0; i < s.length; i++) {
329 if ((s[i].data.id < 1) || (s[i].data.name == 'Administrators')) {
330 Ext.MessageBox.alert("Error", "You can not delete that group");
336 Pman.genericDelete(_this, 'Groups');
341 cls: 'x-btn-text-icon',
342 icon: rootURL + '/Pman/templates/images/view-refresh.gif',
343 handler : function(){
351 this.panel.on('activate', function() {
356 // add stuff to toolbar?
357 //this.innerLayout.endUpdate();
364 this.grid.getDataSource().reload();
366 // - is this used anymore?
368 show: function (parentLayout, region)
370 this.add(parentLayout, region);
371 this.grid.getDataSource().load({