Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.bjs
1 {
2     "id": "roo-file-183",
3     "name": "Pman.Dialog.CoreNotifyRecur",
4     "parent": "",
5     "title": "",
6     "path": "/home/edward/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, // default...\n        \n        method_id : _this.data.method_id, // default...\n        method_id_display_name : _this.data.method_id_display_name, // default...        \n        \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",
116                                     "header": "Type",
117                                     "width": 120,
118                                     "xtype": "ColumnModel",
119                                     "|renderer": "function(v,x,r) {\n     return String.format('{0}', r.data.method_id_display_name); \n}",
120                                     "|xns": "Roo.grid",
121                                     "items": [
122                                         {
123                                             "|xns": "Roo.grid",
124                                             "xtype": "GridEditor",
125                                             "*prop": "editor",
126                                             "items": [
127                                                 {
128                                                     "*prop": "field",
129                                                     "allowBlank": "false",
130                                                     "displayField": "display_name",
131                                                     "editable": false,
132                                                     "emptyText": "Select Type",
133                                                     "fieldLabel": "core_enum",
134                                                     "forceSelection": true,
135                                                     "hiddenName": "method_id",
136                                                     "listWidth": 400,
137                                                     "loadingText": "Searching...",
138                                                     "name": "method_id_display_name",
139                                                     "pageSize": 20,
140                                                     "qtip": "Select core_enum",
141                                                     "selectOnFocus": true,
142                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>",
143                                                     "triggerAction": "all",
144                                                     "typeAhead": true,
145                                                     "valueField": "id",
146                                                     "width": 300,
147                                                     "xtype": "ComboBox",
148                                                     "|xns": "Roo.form",
149                                                     "items": [
150                                                         {
151                                                             "listeners": {
152                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params.etype = 'core_notify_recur';\n}\n"
153                                                             },
154                                                             "*prop": "store",
155                                                             "remoteSort": true,
156                                                             "xtype": "Store",
157                                                             "|sortInfo": "{ direction : 'ASC', field: 'id' }",
158                                                             "|xns": "Roo.data",
159                                                             "items": [
160                                                                 {
161                                                                     "*prop": "proxy",
162                                                                     "xtype": "HttpProxy",
163                                                                     "method": "GET",
164                                                                     "|xns": "Roo.data",
165                                                                     "|url": "baseURL + '/Roo/core_enum.php'"
166                                                                 },
167                                                                 {
168                                                                     "*prop": "reader",
169                                                                     "xtype": "JsonReader",
170                                                                     "|xns": "Roo.data",
171                                                                     "id": "id",
172                                                                     "root": "data",
173                                                                     "totalProperty": "total",
174                                                                     "|fields": "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"etype\",\"type\":\"string\"}]"
175                                                                 }
176                                                             ]
177                                                         }
178                                                     ]
179                                                 }
180                                             ]
181                                         }
182                                     ]
183                                 },
184                                 {
185                                     "*prop": "colModel[]",
186                                     "dataIndex": "dtstart",
187                                     "header": "From",
188                                     "width": 75,
189                                     "xtype": "ColumnModel",
190                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
191                                     "|xns": "Roo.grid",
192                                     "items": [
193                                         {
194                                             "|xns": "Roo.grid",
195                                             "xtype": "GridEditor",
196                                             "*prop": "editor",
197                                             "items": [
198                                                 {
199                                                     "|xns": "Roo.form",
200                                                     "xtype": "DateField",
201                                                     "*prop": "field"
202                                                 }
203                                             ]
204                                         }
205                                     ]
206                                 },
207                                 {
208                                     "*prop": "colModel[]",
209                                     "dataIndex": "dtend",
210                                     "header": "Until",
211                                     "width": 75,
212                                     "xtype": "ColumnModel",
213                                     "|renderer": "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
214                                     "|xns": "Roo.grid",
215                                     "items": [
216                                         {
217                                             "|xns": "Roo.grid",
218                                             "xtype": "GridEditor",
219                                             "*prop": "editor",
220                                             "items": [
221                                                 {
222                                                     "|xns": "Roo.form",
223                                                     "xtype": "DateField",
224                                                     "*prop": "field"
225                                                 }
226                                             ]
227                                         }
228                                     ]
229                                 },
230                                 {
231                                     "*prop": "colModel[]",
232                                     "dataIndex": "freq_day",
233                                     "header": "on day(s)",
234                                     "width": 100,
235                                     "xtype": "ColumnModel",
236                                     "|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}",
237                                     "|xns": "Roo.grid",
238                                     "items": [
239                                         {
240                                             "|xns": "Roo.grid",
241                                             "xtype": "GridEditor",
242                                             "*prop": "editor",
243                                             "items": [
244                                                 {
245                                                     "*prop": "field",
246                                                     "allowBlank": false,
247                                                     "displayField": "title",
248                                                     "editable": false,
249                                                     "fieldLabel": "Country",
250                                                     "hiddenName": "freq_day",
251                                                     "listWidth": 300,
252                                                     "mode": "local",
253                                                     "name": "freq_day_name",
254                                                     "pageSize": 40,
255                                                     "triggerAction": "all",
256                                                     "valueField": "code",
257                                                     "xtype": "ComboCheck",
258                                                     "|xns": "Roo.form",
259                                                     "items": [
260                                                         {
261                                                             "*prop": "store",
262                                                             "xtype": "SimpleStore",
263                                                             "|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})()",
264                                                             "|fields": "['code', 'title']",
265                                                             "|sortInfo": "{ field : 'title', direction: 'ASC' }",
266                                                             "|xns": "Roo.data"
267                                                         }
268                                                     ]
269                                                 }
270                                             ]
271                                         }
272                                     ]
273                                 },
274                                 {
275                                     "*prop": "colModel[]",
276                                     "dataIndex": "freq_hour",
277                                     "header": "at Hour(s)",
278                                     "width": 250,
279                                     "xtype": "ColumnModel",
280                                     "|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}",
281                                     "|xns": "Roo.grid",
282                                     "items": [
283                                         {
284                                             "|xns": "Roo.grid",
285                                             "xtype": "GridEditor",
286                                             "*prop": "editor",
287                                             "items": [
288                                                 {
289                                                     "*prop": "field",
290                                                     "allowBlank": false,
291                                                     "displayField": "title",
292                                                     "editable": false,
293                                                     "fieldLabel": "Country",
294                                                     "hiddenName": "freq_hour",
295                                                     "listWidth": 300,
296                                                     "mode": "local",
297                                                     "name": "freq_hour_name",
298                                                     "pageSize": 40,
299                                                     "triggerAction": "all",
300                                                     "valueField": "code",
301                                                     "xtype": "ComboCheck",
302                                                     "|xns": "Roo.form",
303                                                     "items": [
304                                                         {
305                                                             "*prop": "store",
306                                                             "xtype": "SimpleStore",
307                                                             "|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})()",
308                                                             "|fields": "['code', 'title']",
309                                                             "|sortInfo": "{ field : 'title', direction: 'ASC' }",
310                                                             "|xns": "Roo.data"
311                                                         }
312                                                     ]
313                                                 }
314                                             ]
315                                         }
316                                     ]
317                                 },
318                                 {
319                                     "*prop": "colModel[]",
320                                     "dataIndex": "tz",
321                                     "header": "Timezone",
322                                     "width": 100,
323                                     "xtype": "ColumnModel",
324                                     "|renderer": "function(v) { return String.format('{0}', v); }",
325                                     "|xns": "Roo.grid",
326                                     "items": [
327                                         {
328                                             "|xns": "Roo.grid",
329                                             "xtype": "GridEditor",
330                                             "*prop": "editor",
331                                             "items": [
332                                                 {
333                                                     "*prop": "field",
334                                                     "allowBlank": "false",
335                                                     "displayField": "tz",
336                                                     "editable": true,
337                                                     "emptyText": "Select timezone",
338                                                     "fieldLabel": "core_enum",
339                                                     "forceSelection": true,
340                                                     "listWidth": 400,
341                                                     "loadingText": "Searching...",
342                                                     "minChars": 2,
343                                                     "name": "tz",
344                                                     "pageSize": 999,
345                                                     "qtip": "Select timezone",
346                                                     "queryParam": "q",
347                                                     "selectOnFocus": true,
348                                                     "tpl": "<div class=\"x-grid-cell-text x-btn button\"><b>{tz}</b> </div>",
349                                                     "triggerAction": "all",
350                                                     "typeAhead": true,
351                                                     "width": 300,
352                                                     "xtype": "ComboBox",
353                                                     "|xns": "Roo.form",
354                                                     "items": [
355                                                         {
356                                                             "listeners": {
357                                                                 "|beforeload": "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
358                                                             },
359                                                             "*prop": "store",
360                                                             "remoteSort": true,
361                                                             "xtype": "Store",
362                                                             "|sortInfo": "{ direction : 'ASC', field: 'tz' }",
363                                                             "|xns": "Roo.data",
364                                                             "items": [
365                                                                 {
366                                                                     "*prop": "proxy",
367                                                                     "method": "GET",
368                                                                     "xtype": "HttpProxy",
369                                                                     "|url": "baseURL + '/Core/I18n/Timezone.php'\n",
370                                                                     "|xns": "Roo.data"
371                                                                 },
372                                                                 {
373                                                                     "*prop": "reader",
374                                                                     "id": "id",
375                                                                     "root": "data",
376                                                                     "totalProperty": "total",
377                                                                     "xtype": "JsonReader",
378                                                                     "|fields": "[{\"name\":\"tz\",\"type\":\"string\"}]",
379                                                                     "|xns": "Roo.data"
380                                                                 }
381                                                             ]
382                                                         }
383                                                     ]
384                                                 }
385                                             ]
386                                         }
387                                     ]
388                                 },
389                                 {
390                                     "*prop": "colModel[]",
391                                     "dataIndex": "last_event_id",
392                                     "header": "Last Sent",
393                                     "width": 75,
394                                     "xtype": "ColumnModel",
395                                     "|renderer": "function(v) { return String.format('{0}', v ? v : 'never'); }",
396                                     "|xns": "Roo.grid"
397                                 }
398                             ]
399                         }
400                     ]
401                 },
402                 {
403                     "listeners": {
404                         "click": "function (_self, e)\n{\n    _this.dialog.hide();\n}"
405                     },
406                     "*prop": "buttons[]",
407                     "text": "Done",
408                     "xtype": "Button",
409                     "|xns": "Roo"
410                 }
411             ]
412         }
413     ],
414     "permname": "",
415     "modOrder": "001"
416 }