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