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 add?????????????????????????????????????????????????');
24 var refreshPager = function() {
29 parentLayout.getRegion(region).showPanel(this.panel);
33 var refreshCenterPanel = function()
35 var actpan = parentLayout.getRegion('center').getActivePanel();
36 if (actpan && actpan.controller) {
37 actpan.controller.refresh();
45 Pman.Tab[agid].refresh();
48 var frm = parentLayout.getRegion(region).getEl().createChild({tag:'div'});
49 //this.grid = new Ext.grid.EditorGrid(frm, {
50 this.grid = new Ext.grid.Grid(frm, {
51 id: _this.id + '-groups',
53 //enableDragDrop:true,
61 ds: new Ext.data.Store({
65 proxy: new Ext.data.HttpProxy({
66 url: baseURL + '/Roo/Groups.html',
70 reader: Pman.Readers.Groups,
72 field: 'name', direction: 'ASC'
76 beforeload: function(t, o) {
77 //console.log(o.params);
81 o.params.type = _this.type;
87 var sm = _this.grid.getSelectionModel();
88 if (!sm.getSelections().length) {
92 // Pman.Tab.Documents_In.delayedCreate();
93 // Pman.Tab.Documents_Out.delayedCreate();
95 loadexception : Pman.loadException
99 sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
100 cm: new Ext.grid.ColumnModel(
102 id : _this.id + '-name',
107 renderer : function(v,x,r) {
108 if (r.data.id == -1) {
109 return '<b>' + "Not in a Group" + '</b>';
111 if ((r.data.id == 0) && (_this.type == 0)) {
112 return '<b>' + "All Staff (Default Permissions)" + '</b>';
114 if ((r.data.id == 0) && (_this.type == 2)) {
115 return '<b>' + "Everybody" + '</b>';
117 if (r.data.id == 0) {
118 return '<b>' + "All Staff" + '</b>';
120 if (v == 'Administrators') {
121 return '<b>' + "Adminstrators" + '</b>';
124 return v + ' (' + r.data.leader_name + ')';
131 return '<b>' + "All Staff (Default Perms.)" + '</b>';
132 case 'Administrators':
133 return '<b>' + "Administrators" + '</b>';
142 autoExpandColumn: _this.id + '-name' , // fixme!!!!
147 rowclick: function(g, ri, e)
149 refreshCenterPanel();
154 // add selection changed...
156 this.panel = parentLayout.add(region, new Ext.GridPanel(this.grid ,
157 { fitToframe: true,fitContainer: true, title: _this.title, id : _this.id, background: true})
162 new Ext.dd.DropTarget(_this.grid.getView().mainBody, {
166 notifyOver : function(dd, e, data){
167 var t = Roo.lib.Event.getTarget(e);
168 var ri = _this.grid.view.findRowIndex(t);
171 rid = _this.grid.getDataSource().getAt(ri).data;
174 var s = _this.grid.getSelectionModel().getSelections();
176 var isFromGroup = s.length ? s[0].data.id > 0 : false;
178 var isToGroup = rid && rid.id > 0;
180 if (isFromGroup && isToGroup) {
181 return this.dropNotAllowed;
183 if (!isFromGroup && !isToGroup) {
184 return this.dropNotAllowed;
186 if (isFromGroup && !isToGroup) {
187 return 'x-dd-drop-ok-sub';
189 //if (!isFromGroup && isToGroup) {
190 return 'x-dd-drop-ok-add';
195 notifyDrop : function(dd, e, data){
197 var t = Roo.lib.Event.getTarget(e);
198 var ri = _this.grid.view.findRowIndex(t);
201 rid = _this.grid.getDataSource().getAt(ri).data;
203 var s = _this.grid.getSelectionModel().getSelections();
206 var isFromGroup = s.length ? s[0].data.id > 0 : false;
208 var isToGroup = rid && rid.id > 0;
210 if (isFromGroup && isToGroup) {
213 if (!isFromGroup && !isToGroup) {
217 if (isFromGroup && !isToGroup) {
219 //return 'x-dd-drop-ok-sub';
221 // build a list of selections.
223 for (var i=0; i < data.selections.length; i++) {
224 sels.push(data.selections[i].data.id);
228 url: baseURL + '/Core/GroupMembers.php',
231 group_id: action =='add' ? rid.id : s[0].data.id,
233 user_ids : sels.join(',')
237 success : function(data) {
241 failure: function() {
242 //Ext.get(document.body).unmask();
252 //if (!isFromGroup && isToGroup) {
253 //return 'x-dd-drop-ok-add';
262 var gridFoot = this.grid.getView().getFooterPanel(true);
264 this.paging = new Ext.PagingToolbar(gridFoot, this.grid.getDataSource(), {
271 var grid = this.grid;
273 var gridHead = this.grid.getView().getHeaderPanel(true);
274 this.toolbar = new Ext.Toolbar(gridHead);
277 var _dialog= this.getDialog();
280 text: "Manage Groups",
281 cls: 'x-btn-text-icon',
282 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
288 cls: 'x-btn-text-icon',
289 icon: Ext.rootURL + 'images/default/dd/drop-add.gif',
290 hidden : !Pman.hasPerm('Core.Groups', 'A'),
291 handler : function(){
292 _dialog.show( { id : 0, type: _this.type }, refreshPager );
297 cls: 'x-btn-text-icon',
298 icon: Ext.rootURL + 'images/default/tree/leaf.gif',
299 hidden : !Pman.hasPerm('Core.Groups', 'E'),
300 handler : function() {
301 var s = grid.getSelectionModel().getSelections();
302 if (!s.length || (s.length > 1)) {
303 Ext.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
306 if ((s[0].data.name == 'Administrators') ||(s[0].data.name == 'Default')) {
307 Ext.MessageBox.alert("Error", "You can not rename that group");
310 if (s[0].data.id < 1) {
311 Ext.MessageBox.alert("Error", "You can not rename that group");
314 _dialog.show(s[0].data, refreshPager);
320 cls: 'x-btn-text-icon',
321 icon: rootURL + '/Pman/templates/images/trash.gif',
322 hidden : !Pman.hasPerm('Core.Groups', 'D'),
323 handler : function(){
324 var s = grid.getSelectionModel().getSelections();
326 for(var i = 0; i < s.length; i++) {
328 if ((s[i].data.id < 1) || (s[i].data.name == 'Administrators')) {
329 Ext.MessageBox.alert("Error", "You can not delete that group");
335 Pman.genericDelete(_this, 'Groups');
340 cls: 'x-btn-text-icon',
341 icon: rootURL + '/Pman/templates/images/view-refresh.gif',
342 handler : function(){
350 this.panel.on('activate', function() {
355 // add stuff to toolbar?
356 //this.innerLayout.endUpdate();
363 this.grid.getDataSource().reload();
365 // - is this used anymore?
367 show: function (parentLayout, region)
369 this.add(parentLayout, region);
370 this.grid.getDataSource().load({