Pman.Dialog.BuilderAdd.bjs
[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 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.BuilderAdd = {
8
9  dialog : false,
10  callback:  false,
11
12  show : function(data, cb)
13  {
14   if (!this.dialog) {
15    this.create();
16   }
17
18   this.callback = cb;
19   this.data = data;
20   this.dialog.show(this.data._el);
21   if (this.form) {
22    this.form.reset();
23    this.form.setValues(data);
24    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
25   }
26
27  },
28
29  create : function()
30  {
31    var _this = this;
32    this.dialog = Roo.factory({
33    center : {
34     '|xns' : 'Roo',
35     xtype : 'LayoutRegion',
36     xns : Roo
37    },
38    '|xns' : 'Roo',
39    modal : true,
40    xtype : 'LayoutDialog',
41    title : "Add Node",
42    width : 400,
43    xns : Roo,
44    closable : false,
45    resizable : false,
46    height : 170,
47    buttons : [
48      {
49       '|xns' : 'Roo',
50       text : "OK",
51       xtype : 'Button',
52       xns : Roo,
53       listeners : {
54        click : function (_self, e)
55         {
56             var vals = _this.form.getValues();
57             
58             _this.dialog.hide();
59             
60            if (vals.table.length) {
61               Pman.Dialog.BuilderAddTable.show( 
62                Roo.apply({  table : vals.table } , _this.data),  
63                
64                function(data) {
65                     _this.dialog.hide();
66                     var cls = data['|xns'] + '.' + data['xtype'];
67                     
68                     var res = Pman.Builder.Wizard[cls](data);
69                    _this.callback(res); 
70                });
71                 return;
72             }
73            
74             // otherwise, call back with template??
75            
76              
77              _this.callback(_this.data);
78         }
79       }
80      },
81 {
82       '|xns' : 'Roo',
83       text : "Cancel",
84       xtype : 'Button',
85       xns : Roo,
86       listeners : {
87        click : function (_self, e)
88         {
89            _this.dialog.hide();
90         }
91       }
92      }
93    ],
94    items : [
95     {
96      '|xns' : 'Roo',
97      region : 'center',
98      xtype : 'ContentPanel',
99      xns : Roo,
100      items : [
101       {
102        '|xns' : 'Roo.form',
103        xtype : 'Form',
104        xns : Roo.form,
105        listeners : {
106         rendered : function (form)
107          {
108            _this.form  = form;
109          },
110         actioncomplete : function (_self, action)
111          {
112               if (action.type == 'setdata') {
113                   // check if element can be templated or databased..
114                   
115                    
116               }
117          }
118        },
119        items : [
120         {
121          '|xns' : 'Roo.form',
122          legend : "Do you want to create the element?",
123          xtype : 'FieldSet',
124          style : 'width:350px',
125          labelWidth : 140,
126          xns : Roo.form,
127          items : [
128           {
129            store : {
130             '|xns' : 'Roo.data',
131             xtype : 'Store',
132             xns : Roo.data
133            },
134            '|xns' : 'Roo.form',
135            fieldLabel : 'From Template',
136            xtype : 'ComboBox',
137            xns : Roo.form,
138            name : 'template',
139            items : [
140
141            ]
142
143           },
144           {
145            store : {
146             proxy : {
147              '|xns' : 'Roo.data',
148              url : baseURL + '/Builder/ERM.php',
149              method : 'GET',
150              xtype : 'HttpProxy',
151              xns : Roo.data
152             },
153             reader : {
154              '|xns' : 'Roo.data',
155              root : 'data',
156              xtype : 'JsonReader',
157              fields : [  'name' , 'desc' ],
158              xns : Roo.data,
159              totalProperty : 'total'
160             },
161             '|xns' : 'Roo.data',
162             xtype : 'Store',
163             xns : Roo.data,
164             items : [
165
166             ]
167
168            },
169            '|xns' : 'Roo.form',
170            alwaysQuery : true,
171            listWidth : 400,
172            triggerAction : 'all',
173            fieldLabel : 'From Database Table',
174            displayField : 'name',
175            xtype : 'ComboBox',
176            allowBlank : true,
177            xns : Roo.form,
178            name : 'table',
179            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b> {desc}</div>',
180            items : [
181
182            ]
183
184           }
185          ]
186
187         }
188        ]
189
190       }
191      ]
192
193     }
194    ]
195
196   });
197  }
198 };