Pman.Dialog.BuilderModule.js
[Pman.Builder] / Pman.Dialog.BuilderModule.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.Dialog.BuilderModule = {
6
7     dialog : false,
8     callback:  false,
9
10     show : function(data, cb)
11     {
12         if (!this.dialog) {
13             this.create();
14         }
15
16         this.callback = cb;
17         this.data = data;
18         this.dialog.show(this.data._el);
19         if (this.form) {
20            this.form.reset();
21            this.form.setValues(data);
22            this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
23         }
24
25     },
26
27     create : function()
28     {
29         var _this = this;
30         this.dialog = Roo.factory({
31             xtype: 'LayoutDialog',
32             xns: Roo,
33             closable : false,
34             collapsible : false,
35             height : 180,
36             modal : true,
37             resizable : false,
38             title : "Edit / Create builder_modules",
39             width : 400,
40             items : [
41                 {
42                     xtype: 'ContentPanel',
43                     xns: Roo,
44                     region : 'center',
45                     items : [
46                         {
47                             xtype: 'Form',
48                             xns: Roo.form,
49                             listeners : {
50                                 actioncomplete : function(_self,action)
51                                 {
52                                     if (action.type == 'setdata') {
53                                        if (_this.data.id) {
54                                            _this.dialog.el.mask("Loading");
55                                             this.load({ method: 'GET', params: { '_id' : _this.data.id }});
56                                             return;
57                                         }
58                                        return;
59                                     }
60                                     if (action.type == 'load') {
61                                         _this.dialog.el.unmask();
62                                         return;
63                                     }
64                                     if (action.type =='submit') {
65                                     
66                                         _this.dialog.el.unmask();
67                                         _this.dialog.hide();
68                                     
69                                          if (_this.callback) {
70                                             _this.callback.call(_this, _this.form.getValues());
71                                          }
72                                          _this.form.reset();
73                                          return;
74                                     }
75                                 },
76                                 rendered : function (form)
77                                 {
78                                     this.dialog = _this.dialog;
79                                     _this.form= form;
80                                 }
81                             },
82                             method : 'POST',
83                             style : 'margin:10px;',
84                             url : baseURL + '/Roo/builder_modules.php',
85                             items : [
86                                 {
87                                     xtype: 'TextField',
88                                     xns: Roo.form,
89                                     fieldLabel : 'Name',
90                                     name : 'name',
91                                     width : 200
92                                 },
93                                 {
94                                     xtype: 'TextField',
95                                     xns: Roo.form,
96                                     fieldLabel : 'Path',
97                                     name : 'path',
98                                     width : 200
99                                 },
100                                 {
101                                     xtype: 'Checkbox',
102                                     xns: Roo.form,
103                                     fieldLabel : 'Public',
104                                     name : 'public',
105                                     width : 75
106                                 },
107                                 {
108                                     xtype: 'Hidden',
109                                     xns: Roo.form,
110                                     name : 'id'
111                                 }
112                             ]
113                         }
114                     ]
115                 }
116             ],
117             center : {
118                 xtype: 'LayoutRegion',
119                 xns: Roo
120             },
121             buttons : [
122                 {
123                     xtype: 'Button',
124                     xns: Roo,
125                     listeners : {
126                         click : function (_self, e)
127                         {
128                             _this.dialog.hide();
129                         }
130                     },
131                     text : "Cancel"
132                 },
133                 {
134                     xtype: 'Button',
135                     xns: Roo,
136                     listeners : {
137                         click : function (_self, e)
138                         {
139                             // do some checks?
140                              
141                             
142                             _this.dialog.el.mask("Saving");
143                             _this.form.doAction("submit");
144                         
145                         }
146                     },
147                     text : "Save"
148                 }
149             ]
150         });
151     }
152 };