Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.bjs
1 {
2     "id": "roo-file-100",
3     "name": "Pman.Dialog.CoreNotifyRecur",
4     "parent": "",
5     "title": "",
6     "path": "/home/alan/gitlive/Pman.Core/Pman.Dialog.CoreNotifyRecur.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "show": "function (_self)\n{\n    _this.grid.ds.load({});\n}"
11             },
12             "height": 550,
13             "modal": true,
14             "resizable": false,
15             "title": "Modify Recurrent Notifications",
16             "width": 800,
17             "xtype": "LayoutDialog",
18             "|xns": "Roo",
19             "items": [
20                 {
21                     "*prop": "center",
22                     "autoScroll": true,
23                     "loadOnce": true,
24                     "xtype": "LayoutRegion",
25                     "|xns": "Roo"
26                 },
27                 {
28                     "listeners": {
29                         "|activate": "function() {\n _this.panel = this;\n    if (_this.grid) {\n//        _this.grid.footer.onClick('first');\n    }\n}"
30                     },
31                     "background": false,
32                     "fitContainer": true,
33                     "fitToFrame": true,
34                     "region": "center",
35                     "tableName": "core_notify_recur",
36                     "title": "core_notify_recur",
37                     "xtype": "GridPanel",
38                     "|xns": "Roo",
39                     "items": [
40                         {
41                             "listeners": {
42                                 "|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}",
43                                 "|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",
44                                 "afteredit": "function (e)\n{\n   e.record.commit();\n}"
45                             },
46                             "*prop": "grid",
47                             "autoExpandColumn": "freq_day",
48                             "clicksToEdit": 1,
49                             "loadMask": true,
50                             "xtype": "EditorGrid",
51                             "|xns": "Roo.grid",
52                             "items": [
53                                 {
54                                     "listeners": {
55                                         "update": "function (_self, record, operation)\n{\n    //Roo.log(operation);\n    if (operation != 'commit') {\n        return;\n    }\n    var p = Roo.apply({}, record.data);\n    p.dtstart = record.data.dtstart.format('Y-m-d');\n    p.dtend = record.data.dtend.format('Y-m-d');    \n    \n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Core_notify_recur',\n        method :'POST',\n        params : p,\n        success : function(data)\n        {\n            //Roo.log(data);\n            record.set('id', data.data.id);\n        },\n        failure : function() {\n            Roo.MessageBox.alert(\"Error\", \"There was a problem saving\");\n        }\n    });\n       \n    \n    \n}",
56                                         "beforeload": "function (_self, o)\n{\n    if (!_this.data) {\n        return false;\n    }\n    o.params =  Roo.apply(o.params || {}, {\n        person_id : _this.data.person_id,\n        onid : _this.data.onid,\n        ontable : _this.data.ontable,\n        method : _this.data.method\n    });\n        \n}"
57                                     },
58                                     "*prop": "dataSource",
59                                     "remoteSort": true,
60                                     "xtype": "Store",
61                                     "|sortInfo": "{ field : 'freq', direction: 'ASC' }",
62                                     "|xns": "Roo.data",
63                                     "items": [
64                                         {
65                                             "*prop": "proxy",
66                                             "xtype": "HttpProxy",
67                                             "method": "GET",
68                                             "|url": "baseURL + '/Roo/core_notify_recur.php'",
69                                             "|xns": "Roo.data"
70                                         },
71                                         {
72                                             "*prop": "reader",
73                                             "id": "id",
74                                             "root": "data",
75                                             "totalProperty": "total",
76                                             "xtype": "JsonReader",
77                                             "|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]",
78                                             "|xns": "Roo.data"
79                                         }
80                                     ]
81                                 },
82                                 {
83                                     "*prop": "toolbar",
84                                     "xtype": "Toolbar",
85                                     "|xns": "Roo",
86                                     "items": [
87                                         {
88                                             "listeners": {
89                                                 "|click": "function()\n{\n    var grid = _this.grid;\n    var r = grid.getDataSource().reader.newRow({\n    // defaults..\n        person_id : _this.data.person_id,\n        dtstart : new Date(),\n        dtend : Date.parseDate('2050-01-01', 'Y-m-d'),\n        tz : 'Asia/Hong_Kong',\n        onid : _this.data.onid,\n        ontable : _this.data.ontable,\n        method : _this.data.method,\n        last_event_id : 0,\n        freq_day_name : '',\n        freq_hour_name : '',\n        freq_name : ''\n        \n    \n    });\n    grid.stopEditing();\n    grid.getDataSource().insert(0, r); \n    grid.startEditing(0, 2); \n    \n\n}\n"
90                                             },
91                                             "cls": "x-btn-text-icon",
92                                             "text": "Add",
93                                             "xtype": "Button",
94                                             "|icon": "Roo.rootURL + 'images/default/dd/drop-add.gif'",
95                                             "|xns": "Roo.Toolbar"
96                                         },
97                                         {
98                                             "|xns": "Roo.Toolbar",
99                                             "xtype": "Fill"
100                                         },
101                                         {
102                                             "listeners": {
103                                                 "|click": "function()\n{\n     _this.grid.stopEditing();\n     var s = _this.grid.selModel.getSelectedCell();\n     if (!s) {\n        Roo.MessageBox.alert(\"Error\", \"Select row\");\n        return;\n    }\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/core_notify_recur',\n        method : 'POST',\n        params : {\n            _delete : _this.grid.ds.getAt(s[0]).data.id\n        }, \n        success : function() {\n            _this.grid.ds.load({});\n        },\n        failure : function() {\n            Roo.MessageBox.alert(\"Error\", \"Deleting failed - try reloading\");\n        }\n   });\n    \n}\n        "
104                                             },
105                                             "cls": "x-btn-text-icon",
106                                             "text": "Delete",
107                                             "xtype": "Button",
108                                             "|icon": "rootURL + '/Pman/templates/images/trash.gif'",
109                                             "|xns": "Roo.Toolbar"
110                                         }
111                                     ]
112                                 },
113                                 {
114                                     "*prop": "colModel[]",
115                                     "dataIndex": "method_id_title",
116                                     "header": "From",
117                                     "width": 75,
118                                     "xtype": "ColumnModel",
119                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
120                                     "|xns": "Roo.grid",
121                                     "items": [
122                                         {
123                                             "|xns": "Roo.grid",
124                                             "xtype": "GridEditor",
125                                             "*prop": "editor",
126                                             "items": [
127                                                 {
128                                                     "|xns": "Roo.form",
129                                                     "xtype": "DateField",
130                                                     "*prop": "field"
131                                                 }
132                                             ]
133                                         }
134                                     ]
135                                 },
136                                 {
137                                     "*prop": "colModel[]",
138                                     "dataIndex": "dtstart",
139                                     "header": "From",
140                                     "width": 75,
141                                     "xtype": "ColumnModel",
142                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
143                                     "|xns": "Roo.grid",
144                                     "items": [
145                                         {
146                                             "|xns": "Roo.grid",
147                                             "xtype": "GridEditor",
148                                             "*prop": "editor",
149                                             "items": [
150                                                 {
151                                                     "|xns": "Roo.form",
152                                                     "xtype": "DateField",
153                                                     "*prop": "field"
154                                                 }
155                                             ]
156                                         }
157                                     ]
158                                 },
159                                 {
160                                     "*prop": "colModel[]",
161                                     "dataIndex": "dtend",
162                                     "header": "Until",
163                                     "width": 75,
164                                     "xtype": "ColumnModel",
165                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
166                                     "|xns": "Roo.grid",
167                                     "items": [
168                                         {
169                                             "|xns": "Roo.grid",
170                                             "xtype": "GridEditor",
171                                             "*prop": "editor",
172                                             "items": [
173                                                 {
174                                                     "|xns": "Roo.form",
175                                                     "xtype": "DateField",
176                                                     "*prop": "field"
177                                                 }
178                                             ]
179                                         }
180                                     ]
181                                 },
182                                 {
183                                     "*prop": "colModel[]",
184                                     "dataIndex": "freq_day",
185                                     "header": "on day(s)",
186                                     "width": 100,
187                                     "xtype": "ColumnModel",
188                                     "|renderer": "function(v,x,r) { \n    \n    if (v.length) {\n     \n        var cm = _this.grid.colModel;\n       \n        var ci = cm.getColumnByDataIndex(this.name);\n       \n         var tv = [];\n        var vals = Roo.decode(v);\n        Roo.each(vals, function(k) {\n            var r = this.findRecord(this.valueField, k);\n            if(r){\n                tv.push(r.data[this.displayField]);\n            }else if(this.valueNotFoundText !== undefined){\n                tv.push( this.valueNotFoundText );\n            }\n        },ci.editor.field);\n\n        r.data[this.name + '_name'] = tv.join(', ');\n        return String.format('{0}',tv.join(', '));\n\n        \n    \n    }\n    r.data[this.name + '_name'] = '';\n    return String.format('{0}', r.data.freq_day_name || v); \n    \n}",
189                                     "|xns": "Roo.grid",
190                                     "items": [
191                                         {
192                                             "|xns": "Roo.grid",
193                                             "xtype": "GridEditor",
194                                             "*prop": "editor",
195                                             "items": [
196                                                 {
197                                                     "*prop": "field",
198                                                     "allowBlank": false,
199                                                     "displayField": "title",
200                                                     "editable": false,
201                                                     "fieldLabel": "Country",
202                                                     "hiddenName": "freq_day",
203                                                     "listWidth": 300,
204                                                     "mode": "local",
205                                                     "name": "freq_day_name",
206                                                     "pageSize": 40,
207                                                     "triggerAction": "all",
208                                                     "valueField": "code",
209                                                     "xtype": "ComboCheck",
210                                                     "|xns": "Roo.form",
211                                                     "items": [
212                                                         {
213                                                             "*prop": "store",
214                                                             "xtype": "SimpleStore",
215                                                             "|data": "(function() { \n    var ret = [];\n    Roo.each(Date.dayNames, function(d) {\n        ret.push([ d.substring(0,3).toUpperCase(), d ]);\n    });\n    return ret;\n})()",
216                                                             "|fields": "['code', 'title']",
217                                                             "|sortInfo": "{ field : 'title', direction: 'ASC' }",
218                                                             "|xns": "Roo.data"
219                                                         }
220                                                     ]
221                                                 }
222                                             ]
223                                         }
224                                     ]
225                                 },
226                                 {
227                                     "*prop": "colModel[]",
228                                     "dataIndex": "freq_hour",
229                                     "header": "at Hour(s)",
230                                     "width": 250,
231                                     "xtype": "ColumnModel",
232                                     "|renderer": "function(v,x,r) { \n    \n \n    if (v.length) {\n     \n        var cm = _this.grid.colModel;\n       \n        var ci = cm.getColumnByDataIndex(this.name);\n       \n         var tv = [];\n        var vals = Roo.decode(v);\n        Roo.each(vals, function(k) {\n            var r = this.findRecord(this.valueField, k);\n            if(r){\n                tv.push(r.data[this.displayField]);\n            }else if(this.valueNotFoundText !== undefined){\n                tv.push( this.valueNotFoundText );\n            }\n        },ci.editor.field);\n\n         r.data[this.name + '_name'] = tv.join(', ');\n        return String.format('{0}',tv.join(', '));\n\n        \n    \n    }\n        r.data[this.name + '_name'] = '';\n    return String.format('{0}', r.data.freq_hour_name || v); \n    \n}",
233                                     "|xns": "Roo.grid",
234                                     "items": [
235                                         {
236                                             "|xns": "Roo.grid",
237                                             "xtype": "GridEditor",
238                                             "*prop": "editor",
239                                             "items": [
240                                                 {
241                                                     "*prop": "field",
242                                                     "allowBlank": false,
243                                                     "displayField": "title",
244                                                     "editable": false,
245                                                     "fieldLabel": "Country",
246                                                     "hiddenName": "freq_hour",
247                                                     "listWidth": 300,
248                                                     "mode": "local",
249                                                     "name": "freq_hour_name",
250                                                     "pageSize": 40,
251                                                     "triggerAction": "all",
252                                                     "valueField": "code",
253                                                     "xtype": "ComboCheck",
254                                                     "|xns": "Roo.form",
255                                                     "items": [
256                                                         {
257                                                             "*prop": "store",
258                                                             "xtype": "SimpleStore",
259                                                             "|data": "(function() { \n    var ret = [];\n    for (var i = 5; i < 25; i++) {\n        var h = i < 10 ? ('0' + i) : i;\n        var mer = i < 12 || i > 23 ? 'am' : 'pm';\n        var dh = i < 13 ? i : i-12;\n        \n        ret.push([ h+':00', dh+':00' + mer ]);\n        ret.push([ h+':30', dh+':30' + mer ]);        \n    }\n    return ret;\n})()",
260                                                             "|fields": "['code', 'title']",
261                                                             "|sortInfo": "{ field : 'title', direction: 'ASC' }",
262                                                             "|xns": "Roo.data"
263                                                         }
264                                                     ]
265                                                 }
266                                             ]
267                                         }
268                                     ]
269                                 },
270                                 {
271                                     "*prop": "colModel[]",
272                                     "dataIndex": "tz",
273                                     "header": "Timezone",
274                                     "width": 100,
275                                     "xtype": "ColumnModel",
276                                     "|renderer": "function(v) { return String.format('{0}', v); }",
277                                     "|xns": "Roo.grid",
278                                     "items": [
279                                         {
280                                             "|xns": "Roo.grid",
281                                             "xtype": "GridEditor",
282                                             "*prop": "editor",
283                                             "items": [
284                                                 {
285                                                     "*prop": "field",
286                                                     "allowBlank": "false",
287                                                     "displayField": "tz",
288                                                     "editable": true,
289                                                     "emptyText": "Select timezone",
290                                                     "fieldLabel": "core_enum",
291                                                     "forceSelection": true,
292                                                     "listWidth": 400,
293                                                     "loadingText": "Searching...",
294                                                     "minChars": 2,
295                                                     "name": "tz",
296                                                     "pageSize": 999,
297                                                     "qtip": "Select timezone",
298                                                     "queryParam": "q",
299                                                     "selectOnFocus": true,
300                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{tz}</b> </div>",
301                                                     "triggerAction": "all",
302                                                     "typeAhead": true,
303                                                     "width": 300,
304                                                     "xtype": "ComboBox",
305                                                     "|xns": "Roo.form",
306                                                     "items": [
307                                                         {
308                                                             "listeners": {
309                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
310                                                             },
311                                                             "*prop": "store",
312                                                             "remoteSort": true,
313                                                             "xtype": "Store",
314                                                             "|sortInfo": "{ direction : 'ASC', field: 'tz' }",
315                                                             "|xns": "Roo.data",
316                                                             "items": [
317                                                                 {
318                                                                     "*prop": "proxy",
319                                                                     "method": "GET",
320                                                                     "xtype": "HttpProxy",
321                                                                     "|url": "baseURL + '/Core/I18n/Timezone.php'\n",
322                                                                     "|xns": "Roo.data"
323                                                                 },
324                                                                 {
325                                                                     "*prop": "reader",
326                                                                     "id": "id",
327                                                                     "root": "data",
328                                                                     "totalProperty": "total",
329                                                                     "xtype": "JsonReader",
330                                                                     "|fields": "[{\"name\":\"tz\",\"type\":\"string\"}]",
331                                                                     "|xns": "Roo.data"
332                                                                 }
333                                                             ]
334                                                         }
335                                                     ]
336                                                 }
337                                             ]
338                                         }
339                                     ]
340                                 },
341                                 {
342                                     "*prop": "colModel[]",
343                                     "dataIndex": "last_event_id",
344                                     "header": "Last Sent",
345                                     "width": 75,
346                                     "xtype": "ColumnModel",
347                                     "|renderer": "function(v) { return String.format('{0}', v ? v : 'never'); }",
348                                     "|xns": "Roo.grid"
349                                 }
350                             ]
351                         }
352                     ]
353                 },
354                 {
355                     "listeners": {
356                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
357                     },
358                     "*prop": "buttons[]",
359                     "text": "Done",
360                     "xtype": "Button",
361                     "|xns": "Roo"
362                 }
363             ]
364         }
365     ],
366     "permname": "",
367     "modOrder": "001"
368 }