php7 fixes
[Pman.Builder] / Pman.Builder.js
1 /**
2  *
3  *
4  * Core utils for builder..
5  *
6  */
7
8
9
10
11
12 Pman.Builder = {
13  
14     typemap : {
15         'bool' : 'boolean',
16         
17         'date' : 'date',
18         'datetime' : 'date',
19         'time' : 'string', //bogus
20         
21         'int' : 'int',
22         'int4' : 'int',
23         'bigint' : 'int',
24         'tinyint' : 'int',
25         'smallint' : 'int',
26         'timestamp' : 'number',
27         
28         'double' : 'float',
29         'decimal' : 'float',
30         'float' : 'float',
31         
32         'char' : 'string',
33         'varchar' : 'string',
34         'text' : 'string',
35         'longtext' : 'string',
36         'tinytext' : 'string',
37         'mediumtext' : 'string',
38         'enum' : 'string',
39         
40         'blob' : 'string'
41     },
42     /**
43      * auto builders..
44      * @param {Object} cfg the configuration
45      * @param {Object} old the previous def...
46      *  - table
47      *  - cols_ex : [ name, name]
48      *  - cols : [ 
49      *      { column : name
50      *        ctype : ctype,
51      *        desc : desc
52      *      }
53      *   ]
54      * 
55      */
56  
57     save : function(cb, sid) 
58     {
59        // first see if first element has a name.. - we can not save otherwise..
60         var t = Pman.Tab.BuilderTree.tree;
61         if (!t.root.elConfig.name.length) {
62             Roo.MessageBox.alert("Error", "No name set for form");
63             return;
64         }
65      
66         sid = (typeof(sid) == 'undefined') ? 
67              (Pman.Tab.BuilderTop.filesel.lastData ? Pman.Tab.BuilderTop.filesel.lastData.id : 0) : sid;
68         
69
70         var js = Pman.Builder.Tree.toJS();
71         var render = new Pman.Builder.JsRender(js); 
72          
73         // console.log(js);
74         // console.log(json);
75         
76         // check the select box to see if that has been set... - save it with that id..
77         
78         //var _this = this;
79         
80         // should we try and render first???
81         var html = '';
82         try {
83              html = Pman.Builder.View.frameToHTML();
84             
85         } catch (e) {
86             
87         }
88         
89         
90         
91         new Pman.Request({
92             url: baseURL + '/Roo/Builder_part.php',
93             method : 'POST',
94             params : {
95                 json : Roo.encode(js, null, 4),
96                 jsource : render.toSource(),
97                 html : html,
98                 name :   js.name,
99                 module_id : Pman.Tab.BuilderTop.modsel.getValue(),
100                 id : sid
101             }, 
102             success : function(res) {
103                 var data = res.data;
104                 // set the fileSel!!
105                 console.log(data);
106                 if (data) {
107                     Pman.Tab.BuilderTop.filesel.setFromData(data);
108                     
109                 }
110                 data.jsource = render.toSource();
111                 data.json = Roo.encode(js, null, 4);
112                 data.html = html; 
113                 
114                 
115                 if (data && cb) {
116                      cb.call(Pman.Tab.BuilderTop,data);
117                     // ??? _this.postCode(data);
118                 }
119
120             }
121         });
122 }
123  
124     
125 }