Pman.Dialog.BAdminGroups.bjs
[Pman.BAdmin] / Pman.Dialog.BAdminGroups.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.BAdminGroups= function() {}
8 Roo.apply(Pman.Dialog.BAdminGroups.prototype, {
9
10  _strings : {
11   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
12   'a0f852ef8bfccd86a0e7217d7959e3e8' :"Add / Edit User",
13   '49ee3087348e8d44e1feda1917443987' :"Name",
14   'c9cc8cce247e49bae79f15173ce97354' :"Save"
15  },
16
17  dialog : false,
18  callback:  false,
19
20  show : function(data, cb)
21  {
22   if (!this.dialog) {
23    this.create();
24   }
25
26   this.callback = cb;
27   this.data = data;
28   this.dialog.show(this.data._el);
29   if (this.form) {
30    this.form.reset();
31    this.form.setValues(data);
32    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
33   }
34
35  },
36
37  create : function()
38  {
39   var _this = this;
40   this.dialog = Roo.factory({
41     xtype : 'Modal',
42     title : _this._strings['a0f852ef8bfccd86a0e7217d7959e3e8'] /* Add / Edit User */,
43     listeners : {
44      render : function (_self)
45       {
46           _this.modal = _self;
47       }
48     },
49     xns : Roo.bootstrap,
50     '|xns' : 'Roo.bootstrap',
51     buttons : [
52      {
53       xtype : 'Button',
54       html : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
55       listeners : {
56        click : function (_self, e)
57         {
58             _this.dialog.hide(); 
59         }
60       },
61       xns : Roo.bootstrap,
62       '|xns' : 'Roo.bootstrap'
63      },
64      {
65       xtype : 'Button',
66       html : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
67       weight : 'primary',
68       listeners : {
69        click : function (_self, e)
70         {
71             if(!_this.form.isValid()){
72                 Roo.bootstrap.MessageBox.alert('Error', 'Please Correct all the errors in red');
73                 return;
74             }
75             
76             var myID = _this.form.findField('id').getValue() * 1;
77             var myName = _this.form.findField('name').getValue();
78         
79             if (_this.form.findField('company_id') && !_this.form.findField('company_id').getValue()) {
80                 Roo.bootstrap.MessageBox.alert("Error", "Select a Company");
81                 return;
82             }
83                 
84                // validate password match (only needed if we are not using generated one..
85             if (_this.form.findField('passwd1') 
86                     && _this.form.findField('passwd1').getValue().length > 0 
87                     && _this.form.findField('passwd1').inputEl().dom.type == "password") {
88                     
89                 var p1 = _this.form.findField('passwd1').getValue();
90                 var p2 = _this.form.findField('passwd2').getValue();
91                     
92                     
93                 if (Pman.Login.authUser.id < 0 && !p1.length) {
94                     Roo.bootstrap.MessageBox.alert("Error", "You must create a password for the admin account");
95                     return;
96                 }
97                     
98                     
99                 if (p1.length || p2.length) {
100                     if (p1 != p2) {
101                         Roo.bootstrap.MessageBox.alert("Error", "Passwords do not match");
102                         return;
103                     }
104                 }
105                     
106                 
107             }
108             _this.form.doAction("submit");
109         
110           
111         
112             return;
113         }
114       },
115       xns : Roo.bootstrap,
116       '|xns' : 'Roo.bootstrap'
117      }
118     ],
119     items  : [
120      {
121       xtype : 'Form',
122       labelAlign : 'top',
123       url : baseURL + '/Roo/Core_group',
124       listeners : {
125        actioncomplete : function (_self, action)
126         {
127             if(action.type == 'setdata'){
128             
129                if(_this.data.id * 1 > 0) {
130                     this.doAction('load',{ method: 'GET', params: { '_id' : _this.data.id }});
131                 } 
132                 
133                 return;
134             }
135            
136             if (action.type == 'load') {
137                 _this.data = action.result.data;
138                 return;
139             }
140             
141             
142             if (action.type == 'submit') {
143             
144                 _this.dialog.hide();
145                
146                 if (_this.callback) {
147                     _this.callback.call(this, action.result.data);
148                 }
149                 
150                 return; 
151             }
152         },
153        actionfailed : function (_self, action)
154         {
155             Roo.log(action);
156             Roo.bootstrap.MessageBox.alert(action.result.errorMsg);
157         },
158        render : function (_self)
159         {
160             _this.form = _self;
161         }
162       },
163       xns : Roo.bootstrap,
164       '|xns' : 'Roo.bootstrap',
165       items  : [
166        {
167         xtype : 'Input',
168         name : 'name',
169         placeholder : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
170         xns : Roo.bootstrap,
171         '|xns' : 'Roo.bootstrap'
172        },
173        {
174         xtype : 'Input',
175         inputType : 'hidden',
176         name : 'id',
177         xns : Roo.bootstrap,
178         '|xns' : 'Roo.bootstrap'
179        }
180       ]
181      }
182     ]
183    }  );
184  }
185 });
186 Roo.apply(Pman.Dialog.BAdminGroups, Pman.Dialog.BAdminGroups.prototype);