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})
159 Roo.log(['Groups', parentLayout, this.panel]);
164 new Ext.dd.DropTarget(_this.grid.getView().mainBody, {
168 notifyOver : function(dd, e, data){
169 var t = Roo.lib.Event.getTarget(e);
170 var ri = _this.grid.view.findRowIndex(t);
173 rid = _this.grid.getDataSource().getAt(ri).data;
176 var s = _this.grid.getSelectionModel().getSelections();
178 var isFromGroup = s.length ? s[0].data.id > 0 : false;
180 var isToGroup = rid && rid.id > 0;
182 if (isFromGroup && isToGroup) {
183 return this.dropNotAllowed;
185 if (!isFromGroup && !isToGroup) {
186 return this.dropNotAllowed;
188 if (isFromGroup && !isToGroup) {
189 return 'x-dd-drop-ok-sub';
191 //if (!isFromGroup && isToGroup) {
192 return 'x-dd-drop-ok-add';
197 notifyDrop : function(dd, e, data){
199 var t = Roo.lib.Event.getTarget(e);
200 var ri = _this.grid.view.findRowIndex(t);
203 rid = _this.grid.getDataSource().getAt(ri).data;
205 var s = _this.grid.getSelectionModel().getSelections();
208 var isFromGroup = s.length ? s[0].data.id > 0 : false;
210 var isToGroup = rid && rid.id > 0;
212 if (isFromGroup && isToGroup) {
215 if (!isFromGroup && !isToGroup) {
219 if (isFromGroup && !isToGroup) {
221 //return 'x-dd-drop-ok-sub';
223 // build a list of selections.
225 for (var i=0; i < data.selections.length; i++) {
226 sels.push(data.selections[i].data.id);
230 url: baseURL + '/Core/GroupMembers.php',
233 group_id: action =='add' ? rid.id : s[0].data.id,
235 user_ids : sels.join(',')
239 success : function(data) {
243 failure: function() {
244 //Ext.get(document.body).unmask();
254 //if (!isFromGroup && isToGroup) {
255 //return 'x-dd-drop-ok-add';
264 var gridFoot = this.grid.getView().getFooterPanel(true);
266 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
273 var grid = this.grid;
275 var gridHead = this.grid.getView().getHeaderPanel(true);
276 this.toolbar = new Ext.Toolbar(gridHead);
279 var _dialog= this.getDialog();
282 text: "Manage Groups",
283 cls: 'x-btn-text-icon',
284 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
290 cls: 'x-btn-text-icon',
291 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
292 hidden : !Pman.hasPerm('Core.Groups', 'A'),
293 handler : function(){
294 _dialog.show( { id : 0, type: _this.type }, refreshPager );
299 cls: 'x-btn-text-icon',
300 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
301 hidden : !Pman.hasPerm('Core.Groups', 'E'),
302 handler : function() {
303 var s = grid.getSelectionModel().getSelections();
304 if (!s.length || (s.length > 1)) {
305 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
308 if ((s[0].data.name == 'Administrators') ||(s[0].data.name == 'Default')) {
309 Ext.MessageBox.alert("Error", "You can not rename that group");
312 if (s[0].data.id < 1) {
313 Ext.MessageBox.alert("Error", "You can not rename that group");
316 _dialog.show(s[0].data, refreshPager);
322 cls: 'x-btn-text-icon',
323 icon: rootURL + '/Pman/templates/images/trash.gif',
324 hidden : !Pman.hasPerm('Core.Groups', 'D'),
325 handler : function(){
326 var s = grid.getSelectionModel().getSelections();
328 for(var i = 0; i < s.length; i++) {
330 if ((s[i].data.id < 1) || (s[i].data.name == 'Administrators')) {
331 Ext.MessageBox.alert("Error", "You can not delete that group");
337 Pman.genericDelete(_this, 'Groups');
342 cls: 'x-btn-text-icon',
343 icon: rootURL + '/Pman/templates/images/view-refresh.gif',
344 handler : function(){
352 this.panel.on('activate', function() {
357 // add stuff to toolbar?
358 //this.innerLayout.endUpdate();
365 this.grid.getDataSource().reload();
367 // - is this used anymore?
369 show: function (parentLayout, region)
371 this.add(parentLayout, region);
372 this.grid.getDataSource().load({