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