Pman.Tab.CoreOAuthClient.bjs
[Pman.Core] / Pman.Tab.CoreOAuthClient.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Pman.Tab.CoreOAuthClient = new Roo.XComponent({
6     part     :  ["Core","OAuthClient"],
7     order    : '900-Pman.Tab.CoreOAuthClient',
8     region   : 'center',
9     parent   : 'Pman.Tab.Admin',
10     name     : "unnamed module",
11     disabled : false, 
12     permname : '', 
13     _tree : function()
14     {
15         var _this = this;
16         var MODULE = this;
17         return {
18             xtype: 'NestedLayoutPanel',
19             xns: Roo,
20             region : 'center',
21             title : "Oauth2 Clients",
22             layout : {
23                 xtype: 'BorderLayout',
24                 xns: Roo,
25                 items : [
26                     {
27                         xtype: 'GridPanel',
28                         xns: Roo,
29                         listeners : {
30                             activate : function() {
31                                 _this.panel = this;
32                                 
33                                 if (_this.grid) {
34                                     _this.grid.footer.onClick('first');
35                                 }
36                             }
37                         },
38                         background : true,
39                         fitContainer : true,
40                         fitToframe : true,
41                         region : 'center',
42                         tableName : 'core_oauth_clients',
43                         title : "Oauth2 Clients",
44                         grid : {
45                             xtype: 'EditorGrid',
46                             xns: Roo.grid,
47                             listeners : {
48                                 render : function() 
49                                 {
50                                     _this.grid = this; 
51                                     if (_this.panel.active) {
52                                        this.footer.onClick('first');
53                                     }
54                                 },
55                                 afteredit : function (e)
56                                 {
57                                     if(e.originalValue == e.value || !e.value.length){
58                                         return false;
59                                     }
60                                     
61                                     e.record.commit();
62                                 }
63                             },
64                             autoExpandColumn : 'redirect_uri',
65                             clicksToEdit : 1,
66                             loadMask : true,
67                             dataSource : {
68                                 xtype: 'Store',
69                                 xns: Roo.data,
70                                 listeners : {
71                                     beforeload : function (_self, o){
72                                         o.params = o.params || {};
73                                     
74                                     },
75                                     update : function (_self, record, operation)
76                                     {
77                                         if (operation != Roo.data.Record.COMMIT) {
78                                             return;
79                                         }
80                                         Roo.log(record);
81                                     
82                                         if (typeof(_this.data._hide_name) != 'undefined') {
83                                             record.set('name', record.data.display_name);
84                                         }
85                                         if (!record.data.client_id.length || !record.data.client_secret.length) {
86                                             return;
87                                         }
88                                         
89                                         // got commit..
90                                         new Pman.Request({
91                                             url : baseURL + '/Roo/Core_enum.php',
92                                             method : 'POST',
93                                             params : {
94                                                 id : record.data.id,
95                                                 etype : _this.data.etype,
96                                                 name :  record.data.name,
97                                                 active : record.data.active,
98                                                 seqid : record.data.seqid,
99                                                 display_name : record.data.display_name
100                                             }, 
101                                             success : function(res) {
102                                                 //Roo.log(data);
103                                                 // update the ID if it's not set..
104                                                 if (record.data.id * 1 < 1) {
105                                                     record.set('id', res.data.id);
106                                                 }
107                                             }
108                                         });
109                                         
110                                     }
111                                 },
112                                 remoteSort : true,
113                                 sortInfo : { field : 'client_id', direction: 'ASC' },
114                                 proxy : {
115                                     xtype: 'HttpProxy',
116                                     xns: Roo.data,
117                                     method : 'GET',
118                                     url : baseURL + '/Roo/Core_oauth_clients'
119                                 },
120                                 reader : {
121                                     xtype: 'JsonReader',
122                                     xns: Roo.data,
123                                     id : 'id',
124                                     root : 'data',
125                                     totalProperty : 'total',
126                                     fields : [
127                                         {
128                                             'name': 'client_id',
129                                             'type': 'string'
130                                         },
131                                         {
132                                             'name': 'client_secret',
133                                             'type': 'string'
134                                         },
135                                         {
136                                             'name': 'redirect_uri',
137                                             'type': 'string'
138                                         }
139                                     ]
140                                 }
141                             },
142                             toolbar : {
143                                 xtype: 'Toolbar',
144                                 xns: Roo,
145                                 items : [
146                                     {
147                                         xtype: 'Button',
148                                         xns: Roo.Toolbar,
149                                         listeners : {
150                                             click : function()
151                                             {
152                                                 var status = _this.form.findField('pohead_status').getValue();
153                                                 
154                                                 if(status == 'C'){
155                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
156                                                     return;
157                                                 }
158                                                 
159                                                 var ct  =    _this.grid.ds.getCount();
160                                                 
161                                                 var last = ct ? _this.grid.ds.getAt(ct-1).data.poitem_linenumber * 1 + 1 : 1;
162                                                 
163                                                 var dt = _this.form.findField('pohead_orderdate').getValue();
164                                                 
165                                                 var nr = _this.grid.ds.reader.newRow({
166                                                     poitem_id : 0,
167                                                     poitem_linenumber : last,
168                                                     item_number : '',
169                                                     item_descrip1 : '',
170                                                     poitem_duedate : dt,
171                                                     poitem_qty_ordered : 1,
172                                                     poitem_unitprice : 0
173                                                 });
174                                                 
175                                                 _this.grid.stopEditing();
176                                                 _this.grid.ds.insert(_this.grid.ds.getCount(), nr); 
177                                                 _this.grid.startEditing(_this.grid.ds.getCount()-1, 1);
178                                             }
179                                         },
180                                         cls : 'x-btn-text-icon',
181                                         text : "Add",
182                                         icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
183                                     },
184                                     {
185                                         xtype: 'Button',
186                                         xns: Roo.Toolbar,
187                                         listeners : {
188                                             click : function ()
189                                             {
190                                                 var status = _this.form.findField('pohead_status').getValue();
191                                                 
192                                                 if(status == 'C'){
193                                                     Roo.MessageBox.alert("Error", "This PO has been closed");
194                                                     return;
195                                                 }
196                                                 
197                                                 var cs = _this.grid.getSelectionModel().getSelectedCell();
198                                                 if (!cs) {
199                                                     Roo.MessageBox.alert("Error", "Select a cell");
200                                                     return;
201                                                 }
202                                                 _this.grid.stopEditing();
203                                                 var r = _this.grid.ds.getAt(cs[0]);
204                                                 
205                                                 if(r.data.poitem_qty_received * 1 > 0){
206                                                     Roo.MessageBox.alert("Error", "This item has been receipted");
207                                                     return;
208                                                 }
209                                                 
210                                                 
211                                                 _this.grid.ds.remove(r);
212                                                
213                                             }
214                                         },
215                                         cls : 'x-btn-text-icon',
216                                         text : "Remove",
217                                         icon : rootURL + '/Pman/templates/images/trash.gif'
218                                     }
219                                 ]
220                             },
221                             footer : {
222                                 xtype: 'PagingToolbar',
223                                 xns: Roo,
224                                 displayInfo : true,
225                                 emptyMsg : "No Clients found",
226                                 pageSize : 25
227                             },
228                             colModel : [
229                                 {
230                                     xtype: 'ColumnModel',
231                                     xns: Roo.grid,
232                                     dataIndex : 'client_id',
233                                     header : 'Client ID',
234                                     width : 150,
235                                     renderer : function(v) { 
236                                         return String.format('{0}', v ? v : '');
237                                     },
238                                     editor : {
239                                         xtype: 'GridEditor',
240                                         xns: Roo.grid,
241                                         field : {
242                                             xtype: 'TextField',
243                                             xns: Roo.form,
244                                             allowBlank : false
245                                         }
246                                     }
247                                 },
248                                 {
249                                     xtype: 'ColumnModel',
250                                     xns: Roo.grid,
251                                     dataIndex : 'client_secret',
252                                     header : 'Client Secret',
253                                     width : 150,
254                                     renderer : function(v) { 
255                                         return String.format('{0}', v ? v : '');
256                                     },
257                                     editor : {
258                                         xtype: 'GridEditor',
259                                         xns: Roo.grid,
260                                         field : {
261                                             xtype: 'TextField',
262                                             xns: Roo.form,
263                                             allowBlank : false
264                                         }
265                                     }
266                                 },
267                                 {
268                                     xtype: 'ColumnModel',
269                                     xns: Roo.grid,
270                                     dataIndex : 'redirect_uri',
271                                     header : 'Redirect URI',
272                                     width : 150,
273                                     renderer : function(v) { 
274                                         return String.format('{0}', v ? v : '');
275                                     },
276                                     editor : {
277                                         xtype: 'GridEditor',
278                                         xns: Roo.grid,
279                                         field : {
280                                             xtype: 'TextField',
281                                             xns: Roo.form
282                                         }
283                                     }
284                                 }
285                             ]
286                         }
287                     }
288                 ],
289                 center : {
290                     xtype: 'LayoutRegion',
291                     xns: Roo,
292                     autoScroll : false,
293                     split : true
294                 }
295             }
296         };
297     }
298 });