Pman.Dialog.BuilderPart.js
[Pman.Builder] / Pman.Dialog.BuilderPart.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.BuilderPart = {
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 : 140,
36             resizable : false,
37             title : "Edit / Create builder_part",
38             width : 450,
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.load({ method: 'GET', params: { '_id' : _this.data.id }});
54                                             return;
55                                         }
56                                        return;
57                                     }
58                                     if (action.type == 'load') {
59                                          
60                                         return;
61                                     }
62                                     if (action.type =='submit') {
63                                      
64                                         _this.dialog.hide();
65                                     
66                                          if (_this.callback) {
67                                             _this.callback.call(_this, _this.form.getValues());
68                                          }
69                                          _this.form.reset();
70                                          return;
71                                     }
72                                 },
73                                 rendered : function (form)
74                                 {
75                                     _this.form= form;
76                                 }
77                             },
78                             method : 'POST',
79                             style : 'margin:10px;',
80                             url : baseURL + '/Roo/builder_part.php',
81                             items : [
82                                 {
83                                     xtype: 'TextField',
84                                     xns: Roo.form,
85                                     fieldLabel : 'Part name',
86                                     name : 'name',
87                                     width : 300
88                                 },
89                                 {
90                                     xtype: 'Hidden',
91                                     xns: Roo.form,
92                                     name : 'module_id'
93                                 },
94                                 {
95                                     xtype: 'Hidden',
96                                     xns: Roo.form,
97                                     name : 'id'
98                                 }
99                             ]
100                         }
101                     ]
102                 }
103             ],
104             center : {
105                 xtype: 'LayoutRegion',
106                 xns: Roo
107             },
108             buttons : [
109                 {
110                     xtype: 'Button',
111                     xns: Roo,
112                     listeners : {
113                         click : function (_self, e)
114                         {
115                             _this.dialog.hide();
116                         }
117                     },
118                     text : "Cancel"
119                 },
120                 {
121                     xtype: 'Button',
122                     xns: Roo,
123                     listeners : {
124                         click : function (_self, e)
125                         {
126                             // do some checks?
127                              
128                              
129                             _this.form.doAction("submit");
130                         
131                         }
132                     },
133                     text : "Save"
134                 }
135             ]
136         });
137     }
138 };