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) {
21 Roo.log('run!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1');
22 Roo.log(parentLayout);
27 var refreshPager = function() {
32 parentLayout.getRegion(region).showPanel(this.panel);
36 var refreshCenterPanel = function()
38 var actpan = parentLayout.getRegion('center').getActivePanel();
39 if (actpan && actpan.controller) {
40 actpan.controller.refresh();
48 Pman.Tab[agid].refresh();
51 var frm = parentLayout.getRegion(region).getEl().createChild({tag:'div'});
52 //this.grid = new Ext.grid.EditorGrid(frm, {
53 this.grid = new Ext.grid.Grid(frm, {
54 id: _this.id + '-groups',
56 //enableDragDrop:true,
64 ds: new Ext.data.Store({
68 proxy: new Ext.data.HttpProxy({
69 url: baseURL + '/Roo/Groups.html',
73 reader: Pman.Readers.Groups,
75 field: 'name', direction: 'ASC'
79 beforeload: function(t, o) {
80 //console.log(o.params);
84 o.params.type = _this.type;
90 var sm = _this.grid.getSelectionModel();
91 if (!sm.getSelections().length) {
95 // Pman.Tab.Documents_In.delayedCreate();
96 // Pman.Tab.Documents_Out.delayedCreate();
98 loadexception : Pman.loadException
102 sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
103 cm: new Ext.grid.ColumnModel(
105 id : _this.id + '-name',
110 renderer : function(v,x,r) {
111 if (r.data.id == -1) {
112 return '<b>' + "Not in a Group" + '</b>';
114 if ((r.data.id == 0) && (_this.type == 0)) {
115 return '<b>' + "All Staff (Default Permissions)" + '</b>';
117 if ((r.data.id == 0) && (_this.type == 2)) {
118 return '<b>' + "Everybody" + '</b>';
120 if (r.data.id == 0) {
121 return '<b>' + "All Staff" + '</b>';
123 if (v == 'Administrators') {
124 return '<b>' + "Adminstrators" + '</b>';
127 return v + ' (' + r.data.leader_name + ')';
134 return '<b>' + "All Staff (Default Perms.)" + '</b>';
135 case 'Administrators':
136 return '<b>' + "Administrators" + '</b>';
145 autoExpandColumn: _this.id + '-name' , // fixme!!!!
150 rowclick: function(g, ri, e)
152 refreshCenterPanel();
157 // add selection changed...
159 this.panel = parentLayout.add(region, new Ext.GridPanel(this.grid ,
160 { fitToframe: true,fitContainer: true, title: _this.title, id : _this.id, background: true})
165 new Ext.dd.DropTarget(_this.grid.getView().mainBody, {
169 notifyOver : function(dd, e, data){
170 var t = Roo.lib.Event.getTarget(e);
171 var ri = _this.grid.view.findRowIndex(t);
174 rid = _this.grid.getDataSource().getAt(ri).data;
177 var s = _this.grid.getSelectionModel().getSelections();
179 var isFromGroup = s.length ? s[0].data.id > 0 : false;
181 var isToGroup = rid && rid.id > 0;
183 if (isFromGroup && isToGroup) {
184 return this.dropNotAllowed;
186 if (!isFromGroup && !isToGroup) {
187 return this.dropNotAllowed;
189 if (isFromGroup && !isToGroup) {
190 return 'x-dd-drop-ok-sub';
192 //if (!isFromGroup && isToGroup) {
193 return 'x-dd-drop-ok-add';
198 notifyDrop : function(dd, e, data){
200 var t = Roo.lib.Event.getTarget(e);
201 var ri = _this.grid.view.findRowIndex(t);
204 rid = _this.grid.getDataSource().getAt(ri).data;
206 var s = _this.grid.getSelectionModel().getSelections();
209 var isFromGroup = s.length ? s[0].data.id > 0 : false;
211 var isToGroup = rid && rid.id > 0;
213 if (isFromGroup && isToGroup) {
216 if (!isFromGroup && !isToGroup) {
220 if (isFromGroup && !isToGroup) {
222 //return 'x-dd-drop-ok-sub';
224 // build a list of selections.
226 for (var i=0; i < data.selections.length; i++) {
227 sels.push(data.selections[i].data.id);
231 url: baseURL + '/Core/GroupMembers.php',
234 group_id: action =='add' ? rid.id : s[0].data.id,
236 user_ids : sels.join(',')
240 success : function(data) {
244 failure: function() {
245 //Ext.get(document.body).unmask();
255 //if (!isFromGroup && isToGroup) {
256 //return 'x-dd-drop-ok-add';
265 var gridFoot = this.grid.getView().getFooterPanel(true);
267 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
274 var grid = this.grid;
276 var gridHead = this.grid.getView().getHeaderPanel(true);
277 this.toolbar = new Ext.Toolbar(gridHead);
280 var _dialog= this.getDialog();
283 text: "Manage Groups",
284 cls: 'x-btn-text-icon',
285 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
291 cls: 'x-btn-text-icon',
292 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
293 hidden : !Pman.hasPerm('Core.Groups', 'A'),
294 handler : function(){
295 _dialog.show( { id : 0, type: _this.type }, refreshPager );
300 cls: 'x-btn-text-icon',
301 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
302 hidden : !Pman.hasPerm('Core.Groups', 'E'),
303 handler : function() {
304 var s = grid.getSelectionModel().getSelections();
305 if (!s.length || (s.length > 1)) {
306 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
309 if ((s[0].data.name == 'Administrators') ||(s[0].data.name == 'Default')) {
310 Ext.MessageBox.alert("Error", "You can not rename that group");
313 if (s[0].data.id < 1) {
314 Ext.MessageBox.alert("Error", "You can not rename that group");
317 _dialog.show(s[0].data, refreshPager);
323 cls: 'x-btn-text-icon',
324 icon: rootURL + '/Pman/templates/images/trash.gif',
325 hidden : !Pman.hasPerm('Core.Groups', 'D'),
326 handler : function(){
327 var s = grid.getSelectionModel().getSelections();
329 for(var i = 0; i < s.length; i++) {
331 if ((s[i].data.id < 1) || (s[i].data.name == 'Administrators')) {
332 Ext.MessageBox.alert("Error", "You can not delete that group");
338 Pman.genericDelete(_this, 'Groups');
343 cls: 'x-btn-text-icon',
344 icon: rootURL + '/Pman/templates/images/view-refresh.gif',
345 handler : function(){
353 this.panel.on('activate', function() {
358 // add stuff to toolbar?
359 //this.innerLayout.endUpdate();
366 this.grid.getDataSource().reload();
368 // - is this used anymore?
370 show: function (parentLayout, region)
372 this.add(parentLayout, region);
373 this.grid.getDataSource().load({