Pman.Dialog.CoreNotifyRefer.bjs
authorAlan Knowles <alan@roojs.com>
Wed, 16 May 2012 04:35:16 +0000 (12:35 +0800)
committerAlan Knowles <alan@roojs.com>
Wed, 16 May 2012 04:35:16 +0000 (12:35 +0800)
Pman.Dialog.CoreNotifyRefer.js

Pman.Dialog.CoreNotifyRefer.bjs
Pman.Dialog.CoreNotifyRefer.js

index 0272329..c2fc929 100644 (file)
@@ -6,31 +6,44 @@
     "path": "/home/alan/gitlive/Pman.Core/Pman.Dialog.CoreNotifyRefer.bjs",
     "items": [
         {
-            "|xns": "Roo",
+            "height": 500,
+            "modal": true,
+            "resizable": false,
+            "title": "Modify Recurrent Notifications",
+            "width": 700,
             "xtype": "LayoutDialog",
+            "|xns": "Roo",
             "items": [
                 {
-                    "|xns": "Roo",
-                    "xtype": "GridPanel",
-                    "title": "core_notify_recur",
-                    "fitToframe": true,
-                    "fitContainer": true,
-                    "tableName": "core_notify_recur",
-                    "background": true,
-                    "region": "center",
+                    "*prop": "center",
+                    "autoScroll": true,
+                    "loadOnce": true,
+                    "xtype": "LayoutRegion",
+                    "|xns": "Roo"
+                },
+                {
                     "listeners": {
                         "|activate": "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
                     },
+                    "background": false,
+                    "fitContainer": true,
+                    "fitToFrame": true,
+                    "region": "center",
+                    "tableName": "core_notify_recur",
+                    "title": "core_notify_recur",
+                    "xtype": "GridPanel",
+                    "|xns": "Roo",
                     "items": [
                         {
-                            "*prop": "grid",
-                            "xtype": "Grid",
-                            "autoExpandColumn": "freq",
-                            "loadMask": true,
                             "listeners": {
                                 "|render": "function() \n{\n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       this.footer.onClick('first');\n    }\n}",
                                 "|rowdblclick": "function (_self, rowIndex, e)\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( this.getDataSource().getAt(rowIndex).data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n}\n"
                             },
+                            "*prop": "grid",
+                            "autoExpandColumn": "freq",
+                            "clicksToEdit": 1,
+                            "loadMask": true,
+                            "xtype": "EditorGrid",
                             "|xns": "Roo.grid",
                             "items": [
                                 {
                                             "|xns": "Roo.data"
                                         },
                                         {
-                                            "|xns": "Roo.data",
-                                            "xtype": "JsonReader",
-                                            "totalProperty": "total",
-                                            "root": "data",
                                             "*prop": "reader",
                                             "id": "id",
-                                            "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'dtstart',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'dtend',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'tz',\n        'type': 'float'\n    },\n    {\n        'name': 'last_applied_dt',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'freq',\n        'type': 'string'\n    },\n    {\n        'name': 'freq_day',\n        'type': 'string'\n    },\n    {\n        'name': 'freq_hour',\n        'type': 'string'\n    },\n    {\n        'name': 'last_event_id',\n        'type': 'int'\n    },\n    {\n        'name': 'method',\n        'type': 'string'\n    }\n]"
+                                            "root": "data",
+                                            "totalProperty": "total",
+                                            "xtype": "JsonReader",
+                                            "|fields": "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'person_id',\n        'type': 'int'\n    },\n    {\n        'name': 'dtstart',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'dtend',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'tz',\n        'type': 'float'\n    },\n    {\n        'name': 'last_applied_dt',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'freq',\n        'type': 'string'\n    },\n    {\n        'name': 'freq_day',\n        'type': 'string'\n    },\n    {\n        'name': 'freq_hour',\n        'type': 'string'\n    },\n    {\n        'name': 'last_event_id',\n        'type': 'int'\n    },\n    {\n        'name': 'method',\n        'type': 'string'\n    }\n]",
+                                            "|xns": "Roo.data"
                                         }
                                     ]
                                 },
                                     "|xns": "Roo",
                                     "items": [
                                         {
+                                            "listeners": {
+                                                "|click": "function()\n{\n    var grid = _this.grid;\n    var r = grid.getDataSource().reader.newRow();\n    grid.stopEditing();\ngrid.getDataSource().insert(0, r); \ngrid.startEditing(0, 0); \n\n}\n"
+                                            },
+                                            "cls": "x-btn-text-icon",
                                             "text": "Add",
                                             "xtype": "Button",
-                                            "cls": "x-btn-text-icon",
                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
-                                            "listeners": {
-                                                "|click": "function()\n{\n    if (!_this.dialog) return;\n    _this.dialog.show( { id : 0 } , function() {\n        _this.grid.footer.onClick('first');\n   }); \n}\n"
-                                            },
                                             "|xns": "Roo.Toolbar"
                                         },
                                         {
-                                            "text": "Edit",
-                                            "xtype": "Button",
-                                            "cls": "x-btn-text-icon",
-                                            "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
-                                            "listeners": {
-                                                "|click": "function()\n{\n    var s = _this.grid.getSelectionModel().getSelections();\n    if (!s.length || (s.length > 1))  {\n        Roo.MessageBox.alert(\"Error\", s.length ? \"Select only one Row\" : \"Select a Row\");\n        return;\n    }\n    if (!_this.dialog) return;\n    _this.dialog.show(s[0].data, function() {\n        _this.grid.footer.onClick('first');\n    }); \n    \n}\n"
-                                            },
-                                            "|xns": "Roo.Toolbar"
+                                            "|xns": "Roo.Toolbar",
+                                            "xtype": "Fill"
                                         },
                                         {
                                             "text": "Delete",
                                     ]
                                 },
                                 {
-                                    "xtype": "ColumnModel",
-                                    "header": "Id",
-                                    "width": 75,
-                                    "dataIndex": "id",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Person",
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "dtstart",
+                                    "header": "From",
                                     "width": 75,
-                                    "dataIndex": "person_id",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
                                     "xtype": "ColumnModel",
-                                    "header": "Dtstart",
-                                    "width": 75,
-                                    "dataIndex": "dtstart",
                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
                                     "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "items": [
+                                        {
+                                            "|xns": "Roo.grid",
+                                            "xtype": "GridEditor",
+                                            "*prop": "editor",
+                                            "items": [
+                                                {
+                                                    "|xns": "Roo.form",
+                                                    "xtype": "DateField",
+                                                    "*prop": "field"
+                                                }
+                                            ]
+                                        }
+                                    ]
                                 },
                                 {
-                                    "xtype": "ColumnModel",
-                                    "header": "Dtend",
-                                    "width": 75,
+                                    "*prop": "colModel[]",
                                     "dataIndex": "dtend",
+                                    "header": "Until",
+                                    "width": 75,
+                                    "xtype": "ColumnModel",
                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
                                     "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "items": [
+                                        {
+                                            "|xns": "Roo.grid",
+                                            "xtype": "GridEditor",
+                                            "*prop": "editor",
+                                            "items": [
+                                                {
+                                                    "|xns": "Roo.form",
+                                                    "xtype": "DateField",
+                                                    "*prop": "field"
+                                                }
+                                            ]
+                                        }
+                                    ]
                                 },
                                 {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "freq",
+                                    "header": "Frequency",
+                                    "width": 100,
                                     "xtype": "ColumnModel",
-                                    "header": "Tz",
-                                    "width": 75,
-                                    "dataIndex": "tz",
                                     "|renderer": "function(v) { return String.format('{0}', v); }",
                                     "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
-                                },
-                                {
-                                    "xtype": "ColumnModel",
-                                    "header": "Last applied dt",
-                                    "width": 75,
-                                    "dataIndex": "last_applied_dt",
-                                    "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "items": [
+                                        {
+                                            "|xns": "Roo.grid",
+                                            "xtype": "GridEditor",
+                                            "*prop": "editor",
+                                            "items": [
+                                                {
+                                                    "*prop": "field",
+                                                    "allowBlank": false,
+                                                    "displayField": "title",
+                                                    "editable": false,
+                                                    "fieldLabel": "Country",
+                                                    "hiddenName": "country",
+                                                    "listWidth": 200,
+                                                    "mode": "local",
+                                                    "name": "country_name",
+                                                    "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> </div>",
+                                                    "triggerAction": "all",
+                                                    "valueField": "code",
+                                                    "width": 200,
+                                                    "xtype": "ComboBox",
+                                                    "|xns": "Roo.form",
+                                                    "items": [
+                                                        {
+                                                            "*prop": "store",
+                                                            "xtype": "SimpleStore",
+                                                            "|data": "[ \n    [ 'HOURLY' , 'Hourly at' ] ,\n       [ 'DAILY' , 'Daily at'] ,\n        [ 'WEEKLY' , 'Weekly at'] ,\n         [ 'Montly' , 'Montly at'] \n]",
+                                                            "|fields": "['code', 'title']",
+                                                            "|sortInfo": "{ field : 'title', direction: 'ASC' }",
+                                                            "|xns": "Roo.data"
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                    ]
                                 },
                                 {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "freq_day",
+                                    "header": "on day(s)",
+                                    "width": 100,
                                     "xtype": "ColumnModel",
-                                    "header": "Freq",
-                                    "width": 200,
-                                    "dataIndex": "freq",
                                     "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "|xns": "Roo.grid"
                                 },
                                 {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "freq_hour",
+                                    "header": "at Hour(s)",
+                                    "width": 100,
                                     "xtype": "ColumnModel",
-                                    "header": "Freq day",
-                                    "width": 200,
-                                    "dataIndex": "freq_day",
                                     "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "|xns": "Roo.grid"
                                 },
                                 {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "tz",
+                                    "header": "Timezone",
+                                    "width": 75,
                                     "xtype": "ColumnModel",
-                                    "header": "Freq hour",
-                                    "width": 200,
-                                    "dataIndex": "freq_hour",
                                     "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "|xns": "Roo.grid"
                                 },
                                 {
                                     "xtype": "ColumnModel",
                                     "*prop": "colModel[]"
                                 },
                                 {
+                                    "*prop": "colModel[]",
+                                    "dataIndex": "last_applied_dt",
+                                    "header": "Message Last sent",
+                                    "width": 75,
                                     "xtype": "ColumnModel",
-                                    "header": "Method",
-                                    "width": 200,
-                                    "dataIndex": "method",
-                                    "|renderer": "function(v) { return String.format('{0}', v); }",
-                                    "|xns": "Roo.grid",
-                                    "*prop": "colModel[]"
+                                    "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
+                                    "|xns": "Roo.grid"
                                 }
                             ]
                         }
                     ]
+                },
+                {
+                    "*prop": "buttons[]",
+                    "text": "Done",
+                    "xtype": "Button",
+                    "|xns": "Roo"
                 }
             ]
         }
index 5fbd1f9..5a8764f 100644 (file)
@@ -30,16 +30,15 @@ Pman.Dialog.CoreNotifyRefer = {
         this.dialog = Roo.factory({
             xtype: 'LayoutDialog',
             xns: Roo,
+            height : 500,
+            modal : true,
+            resizable : false,
+            title : "Modify Recurrent Notifications",
+            width : 700,
             items : [
                 {
                     xtype: 'GridPanel',
                     xns: Roo,
-                    title : "core_notify_recur",
-                    fitToframe : true,
-                    fitContainer : true,
-                    tableName : 'core_notify_recur',
-                    background : true,
-                    region : 'center',
                     listeners : {
                         activate : function() {
                             _this.panel = this;
@@ -48,11 +47,15 @@ Pman.Dialog.CoreNotifyRefer = {
                             }
                         }
                     },
+                    background : false,
+                    fitContainer : true,
+                    fitToFrame : true,
+                    region : 'center',
+                    tableName : 'core_notify_recur',
+                    title : "core_notify_recur",
                     grid : {
-                        xtype: 'Grid',
+                        xtype: 'EditorGrid',
                         xns: Roo.grid,
-                        autoExpandColumn : 'freq',
-                        loadMask : true,
                         listeners : {
                             render : function() 
                             {
@@ -70,6 +73,9 @@ Pman.Dialog.CoreNotifyRefer = {
                                 }); 
                             }
                         },
+                        autoExpandColumn : 'freq',
+                        clicksToEdit : 1,
+                        loadMask : true,
                         dataSource : {
                             xtype: 'Store',
                             xns: Roo.data,
@@ -84,9 +90,9 @@ Pman.Dialog.CoreNotifyRefer = {
                             reader : {
                                 xtype: 'JsonReader',
                                 xns: Roo.data,
-                                totalProperty : 'total',
-                                root : 'data',
                                 id : 'id',
+                                root : 'data',
+                                totalProperty : 'total',
                                 fields : [
                                     {
                                         'name': 'id',
@@ -153,40 +159,24 @@ Pman.Dialog.CoreNotifyRefer = {
                                 {
                                     xtype: 'Button',
                                     xns: Roo.Toolbar,
-                                    text : "Add",
-                                    cls : 'x-btn-text-icon',
-                                    icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
                                     listeners : {
                                         click : function()
                                         {
-                                            if (!_this.dialog) return;
-                                            _this.dialog.show( { id : 0 } , function() {
-                                                _this.grid.footer.onClick('first');
-                                           }); 
+                                            var grid = _this.grid;
+                                            var r = grid.getDataSource().reader.newRow();
+                                            grid.stopEditing();
+                                        grid.getDataSource().insert(0, r); 
+                                        grid.startEditing(0, 0); 
+                                        
                                         }
-                                    }
+                                    },
+                                    cls : 'x-btn-text-icon',
+                                    text : "Add",
+                                    icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
                                 },
                                 {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    text : "Edit",
-                                    cls : 'x-btn-text-icon',
-                                    icon : Roo.rootURL + 'images/default/tree/leaf.gif',
-                                    listeners : {
-                                        click : function()
-                                        {
-                                            var s = _this.grid.getSelectionModel().getSelections();
-                                            if (!s.length || (s.length > 1))  {
-                                                Roo.MessageBox.alert("Error", s.length ? "Select only one Row" : "Select a Row");
-                                                return;
-                                            }
-                                            if (!_this.dialog) return;
-                                            _this.dialog.show(s[0].data, function() {
-                                                _this.grid.footer.onClick('first');
-                                            }); 
-                                            
-                                        }
-                                    }
+                                    xtype: 'Fill',
+                                    xns: Roo.Toolbar
                                 },
                                 {
                                     xtype: 'Button',
@@ -207,73 +197,97 @@ Pman.Dialog.CoreNotifyRefer = {
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Id',
-                                width : 75,
-                                dataIndex : 'id',
-                                renderer : function(v) { return String.format('{0}', v); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                header : 'Person',
-                                width : 75,
-                                dataIndex : 'person_id',
-                                renderer : function(v) { return String.format('{0}', v); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                header : 'Dtstart',
-                                width : 75,
                                 dataIndex : 'dtstart',
-                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
-                            },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                header : 'Dtend',
+                                header : 'From',
                                 width : 75,
-                                dataIndex : 'dtend',
-                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
+                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+                                editor : {
+                                    xtype: 'GridEditor',
+                                    xns: Roo.grid,
+                                    field : {
+                                        xtype: 'DateField',
+                                        xns: Roo.form
+                                    }
+                                }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Tz',
+                                dataIndex : 'dtend',
+                                header : 'Until',
                                 width : 75,
-                                dataIndex : 'tz',
-                                renderer : function(v) { return String.format('{0}', v); }
+                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); },
+                                editor : {
+                                    xtype: 'GridEditor',
+                                    xns: Roo.grid,
+                                    field : {
+                                        xtype: 'DateField',
+                                        xns: Roo.form
+                                    }
+                                }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Last applied dt',
-                                width : 75,
-                                dataIndex : 'last_applied_dt',
-                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
+                                dataIndex : 'freq',
+                                header : 'Frequency',
+                                width : 100,
+                                renderer : function(v) { return String.format('{0}', v); },
+                                editor : {
+                                    xtype: 'GridEditor',
+                                    xns: Roo.grid,
+                                    field : {
+                                        xtype: 'ComboBox',
+                                        xns: Roo.form,
+                                        allowBlank : false,
+                                        displayField : 'title',
+                                        editable : false,
+                                        fieldLabel : 'Country',
+                                        hiddenName : 'country',
+                                        listWidth : 200,
+                                        mode : 'local',
+                                        name : 'country_name',
+                                        tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
+                                        triggerAction : 'all',
+                                        valueField : 'code',
+                                        width : 200,
+                                        store : {
+                                            xtype: 'SimpleStore',
+                                            xns: Roo.data,
+                                            data : [ 
+                                                [ 'HOURLY' , 'Hourly at' ] ,
+                                                   [ 'DAILY' , 'Daily at'] ,
+                                                    [ 'WEEKLY' , 'Weekly at'] ,
+                                                     [ 'Montly' , 'Montly at'] 
+                                            ],
+                                            fields : ['code', 'title'],
+                                            sortInfo : { field : 'title', direction: 'ASC' }
+                                        }
+                                    }
+                                }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Freq',
-                                width : 200,
-                                dataIndex : 'freq',
+                                dataIndex : 'freq_day',
+                                header : 'on day(s)',
+                                width : 100,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Freq day',
-                                width : 200,
-                                dataIndex : 'freq_day',
+                                dataIndex : 'freq_hour',
+                                header : 'at Hour(s)',
+                                width : 100,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Freq hour',
-                                width : 200,
-                                dataIndex : 'freq_hour',
+                                dataIndex : 'tz',
+                                header : 'Timezone',
+                                width : 75,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
                             {
@@ -287,14 +301,27 @@ Pman.Dialog.CoreNotifyRefer = {
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
-                                header : 'Method',
-                                width : 200,
-                                dataIndex : 'method',
-                                renderer : function(v) { return String.format('{0}', v); }
+                                dataIndex : 'last_applied_dt',
+                                header : 'Message Last sent',
+                                width : 75,
+                                renderer : function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }
                             }
                         ]
                     }
                 }
+            ],
+            center : {
+                xtype: 'LayoutRegion',
+                xns: Roo,
+                autoScroll : true,
+                loadOnce : true
+            },
+            buttons : [
+                {
+                    xtype: 'Button',
+                    xns: Roo,
+                    text : "Done"
+                }
             ]
         });
     }