PHP8
[Pman.BAdmin] / Pman.Dialog.BAdminStaffGroups.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.BAdminStaffGroups= function() {}
8 Roo.apply(Pman.Dialog.BAdminStaffGroups.prototype, {
9
10  _strings : {
11   '4910043d0b2c8c864a0e8672716fee94' :"Is a Member",
12   '566a352f95c879ff26e50bad767a28dc' :"Group Membership",
13   '6b79852e4370cae80ee551e0671616bb' :"Manage Users Group",
14   '28974c2c793e780427dfb571b26443e6' :"Group Name",
15   'd3d2e617335f08df83599665eef8a418' :"Close"
16  },
17
18  dialog : false,
19  callback:  false,
20
21  show : function(data, cb)
22  {
23   if (!this.dialog) {
24    this.create();
25   }
26
27   this.callback = cb;
28   this.data = data;
29   this.dialog.show.apply(this.dialog,  Array.prototype.slice.call(arguments).slice(2));
30   if (this.form) {
31    this.form.reset();
32    this.form.setValues(data);
33    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
34   }
35
36  },
37
38  create : function()
39  {
40   var _this = this;
41   this.dialog = Roo.factory({
42     xtype : 'Modal',
43     fitwindow : true,
44     max_width : 500,
45     size : 'md',
46     title : _this._strings['6b79852e4370cae80ee551e0671616bb'] /* Manage Users Group */,
47     listeners : {
48      render : function (_self)
49       {
50           _this.dialog = this;
51       },
52      show : function (_self)
53       {
54           this.setTitle("Manage Membership for " + _this.data.name);
55            if(_this.option_grid){
56               _this.option_grid.store.load({});
57           }
58       }
59     },
60     xns : Roo.bootstrap,
61     '|xns' : 'Roo.bootstrap',
62     buttons : [
63      {
64       xtype : 'Button',
65       html : _this._strings['d3d2e617335f08df83599665eef8a418'] /* Close */,
66       weight : 'primary',
67       listeners : {
68        click : function (_self, e)
69         {
70             _this.dialog.hide();
71             _this.callback();
72             
73             return;
74         
75         }
76       },
77       xns : Roo.bootstrap,
78       '|xns' : 'Roo.bootstrap'
79      }
80     ],
81     items  : [
82      {
83       xtype : 'Border',
84       listeners : {
85        render : function (_self)
86         {
87             _this.layout = _self;
88         }
89       },
90       xns : Roo.bootstrap.layout,
91       '|xns' : 'Roo.bootstrap.layout',
92       center : {
93        xtype : 'Region',
94        xns : Roo.bootstrap.layout,
95        '|xns' : 'Roo.bootstrap.layout'
96       },
97       items  : [
98        {
99         xtype : 'Grid',
100         background : false,
101         fitContainer : true,
102         fitToFrame : true,
103         region : 'center',
104         title : _this._strings['566a352f95c879ff26e50bad767a28dc'] /* Group Membership */,
105         listeners : {
106          activate : function (_self)
107           {
108              
109               
110           },
111          render : function (_self)
112           {
113               _this.option_panel = this;
114               
115               
116           }
117         },
118         xns : Roo.bootstrap.panel,
119         '|xns' : 'Roo.bootstrap.panel',
120         grid : {
121          xtype : 'Table',
122          cellSelection : true,
123          cls : 'table-fixed',
124          condensed : true,
125          footerShow : false,
126          loadMask : true,
127          rowSelection : false,
128          listeners : {
129           cellclick : function (_self, el, rowIndex, columnIndex, e)
130            {
131                var di = _this.option_grid.colModel.getDataIndex(columnIndex);
132                
133                /*
134                if (di != 'is_in_group') {
135                    return;
136                }
137                 */
138                var rec = _this.option_grid.store.getAt(rowIndex);
139                
140                if(rec.data.name == 'Administrators' && _this.data.id == Pman.Login.authUser.id){
141                    Roo.bootstrap.MessageBox.alert('Error', 'You can not remove yourself from Administrators group');
142                    return;
143                }
144                
145                rec.set('is_in_group', rec.data.is_in_group * 1 == 1 ? 0 : 1);
146                rec.commit();
147            
148            },
149           render : function (_self)
150            {
151                _this.option_grid = this;
152                
153                this.store.load({})
154            }
155          },
156          xns : Roo.bootstrap,
157          '|xns' : 'Roo.bootstrap',
158          store : {
159           xtype : 'Store',
160           remoteSort : true,
161           sortInfo : { direction : 'ASC', field: 'display_name' },
162           listeners : {
163            beforeload : function (_self, options)
164             { 
165                 options.params = options.params || {};
166                 
167                 if(_this.data.id * 1 < 1){
168                     _this.option_grid.el.mask('Please save the member first');
169                     this.removeAll();
170                     return false;
171                 }
172                 options.params.limit = 200;
173                 options.params._is_in_group = _this.data.id;
174             
175             },
176            update : function (_self, record, operation)
177             {
178                 if (operation != 'commit') {
179                     return;
180                 }
181                 
182                 var params = {
183                     user_ids : _this.data.id,
184                     _action : (record.data.is_in_group * 1 == 0) ? 'sub' : 'add',
185                     group_id : record.data.id
186                 };
187                 
188                 new Pman.Request({
189                     url : baseURL + '/Roo/Core_group',
190                     method : 'POST',
191                     params : params,
192                     success : function() { 
193                         //_this.option_grid.ds.load({});
194                     }
195               });
196             }
197           },
198           xns : Roo.data,
199           '|xns' : 'Roo.data',
200           proxy : {
201            xtype : 'HttpProxy',
202            method : 'GET',
203            url : baseURL + '/Roo/core_group',
204            xns : Roo.data,
205            '|xns' : 'Roo.data'
206           },
207           reader : {
208            xtype : 'JsonReader',
209            fields : [
210                {
211                    'name': 'id',
212                    'type': 'int'
213                },
214                {
215                    'name': 'name',
216                    'type': 'string'
217                },
218                {
219                    'name': 'display_name',
220                    'type': 'string'
221                },
222                {
223                    'name': 'is_in_group',
224                    'type': 'int'
225                }
226            ],
227            id : 'id',
228            root : 'data',
229            xns : Roo.data,
230            '|xns' : 'Roo.data'
231           }
232          },
233          sm : {
234           xtype : 'RowSelectionModel',
235           singleSelect : true,
236           xns : Roo.bootstrap.Table,
237           '|xns' : 'Roo.bootstrap.Table'
238          },
239          cm : [
240           {
241            xtype : 'ColumnModel',
242            align : 'center',
243            cursor : 'pointer',
244            dataIndex : 'is_in_group',
245            header : _this._strings['4910043d0b2c8c864a0e8672716fee94'] /* Is a Member */,
246            renderer : function(v) {  
247            
248                var state = v > 0 ?  'check-' : '';
249                var cls = v > 0 ? 'text-primary' : '';
250                
251                return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
252                     
253             },
254            sortable : false,
255            xs : 3,
256            xns : Roo.grid,
257            '|xns' : 'Roo.grid'
258           },
259           {
260            xtype : 'ColumnModel',
261            cursor : 'pointer',
262            dataIndex : 'display_name',
263            header : _this._strings['28974c2c793e780427dfb571b26443e6'] /* Group Name */,
264            renderer : function(v,x,r) 
265            {
266                var vv = v.length ? v : r.data.name;
267                
268                return String.format('{0}', vv);
269            },
270            sortable : true,
271            xs : 9,
272            xns : Roo.grid,
273            '|xns' : 'Roo.grid'
274           }
275          ]
276         }
277        }
278       ]
279      }
280     ]
281    }  );
282  }
283 });
284 Roo.apply(Pman.Dialog.BAdminStaffGroups, Pman.Dialog.BAdminStaffGroups.prototype);