5 * [Roo.grid.grid] << convert a cfg into a table.
6 * [Roo.grid.grid-edit] << create a config from a tree.
9 * My initial idea was to parse the existing nodes, to generate the cfg.
10 * -- this is far too complicated..
11 * -- let's go back to the idea of storing the config on the relivant nodes.
12 * -- The downside is that if you modify the children, then the wizard will
13 * not know about those columns. etc..
20 Pman.Builder.Wizard = {
27 'time' : 'string', //bogus
34 'timestamp' : 'number',
43 'longtext' : 'string',
44 'tinytext' : 'string',
45 'mediumtext' : 'string',
52 * @param {Object} cfg the configuration
53 * @param {Object} old the previous def...
55 * - cols_ex : [ name, name]
63 - gen config - prior to editing
67 'Roo.GridPanel' : function(cfg, old)
73 var gi = _t['Roo.grid.Grid'](cfg);
79 '.builderCfg' : Roo.encode(cfg),
87 "|activate": "function() {\n _this.panel = this;\n if (_this.grid) {\n _this.grid.footer.onClick('first');\n }\n}"
94 'Roo.grid.Grid' : function(cfg, old)
103 Roo.each(cfg.cols, function(cc) {
104 colmodel.push( _t['Roo.grid.ColumnModel'](cc) );
107 var dataSource = _t['Roo.data.Store'](cfg);
108 dataSource['*prop'] = 'dataSource';
112 '.builderCfg' : Roo.encode(cfg),
113 "autoExpandColumn": cfg.cols_ex[0],
116 "|render": "function() \n" +
118 " _this.grid = this; \n" +
119 " //_this.dialog = Pman.Dialog.FILL_IN\n" +
120 " if (_this.panel.active) {\n" +
121 " this.footer.onClick('first');\n" +
124 "|rowdblclick": "function (_self, rowIndex, e)\n" +
126 " if (!_this.dialog) return;\n" +
127 " _this.dialog.show( this.getDataSource().getAt(rowIndex), function() {\n" +
128 " _this.grid.footer.onClick('first');\n" +
138 "xtype": "PagingToolbar",
141 "displayMsg": "Displaying " + cfg.table + "{0} - {1} of {2}",
142 "emptyMsg": "No " + cfg.table + " found",
153 "cls": "x-btn-text-icon",
154 "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
156 "|click": "function()\n"+
158 " if (!_this.dialog) return;\n" +
159 " _this.dialog.show( { id : 0 } , function() {\n"+
160 " _this.grid.footer.onClick('first');\n"+
164 "|xns": "Roo.Toolbar"
169 "cls": "x-btn-text-icon",
170 "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
172 "|click": "function()\n"+
174 " var s = _this.grid.getSelectionModel().getSelections();\n"+
175 " if (!s.length || (s.length > 1)) {\n"+
176 " Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n"+
179 " if (!_this.dialog) return;\n" +
180 " _this.dialog.show(s[0].data, function() {\n"+
181 " _this.grid.footer.onClick('first');\n"+
187 "|xns": "Roo.Toolbar"
191 "cls": "x-btn-text-icon",
192 "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
195 "|click": "function()\n"+
197 " Pman.genericDelete(_this, '" + cfg.table + "'); \n"+
201 "|xns": "Roo.Toolbar"
210 'Roo.data.Store' : function(cfg, old)
217 var jreader = _t['Roo.data.JsonReader'](cfg);
222 '.builderCfg' : Roo.encode(cfg),
224 '|sortInfo' : "{ field : '" + cfg.cols_ex[0] + "', direction: 'ASC' }",
228 "xtype": "HttpProxy",
230 "|url": "baseURL + '/Roo/" +cfg.table + ".php'",
240 'Roo.data.JsonReader' : function(cfg, old)
242 // simple version to start with..
252 Roo.each(cfg.cols, function(cc) {
253 var ty = typeof(_t.typemap[cc.ctype]) == 'undefined' ? 'string' : _t.typemap[cc.ctype];
254 if (cc.ctype == 'string' ) {
255 fields.push(cc.column);
258 fields.push({ name : cc.column, type : _t.typemap[cc.ctype]} );
265 xtype : "JsonReader",
266 totalProperty : "total",
268 '.builderCfg' : Roo.encode(cfg),
270 id : 'id', // maybe no..
272 '|fields' : JSON.stringify(fields, null,4).replace(/"/g,"'")
277 'Roo.grid.ColumnModel' : function(rcfg, old)
279 // simple version to start with..
280 var ty = typeof(this.typemap[rcfg.ctype]) == 'undefined' ? 'string' : this.typemap[rcfg.ctype];
282 // some special kludges..
283 // remove table prefix..
285 var desc = rcfg.columnshort;
286 if (desc.substring(0, rcfg.table.length+1) == rcfg.table+'_') {
287 desc = desc.substring(rcfg.table.length+1);
289 desc = desc.replace(/_id$/, '');
298 "xtype": "ColumnModel",
299 '.builderCfg' : Roo.encode(rcfg),
300 "header": rcfg.desc.length ? rcfg.desc : desc,
301 "width": ty == 'string' ? 200 : 75,
302 "dataIndex": rcfg.column,
303 "|renderer": ty != 'date' ?
304 "function(v) { return String.format('{0}', v); }" :
305 "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }" , // special for date
307 "*prop": "colModel[]"
313 'Roo.LayoutDialog' : function(rcfg, old)
315 // simple version to start with..
318 var frmCfg = _t['Roo.form.Form'](cfg, old);
320 // loop through the cols..
321 // we need a 'display column' for each of these.
322 // we could also have a 'renderer'...
327 var formHeight = (frmCfg.items.length * 40) + 40; // work out from number of form ites..
330 xtype : 'LayoutDialog',
332 '.builderCfg' : Roo.encode(rcfg),
339 title: "Edit / Create " + rcfg.table,
346 "xtype": "LayoutRegion",
351 "xtype": "ContentPanel",
359 "click": "function (_self, e)\n{\n _this.dialog.hide();\n}"
361 "*prop": "buttons[]",
368 "click": "function (_self, e)\n{\n // do some checks?\n \n \n _this.dialog.el.mask(\"Saving\");\n _this.form.doAction(\"submit\");\n\n}"
370 "*prop": "buttons[]",
378 'Roo.form.Form' : function(rcfg, old)
380 // simple version to start with..
383 var formElements = [];
385 var fcombo = function(cn) {
387 Roo.each(rcfg.cols_ux, function(n) {
388 if (n.substring(0,cn.length) == cn) {
396 Roo.each(rcfg.cols, function(cc) {
398 var ty = typeof(_t.typemap[cc.ctype]) == 'undefined' ? 'string' : _t.typemap[cc.ctype];
400 if (ty == 'string' ) {
401 formElements.push( _t['Roo.form.TextField'](cc, {}));
405 formElements.push( _t['Roo.form.DateField'](cc, {}));
409 formElements.push( _t['Roo.form.ComboBox'](cc, {}));
414 fields.push({ name : cc.column, type : _t.typemap[cc.ctype]} );
423 "|actioncomplete" : "function(_self,action)\n"+
425 " if (action.type == 'setdata') {\n"+
426 " //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
429 " if (action.type == 'load') {\n"+
432 " if (action.type =='submit') {\n"+
434 " _this.dialog.hide();\n"+
436 " if (_this.callback) {\n"+
437 " _this.callback.call(_this, _this.form.getValues());\n"+
439 " _this.form.reset();\n"+
444 "|rendered" : "function (form)\n"+
446 " _this.form= form;\n"+
450 style : "margin:10px;",
451 "|url" : "baseURL + '/Roo/" + rcfg.table + ".php'",