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