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