php7 fixes
[Pman.Builder] / Pman.Dialog.BuilderProp.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.BuilderProp = {
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             listeners : {
34                 show : function (_self)
35                 {
36                    _this.grid.ds.load({});
37                 }
38             },
39             closable : false,
40             collapsible : false,
41             height : 600,
42             modal : true,
43             resizable : false,
44             title : "Add Property",
45             width : 600,
46             items : [
47                 {
48                     xtype: 'GridPanel',
49                     xns: Roo,
50                     listeners : {
51                         activate : function() {
52                             _this.panel = this;
53                             //if (_this.grid) {
54                             //    _this.grid.ds.load({});
55                             //}
56                         }
57                     },
58                     fitContainer : true,
59                     fitToframe : true,
60                     region : 'center',
61                     title : "Props",
62                     grid : {
63                         xtype: 'Grid',
64                         xns: Roo.grid,
65                         listeners : {
66                             render : function() 
67                             {
68                                 _this.grid = this; 
69                                 //_this.dialog = Pman.Dialog.FILL_IN
70                                // if (_this.panel.active) {
71                                  //  this.footer.onClick('first');
72                                // }
73                             },
74                             rowdblclick : function (_self, rowIndex, e)
75                             {
76                                  
77                                  _this.callback(this.getDataSource().getAt(rowIndex).data.name);
78                                  _this.dialog.hide(); 
79                             }
80                         },
81                         autoExpandColumn : 'desc',
82                         loadMask : true,
83                         dataSource : {
84                             xtype: 'Store',
85                             xns: Roo.data,
86                             listeners : {
87                                 beforeload : function (_self, options)
88                                 {
89                                     // we should cache this!!!
90                                     options.params = options.params || {};
91                                     options.params.xtype = _this.data.xtype;
92                                     options.params.xns = _this.data.xns;
93                                     options.params.list = _this.data.list;    
94                                 }
95                             },
96                             remoteSort : false,
97                             sortInfo : { field : 'name', direction: 'ASC' },
98                             proxy : {
99                                 xtype: 'HttpProxy',
100                                 xns: Roo.data,
101                                 method : 'GET',
102                                 url : baseURL + '/Builder/Palette/Prop.php'
103                             },
104                             reader : {
105                                 xtype: 'JsonReader',
106                                 xns: Roo.data,
107                                 id : 'id',
108                                 root : 'data',
109                                 totalProperty : 'total',
110                                 fields : [
111                                     'name',
112                                     'desc'
113                                 ]
114                             }
115                         },
116                         colModel : [
117                             {
118                                 xtype: 'ColumnModel',
119                                 xns: Roo.grid,
120                                 dataIndex : 'name',
121                                 header : 'name',
122                                 width : 175,
123                                 renderer : function(v) { return String.format('{0}', v ? v : ''); }
124                             },
125                             {
126                                 xtype: 'ColumnModel',
127                                 xns: Roo.grid,
128                                 dataIndex : 'desc',
129                                 header : 'Description',
130                                 width : 200,
131                                 renderer : function(v) { return String.format('{0}', v); }
132                             }
133                         ]
134                     }
135                 }
136             ],
137             center : {
138                 xtype: 'LayoutRegion',
139                 xns: Roo
140             },
141             buttons : [
142                 {
143                     xtype: 'Button',
144                     xns: Roo,
145                     listeners : {
146                         click : function (_self, e)
147                         {
148                             _this.dialog.hide();
149                         }
150                     },
151                     text : "Cancel"
152                 },
153                 {
154                     xtype: 'Button',
155                     xns: Roo,
156                     listeners : {
157                         click : function (_self, e)
158                         {
159                             // do some checks?
160                              var sel = _this.grid.getSelectionModel().getSelected();
161                             if (!sel) {
162                                 Roo.MessageBox.alert("Error", "Select a property");
163                             }
164                             
165                             _this.callback(sel.data.name);
166                            _this.dialog.hide();
167                          
168                         
169                         }
170                     },
171                     text : "Add"
172                 }
173             ]
174         });
175     }
176 };