DataObjects/Builder_tables.php
[Pman.Builder] / Pman.Dialog.BuilderAdd.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.BuilderAdd = {
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             height : 170,
35             modal : true,
36             resizable : false,
37             title : "Add Node",
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                                 rendered : function (form)
50                                 {
51                                   _this.form  = form;
52                                 },
53                                 actioncomplete : function (_self, action)
54                                 {
55                                      if (action.type == 'setdata') {
56                                          // check if element can be templated or databased..
57                                          
58                                           
59                                      }
60                                 }
61                             },
62                             items : [
63                                 {
64                                     xtype: 'FieldSet',
65                                     xns: Roo.form,
66                                     labelWidth : 140,
67                                     legend : "Do you want to create the element :",
68                                     style : 'width:350px',
69                                     items : [
70                                         {
71                                             xtype: 'ComboBox',
72                                             xns: Roo.form,
73                                             fieldLabel : 'From Template',
74                                             name : 'template',
75                                             store : {
76                                                 xtype: 'Store',
77                                                 xns: Roo.data
78                                             }
79                                         },
80                                         {
81                                             xtype: 'ComboBox',
82                                             xns: Roo.form,
83                                             allowBlank : true,
84                                             alwaysQuery : true,
85                                             displayField : 'name',
86                                             fieldLabel : 'From Database Table',
87                                             listWidth : 400,
88                                             name : 'table',
89                                             tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> {desc}</div>',
90                                             triggerAction : 'all',
91                                             store : {
92                                                 xtype: 'Store',
93                                                 xns: Roo.data,
94                                                 proxy : {
95                                                     xtype: 'HttpProxy',
96                                                     xns: Roo.data,
97                                                     method : 'GET',
98                                                     url : baseURL + '/Builder/ERM.php'
99                                                 },
100                                                 reader : {
101                                                     xtype: 'JsonReader',
102                                                     xns: Roo.data,
103                                                     root : 'data',
104                                                     totalProperty : 'total',
105                                                     fields : [  'name' , 'desc' ]
106                                                 }
107                                             }
108                                         }
109                                     ]
110                                 }
111                             ]
112                         }
113                     ]
114                 }
115             ],
116             center : {
117                 xtype: 'LayoutRegion',
118                 xns: Roo
119             },
120             buttons : [
121                 {
122                     xtype: 'Button',
123                     xns: Roo,
124                     listeners : {
125                         click : function (_self, e)
126                         {
127                             var vals = _this.form.getValues();
128                             
129                             _this.dialog.hide();
130                             
131                            if (vals.table.length) {
132                               Pman.Dialog.BuilderAddTable.show( 
133                                Roo.apply({  table : vals.table } , _this.data),  
134                                
135                                function(data) {
136                                     _this.dialog.hide();
137                                     var cls = data['|xns'] + '.' + data['xtype'];
138                                     
139                                     var res = Pman.Builder.Wizard[cls](data);
140                                    _this.callback(res); 
141                                });
142                                 return;
143                             }
144                            
145                             // otherwise, call back with template??
146                            
147                              
148                              _this.callback(_this.data);
149                         }
150                     },
151                     text : "OK"
152                 },
153                 {
154                     xtype: 'Button',
155                     xns: Roo,
156                     listeners : {
157                         click : function (_self, e)
158                         {
159                            _this.dialog.hide();
160                         }
161                     },
162                     text : "Cancel"
163                 }
164             ]
165         });
166     }
167 };