resources/Editors/Editor.Roo.LayoutDialog.bjs
authorAlan Knowles <alan@roojs.com>
Fri, 24 Apr 2015 08:46:53 +0000 (16:46 +0800)
committerAlan Knowles <alan@roojs.com>
Fri, 24 Apr 2015 08:46:53 +0000 (16:46 +0800)
resources/Editors/Editor.Roo.LayoutDialog.js

resources/Editors/Editor.Roo.LayoutDialog.bjs
resources/Editors/Editor.Roo.LayoutDialog.js

index 371d142..35036be 100644 (file)
@@ -23,7 +23,7 @@
     "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
    },
    "| function loadData" : "function(data) { \n\n     alert(\"IPC:TEST:\" + JSON.stringify(data,null,4));\n    var ar = [];\n    for (var k in data) { \n        var r = data[k];\n        var has_s = typeof(r.relates_to_schema) != 'undefined'\n        ar.push([ !has_s , r.Field, r.Type,  r.Field, 100] );\n        if (!has_s) {\n            continue;\n        }\n        /*\n        for (var kk in r.relates_to_schema) {         \n            var rr = r.relates_to_schema[kk];\n            if (rr.Field == r.relates_to_col) {\n                continue;\n            }\n            ar.push([ false, r.Field + '_'+ rr.Field, rr.Type,  rr.Field, 100] );\n        }\n        */\n    }\n    this.schema = data;\n    alert(\"IPC:TEST:\" + JSON.stringify(ar));\n    this.grid.dataSource.loadData(ar);\n}",
-   "| function toBJS" : "function() { \n\n// convert the selected cells into a BJS data ready to send back to the UI..\n   \n    this.table = \"XXX\";\n    this.firstTxtCol = \"XXX\";\n   \n    \n    var jreader = {};\n    var     colmodel = [];\n    this.grid.dataSource.each(function(rec) {\n        if (!rec.data.active) {\n            return;\n        }\n        \n        \n        \n        colmodel.push({\n            \"xtype\": \"ColumnModel\",\n            \"header\": rec.data.title,\n            \"width\":  rec.data.width * 1,\n            \"dataIndex\": rec.data.dataIndex,\n            \"|renderer\": !rec.data.type.match(/date/i) ? \n                    \"function(v) { return String.format('{0}', v); }\" :\n                    \"function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }\" , // special for date\n            \"|xns\": \"Roo.grid\",\n            \"*prop\": \"cm[]\"\n        });\n    });\n    \n    \n    \n\n    alert(\"IPC:OUT:\" + JSON.stringify({\n            \"closable\": false,\n            \"collapsible\": false,\n            \"height\": formHeight,\n            \"resizable\": false,\n            \"title\": \"Edit / Create \" + this.table,\n            \"width\": 400,\n            \"modal\" : true,\n            \"xtype\": \"LayoutDialog\",\n            \"|xns\": \"Roo\",\n            \"items\": [\n                {\n                    \"|xns\": \"Roo\",\n                    \"xtype\": \"LayoutRegion\",\n                    \"*prop\": \"center\"\n                },\n                {\n                    \"region\": \"center\",\n                    \"xtype\": \"ContentPanel\",\n                    \"|xns\": \"Roo\",\n                    \"items\": [\n                        frmCfg\n                    ]\n                },\n                \n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    _this.dialog.hide();\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Cancel\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                },\n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    // do some checks?\\n     \\n    \\n    _this.dialog.el.mask(\\\"Saving\\\");\\n    _this.form.doAction(\\\"submit\\\");\\n\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Save\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                }\n            ]\n        \n        \n        \n    }, null, 4));\n\n}",
+   "| function toBJS" : "function() { \n\n// convert the selected cells into a BJS data ready to send back to the UI..\n   \n    this.table = \"XXX\";\n    this.firstTxtCol = \"XXX\";\n   \n    \n    var jreader = {};\n    var  colmodel = [];\n    this.grid.dataSource.each(function(rec) {\n        if (!rec.data.active) {\n            return;\n        }\n        \n        \n        \n        colmodel.push({\n            \"xtype\": \"ColumnModel\",\n            \"header\": rec.data.title,\n            \"width\":  rec.data.width * 1,\n            \"dataIndex\": rec.data.dataIndex,\n            \"|renderer\": !rec.data.type.match(/date/i) ? \n                    \"function(v) { return String.format('{0}', v); }\" :\n                    \"function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }\" , // special for date\n            \"|xns\": \"Roo.grid\",\n            \"*prop\": \"cm[]\"\n        });\n    });\n    \n     var frmCfg = \n    {\n        '|xns' : 'Roo.form',\n        xtype : \"Form\",\n        listeners : {\n            \"|actioncomplete\" : \"function(_self,action)\\n\"+\n                \"{\\n\"+\n                \"    if (action.type == 'setdata') {\\n\"+\n                \"       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\\n\"+\n                \"       return;\\n\"+\n                \"    }\\n\"+\n                \"    if (action.type == 'load') {\\n\"+\n                \"        return;\\n\"+\n                \"    }\\n\"+\n                \"    if (action.type =='submit') {\\n\"+\n                \"    \\n\"+\n                \"        _this.dialog.hide();\\n\"+\n                \"    \\n\"+\n                \"         if (_this.callback) {\\n\"+\n                \"            _this.callback.call(_this, action.result.data);\\n\"+\n                \"         }\\n\"+\n                \"         _this.form.reset();\\n\"+\n                \"         return;\\n\"+\n                \"    }\\n\"+\n                \"}\\n\",\n            \n            \"|rendered\" : \"function (form)\\n\"+\n                \"{\\n\"+\n                \"    _this.form= form;\\n\"+\n                \"}\\n\"\n        },\n        method : \"POST\",\n        style : \"margin:10px;\",\n        \"|url\" : \"baseURL + '/Roo/\" + reader.table + \".php'\",\n        items : formElements\n    };\n    \n\n    alert(\"IPC:OUT:\" + JSON.stringify({\n            \"closable\": false,\n            \"collapsible\": false,\n            \"height\": formHeight,\n            \"resizable\": false,\n            \"title\": \"Edit / Create \" + this.table,\n            \"width\": 400,\n            \"modal\" : true,\n            \"xtype\": \"LayoutDialog\",\n            \"|xns\": \"Roo\",\n            \"items\": [\n                {\n                    \"|xns\": \"Roo\",\n                    \"xtype\": \"LayoutRegion\",\n                    \"*prop\": \"center\"\n                },\n                {\n                    \"region\": \"center\",\n                    \"xtype\": \"ContentPanel\",\n                    \"|xns\": \"Roo\",\n                    \"items\": [\n                        frmCfg\n                    ]\n                },\n                \n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    _this.dialog.hide();\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Cancel\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                },\n                {\n                    \"listeners\": {\n                        \"click\": \"function (_self, e)\\n{\\n    // do some checks?\\n     \\n    \\n    _this.dialog.el.mask(\\\"Saving\\\");\\n    _this.form.doAction(\\\"submit\\\");\\n\\n}\"\n                    },\n                    \"*prop\": \"buttons[]\",\n                    \"text\": \"Save\",\n                    \"xtype\": \"Button\",\n                    \"|xns\": \"Roo\"\n                }\n            ]\n        \n        \n        \n    }, null, 4));\n\n}",
    "fitToframe" : true,
    "background" : false,
    "region" : "center",
index 4168b99..354265c 100644 (file)
@@ -338,7 +338,7 @@ Editor.Roo.LayoutDialog = new Roo.XComponent({
       
        
        var jreader = {};
-       var     colmodel = [];
+       var  colmodel = [];
        this.grid.dataSource.each(function(rec) {
            if (!rec.data.active) {
                return;
@@ -359,7 +359,42 @@ Editor.Roo.LayoutDialog = new Roo.XComponent({
            });
        });
        
-       
+        var frmCfg = 
+       {
+           '|xns' : 'Roo.form',
+           xtype : "Form",
+           listeners : {
+               "|actioncomplete" : "function(_self,action)\n"+
+                   "{\n"+
+                   "    if (action.type == 'setdata') {\n"+
+                   "       //this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n"+
+                   "       return;\n"+
+                   "    }\n"+
+                   "    if (action.type == 'load') {\n"+
+                   "        return;\n"+
+                   "    }\n"+
+                   "    if (action.type =='submit') {\n"+
+                   "    \n"+
+                   "        _this.dialog.hide();\n"+
+                   "    \n"+
+                   "         if (_this.callback) {\n"+
+                   "            _this.callback.call(_this, action.result.data);\n"+
+                   "         }\n"+
+                   "         _this.form.reset();\n"+
+                   "         return;\n"+
+                   "    }\n"+
+                   "}\n",
+               
+               "|rendered" : "function (form)\n"+
+                   "{\n"+
+                   "    _this.form= form;\n"+
+                   "}\n"
+           },
+           method : "POST",
+           style : "margin:10px;",
+           "|url" : "baseURL + '/Roo/" + reader.table + ".php'",
+           items : formElements
+       };
        
    
        alert("IPC:OUT:" + JSON.stringify({