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})
161 new Ext.dd.DropTarget(_this.grid.getView().mainBody, {
165 notifyOver : function(dd, e, data){
166 var t = Roo.lib.Event.getTarget(e);
167 var ri = _this.grid.view.findRowIndex(t);
170 rid = _this.grid.getDataSource().getAt(ri).data;
173 var s = _this.grid.getSelectionModel().getSelections();
175 var isFromGroup = s.length ? s[0].data.id > 0 : false;
177 var isToGroup = rid && rid.id > 0;
179 if (isFromGroup && isToGroup) {
180 return this.dropNotAllowed;
182 if (!isFromGroup && !isToGroup) {
183 return this.dropNotAllowed;
185 if (isFromGroup && !isToGroup) {
186 return 'x-dd-drop-ok-sub';
188 //if (!isFromGroup && isToGroup) {
189 return 'x-dd-drop-ok-add';
194 notifyDrop : function(dd, e, data){
196 var t = Roo.lib.Event.getTarget(e);
197 var ri = _this.grid.view.findRowIndex(t);
200 rid = _this.grid.getDataSource().getAt(ri).data;
202 var s = _this.grid.getSelectionModel().getSelections();
205 var isFromGroup = s.length ? s[0].data.id > 0 : false;
207 var isToGroup = rid && rid.id > 0;
209 if (isFromGroup && isToGroup) {
212 if (!isFromGroup && !isToGroup) {
216 if (isFromGroup && !isToGroup) {
218 //return 'x-dd-drop-ok-sub';
220 // build a list of selections.
222 for (var i=0; i < data.selections.length; i++) {
223 sels.push(data.selections[i].data.id);
227 url: baseURL + '/Core/GroupMembers.php',
230 group_id: action =='add' ? rid.id : s[0].data.id,
232 user_ids : sels.join(',')
236 success : function(data) {
240 failure: function() {
241 //Ext.get(document.body).unmask();
251 //if (!isFromGroup && isToGroup) {
252 //return 'x-dd-drop-ok-add';
261 var gridFoot = this.grid.getView().getFooterPanel(true);
263 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
270 var grid = this.grid;
272 var gridHead = this.grid.getView().getHeaderPanel(true);
273 this.toolbar = new Ext.Toolbar(gridHead);
276 var _dialog= this.getDialog();
279 text: "Manage Groups",
280 cls: 'x-btn-text-icon',
281 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
287 cls: 'x-btn-text-icon',
288 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
289 hidden : !Pman.hasPerm('Core.Groups', 'A'),
290 handler : function(){
291 _dialog.show( { id : 0, type: _this.type }, refreshPager );
296 cls: 'x-btn-text-icon',
297 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
298 hidden : !Pman.hasPerm('Core.Groups', 'E'),
299 handler : function() {
300 var s = grid.getSelectionModel().getSelections();
301 if (!s.length || (s.length > 1)) {
302 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
305 if ((s[0].data.name == 'Administrators') ||(s[0].data.name == 'Default')) {
306 Ext.MessageBox.alert("Error", "You can not rename that group");
309 if (s[0].data.id < 1) {
310 Ext.MessageBox.alert("Error", "You can not rename that group");
313 _dialog.show(s[0].data, refreshPager);
319 cls: 'x-btn-text-icon',
320 icon: rootURL + '/Pman/templates/images/trash.gif',
321 hidden : !Pman.hasPerm('Core.Groups', 'D'),
322 handler : function(){
323 var s = grid.getSelectionModel().getSelections();
325 for(var i = 0; i < s.length; i++) {
327 if ((s[i].data.id < 1) || (s[i].data.name == 'Administrators')) {
328 Ext.MessageBox.alert("Error", "You can not delete that group");
334 Pman.genericDelete(_this, 'Groups');
339 cls: 'x-btn-text-icon',
340 icon: rootURL + '/Pman/templates/images/view-refresh.gif',
341 handler : function(){
349 this.panel.on('activate', function() {
354 // add stuff to toolbar?
355 //this.innerLayout.endUpdate();
362 this.grid.getDataSource().reload();
364 // - is this used anymore?
366 show: function (parentLayout, region)
368 this.add(parentLayout, region);
369 this.grid.getDataSource().load({