Pman.Dialog.CoreNotifyRecur.bjs
[Pman.Core] / Pman.Dialog.CoreNotifyRecur.bjs
1 {
2  "name" : "Pman.Dialog.CoreNotifyRecur",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/edward/gitlive/Pman.Core/Pman.Dialog.CoreNotifyRecur.bjs",
6  "permname" : "",
7  "modOrder" : "001",
8  "strings" : {
9   "3728af837fe70019577ddb0ed7125ee5" : "Until",
10   "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
11   "023a5dfa857c4aa0156e6685231a1dbd" : "Select Type",
12   "6c768695a8efb18436d5b7b4374cdb45" : "Select core_enum",
13   "157e432ec303efd7d537b653cb255ccc" : "on day(s)",
14   "236df51bb0e6416236e255b528346fca" : "Timezone",
15   "44c68bed631ff6e62aecc4a4d32176e6" : "Select timezone",
16   "867343577fa1f33caa632a19543bd252" : "Keywords",
17   "1243daf593fa297e07ab03bf06d925af" : "Searching...",
18   "b26686c0a708faee42861d8b905e882e" : "Last Sent",
19   "c1d32776cd2d2afcd2c45a52f58679f4" : "Modify Recurrent Notifications",
20   "5da618e8e4b89c66fe86e32cdafde142" : "From",
21   "ce527d7432bab413730f25c794648e46" : "at Hour(s)",
22   "c7179f16884513c990b6cbf44aef7fc3" : "core_notify_recur",
23   "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
24   "a1fa27779242b4902f7ae3bdd5c6d508" : "Type",
25   "f92965e2c8a7afb3c1b9a5c09a263636" : "Done"
26  },
27  "items" : [
28   {
29    "listeners" : {
30     "show" : "function (_self)\n{\n    _this.grid.ds.load({});\n}"
31    },
32    "modal" : true,
33    "title" : "Modify Recurrent Notifications",
34    "xtype" : "LayoutDialog",
35    "width" : 800,
36    "$ xns" : "Roo",
37    "resizable" : false,
38    "height" : 550,
39    "items" : [
40     {
41      "loadOnce" : true,
42      "autoScroll" : true,
43      "xtype" : "LayoutRegion",
44      "$ xns" : "Roo",
45      "* prop" : "center"
46     },
47     {
48      "listeners" : {
49       "|activate" : "function() {\n _this.panel = this;\n    if (_this.grid) {\n//        _this.grid.footer.onClick('first');\n    }\n}"
50      },
51      "fitToFrame" : true,
52      "background" : false,
53      "region" : "center",
54      "title" : "core_notify_recur",
55      "xtype" : "GridPanel",
56      "fitContainer" : true,
57      "$ xns" : "Roo",
58      "tableName" : "core_notify_recur",
59      "items" : [
60       {
61        "listeners" : {
62         "cellclick" : "function (_self, rowIndex, columnIndex, e)\n{\n    var di = this.colModel.getDataIndex(columnIndex);\n    if (di != 'keyword_filters') {\n        return;\n    }\n    \n    Pman.Dialog.CoreNotifyRecurKeywords.show({}, function(res){\n        Roo.log(res);\n    });\n    \n}",
63         "|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}",
64         "afteredit" : "function (e)\n{\n   e.record.commit();\n}"
65        },
66        "autoExpandColumn" : "freq_day",
67        "xtype" : "EditorGrid",
68        "loadMask" : true,
69        "clicksToEdit" : 1,
70        "$ xns" : "Roo.grid",
71        "* prop" : "grid",
72        "items" : [
73         {
74          "listeners" : {
75           "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}",
76           "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}"
77          },
78          "xtype" : "Store",
79          "remoteSort" : true,
80          "$ sortInfo" : "{ field : 'freq', direction: 'ASC' }",
81          "$ xns" : "Roo.data",
82          "* prop" : "dataSource",
83          "items" : [
84           {
85            "$ url" : "baseURL + '/Roo/core_notify_recur.php'",
86            "method" : "GET",
87            "xtype" : "HttpProxy",
88            "$ xns" : "Roo.data",
89            "* prop" : "proxy"
90           },
91           {
92            "id" : "id",
93            "root" : "data",
94            "xtype" : "JsonReader",
95            "$ 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]",
96            "$ xns" : "Roo.data",
97            "* prop" : "reader",
98            "totalProperty" : "total"
99           }
100          ]
101         },
102         {
103          "xtype" : "Toolbar",
104          "$ xns" : "Roo",
105          "* prop" : "toolbar",
106          "items" : [
107           {
108            "listeners" : {
109             "|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"
110            },
111            "text" : "Add",
112            "xtype" : "Button",
113            "cls" : "x-btn-text-icon",
114            "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
115            "$ xns" : "Roo.Toolbar"
116           },
117           {
118            "xtype" : "Fill",
119            "$ xns" : "Roo.Toolbar"
120           },
121           {
122            "listeners" : {
123             "|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        "
124            },
125            "text" : "Delete",
126            "xtype" : "Button",
127            "cls" : "x-btn-text-icon",
128            "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
129            "$ xns" : "Roo.Toolbar"
130           }
131          ]
132         },
133         {
134          "xtype" : "ColumnModel",
135          "header" : "Type",
136          "width" : 120,
137          "$ renderer" : "function(v,x,r) {\n     return String.format('{0}', r.data.method_id_display_name); \n}",
138          "$ xns" : "Roo.grid",
139          "* prop" : "colModel[]",
140          "dataIndex" : "method_id",
141          "items" : [
142           {
143            "xtype" : "GridEditor",
144            "$ xns" : "Roo.grid",
145            "* prop" : "editor",
146            "items" : [
147             {
148              "listWidth" : 400,
149              "triggerAction" : "all",
150              "fieldLabel" : "core_enum",
151              "forceSelection" : true,
152              "selectOnFocus" : true,
153              "pageSize" : 20,
154              "displayField" : "display_name",
155              "emptyText" : "Select Type",
156              "hiddenName" : "method_id",
157              "valueField" : "id",
158              "xtype" : "ComboBox",
159              "allowBlank" : false,
160              "typeAhead" : true,
161              "editable" : false,
162              "width" : 300,
163              "$ xns" : "Roo.form",
164              "* prop" : "field",
165              "name" : "method_id_display_name",
166              "qtip" : "Select core_enum",
167              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>",
168              "loadingText" : "Searching...",
169              "items" : [
170               {
171                "listeners" : {
172                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params.etype = 'core_notify_recur';\n}\n"
173                },
174                "xtype" : "Store",
175                "remoteSort" : true,
176                "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
177                "$ xns" : "Roo.data",
178                "* prop" : "store",
179                "items" : [
180                 {
181                  "$ url" : "baseURL + '/Roo/core_enum.php'",
182                  "method" : "GET",
183                  "xtype" : "HttpProxy",
184                  "$ xns" : "Roo.data",
185                  "* prop" : "proxy"
186                 },
187                 {
188                  "id" : "id",
189                  "root" : "data",
190                  "xtype" : "JsonReader",
191                  "$ xns" : "Roo.data",
192                  "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"etype\",\"type\":\"string\"}]",
193                  "* prop" : "reader",
194                  "totalProperty" : "total"
195                 }
196                ]
197               }
198              ]
199             }
200            ]
201           }
202          ]
203         },
204         {
205          "xtype" : "ColumnModel",
206          "header" : "From",
207          "width" : 75,
208          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
209          "$ xns" : "Roo.grid",
210          "* prop" : "colModel[]",
211          "dataIndex" : "dtstart",
212          "items" : [
213           {
214            "xtype" : "GridEditor",
215            "$ xns" : "Roo.grid",
216            "* prop" : "editor",
217            "items" : [
218             {
219              "xtype" : "DateField",
220              "$ xns" : "Roo.form",
221              "* prop" : "field"
222             }
223            ]
224           }
225          ]
226         },
227         {
228          "xtype" : "ColumnModel",
229          "header" : "Until",
230          "width" : 75,
231          "$ renderer" : "function(v) { return String.format('{0}', v ? v.format('d/M/Y') : ''); }",
232          "$ xns" : "Roo.grid",
233          "* prop" : "colModel[]",
234          "dataIndex" : "dtend",
235          "items" : [
236           {
237            "xtype" : "GridEditor",
238            "$ xns" : "Roo.grid",
239            "* prop" : "editor",
240            "items" : [
241             {
242              "xtype" : "DateField",
243              "$ xns" : "Roo.form",
244              "* prop" : "field"
245             }
246            ]
247           }
248          ]
249         },
250         {
251          "xtype" : "ColumnModel",
252          "header" : "on day(s)",
253          "width" : 100,
254          "$ 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}",
255          "$ xns" : "Roo.grid",
256          "* prop" : "colModel[]",
257          "dataIndex" : "freq_day",
258          "items" : [
259           {
260            "xtype" : "GridEditor",
261            "$ xns" : "Roo.grid",
262            "* prop" : "editor",
263            "items" : [
264             {
265              "listWidth" : 300,
266              "triggerAction" : "all",
267              "fieldLabel" : "Country",
268              "pageSize" : 40,
269              "displayField" : "title",
270              "hiddenName" : "freq_day",
271              "valueField" : "code",
272              "xtype" : "ComboCheck",
273              "allowBlank" : false,
274              "editable" : false,
275              "$ xns" : "Roo.form",
276              "* prop" : "field",
277              "mode" : "local",
278              "name" : "freq_day_name",
279              "items" : [
280               {
281                "| 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})()",
282                "xtype" : "SimpleStore",
283                "$ fields" : "['code', 'title']",
284                "$ sortInfo" : "{ field : 'title', direction: 'ASC' }",
285                "$ xns" : "Roo.data",
286                "* prop" : "store"
287               }
288              ]
289             }
290            ]
291           }
292          ]
293         },
294         {
295          "xtype" : "ColumnModel",
296          "header" : "at Hour(s)",
297          "width" : 100,
298          "$ 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}",
299          "$ xns" : "Roo.grid",
300          "* prop" : "colModel[]",
301          "dataIndex" : "freq_hour",
302          "items" : [
303           {
304            "xtype" : "GridEditor",
305            "$ xns" : "Roo.grid",
306            "* prop" : "editor",
307            "items" : [
308             {
309              "listWidth" : 300,
310              "triggerAction" : "all",
311              "fieldLabel" : "Country",
312              "pageSize" : 40,
313              "displayField" : "title",
314              "hiddenName" : "freq_hour",
315              "valueField" : "code",
316              "xtype" : "ComboCheck",
317              "allowBlank" : false,
318              "editable" : false,
319              "$ xns" : "Roo.form",
320              "* prop" : "field",
321              "mode" : "local",
322              "name" : "freq_hour_name",
323              "items" : [
324               {
325                "| 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})()",
326                "xtype" : "SimpleStore",
327                "$ fields" : "['code', 'title']",
328                "$ sortInfo" : "{ field : 'title', direction: 'ASC' }",
329                "$ xns" : "Roo.data",
330                "* prop" : "store"
331               }
332              ]
333             }
334            ]
335           }
336          ]
337         },
338         {
339          "xtype" : "ColumnModel",
340          "header" : "Timezone",
341          "width" : 100,
342          "$ renderer" : "function(v) { return String.format('{0}', v); }",
343          "$ xns" : "Roo.grid",
344          "* prop" : "colModel[]",
345          "dataIndex" : "tz",
346          "items" : [
347           {
348            "xtype" : "GridEditor",
349            "$ xns" : "Roo.grid",
350            "* prop" : "editor",
351            "items" : [
352             {
353              "listWidth" : 400,
354              "triggerAction" : "all",
355              "fieldLabel" : "core_enum",
356              "forceSelection" : true,
357              "selectOnFocus" : true,
358              "pageSize" : 999,
359              "displayField" : "tz",
360              "emptyText" : "Select timezone",
361              "minChars" : 2,
362              "xtype" : "ComboBox",
363              "allowBlank" : false,
364              "typeAhead" : true,
365              "editable" : true,
366              "width" : 300,
367              "$ xns" : "Roo.form",
368              "* prop" : "field",
369              "name" : "tz",
370              "qtip" : "Select timezone",
371              "queryParam" : "q",
372              "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{tz}</b> </div>",
373              "loadingText" : "Searching...",
374              "items" : [
375               {
376                "listeners" : {
377                 "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n}\n"
378                },
379                "xtype" : "Store",
380                "remoteSort" : true,
381                "$ sortInfo" : "{ direction : 'ASC', field: 'tz' }",
382                "$ xns" : "Roo.data",
383                "* prop" : "store",
384                "items" : [
385                 {
386                  "$ url" : "baseURL + '/Core/I18n/Timezone.php'\n",
387                  "xtype" : "HttpProxy",
388                  "method" : "GET",
389                  "$ xns" : "Roo.data",
390                  "* prop" : "proxy"
391                 },
392                 {
393                  "id" : "id",
394                  "root" : "data",
395                  "xtype" : "JsonReader",
396                  "$ fields" : "[{\"name\":\"tz\",\"type\":\"string\"}]",
397                  "$ xns" : "Roo.data",
398                  "* prop" : "reader",
399                  "totalProperty" : "total"
400                 }
401                ]
402               }
403              ]
404             }
405            ]
406           }
407          ]
408         },
409         {
410          "xtype" : "ColumnModel",
411          "width" : 75,
412          "header" : "Last Sent",
413          "$ renderer" : "function(v) { return String.format('{0}', v ? v : 'never'); }",
414          "$ xns" : "Roo.grid",
415          "* prop" : "colModel[]",
416          "dataIndex" : "last_event_id"
417         },
418         {
419          "xtype" : "ColumnModel",
420          "header" : "Keywords",
421          "width" : 75,
422          "$ renderer" : "function(v) { return String.format('{0}', v ? v : ''); }",
423          "$ xns" : "Roo.grid",
424          "* prop" : "colModel[]",
425          "dataIndex" : "keyword_filters"
426         }
427        ]
428       }
429      ]
430     },
431     {
432      "listeners" : {
433       "click" : "function (_self, e)\n{\n    _this.dialog.hide();\n}"
434      },
435      "text" : "Done",
436      "xtype" : "Button",
437      "$ xns" : "Roo",
438      "* prop" : "buttons[]"
439     }
440    ]
441   }
442  ]
443 }