Pman.Tab.BAdminEmailTemplates.bjs
[Pman.BAdmin] / Pman.Tab.BAdminEmailTemplates.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Tab');
6
7 Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
8
9  _strings : {
10   'cdb6b6bab1fd18b9dbfe3fb84a5d34ae' :"<i class=\"fa fa-search\"></i>",
11   'cae905999a2ad1dfb8f4eae0e8cda73b' :"From Name<br/>Email",
12   '98d2ee61ddce0c7666297d81639914f1' :"To / BCC Group",
13   '73ea6b4441cdced246d236b22c8f991c' :"HTML File",
14   '694e249c3a9503141fa5ce3fb71d5477' :"<i class=\"fa fa-edit\"></i> Edit",
15   'cffbd822c38679e2fbf11cc182c945e5' :"search for email template",
16   '9e11143e29a031212f2cdefcf61f39e9' :"View Message",
17   'f49559cda3fb906fbd7736f8b8a0e37d' :"Email Template",
18   '27a7146e1e1890e289bc7fad72876831' :"<i class=\"fa fa-plus\"></i> Create a template",
19   'cd6df251f262cc64514b25f04aecf3c8' :"<i class=\"fa fa-clipboard\"></i> Copy",
20   'ed807858fcb68abdd180481f1fcba5c5' :"<i class=\"fa fa-trash\"></i> Delete",
21   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
22   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
23   'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
24   'e6b391a8d2c4d45902a23a8b6585703d' :"URL"
25  },
26
27   part     :  ["BAdmin", "EmailTemplates" ],
28   order    : '004-Pman.Tab.BAdminEmailTemplates',
29   region   : 'center',
30   parent   : 'Pman.Tab.BAdmin',
31   name     : "Pman.Tab.BAdminEmailTemplates",
32   disabled : false, 
33   permname : '', 
34   _tree : function(_data)
35   {
36    var _this = this;
37    var MODULE = this;
38    return {
39    xtype : 'Nest',
40    background : true,
41    title : _this._strings['f49559cda3fb906fbd7736f8b8a0e37d'] /* Email Template */,
42    xns : Roo.bootstrap.panel,
43    '|xns' : 'Roo.bootstrap.panel',
44    layout : {
45     xtype : 'Border',
46     xns : Roo.bootstrap.layout,
47     '|xns' : 'Roo.bootstrap.layout',
48     center : {
49      xtype : 'Region',
50      hideTabs : true,
51      tabPosition : 'top',
52      xns : Roo.bootstrap.layout,
53      '|xns' : 'Roo.bootstrap.layout'
54     },
55     south : {
56      xtype : 'Region',
57      autoScroll : true,
58      height : 200,
59      hideTabs : true,
60      split : true,
61      tabPosition : 'top',
62      titlebar : true,
63      xns : Roo.bootstrap.layout,
64      '|xns' : 'Roo.bootstrap.layout'
65     },
66     items  : [
67      {
68       xtype : 'Grid',
69       background : false,
70       closable : false,
71       fitContainer : true,
72       fitToFrame : true,
73       region : 'center',
74       listeners : {
75        activate : function (_self)
76         {
77             _this.edit_btn.hide();
78             _this.copy_btn.hide();
79             _this.delete_btn.hide();
80             
81             if (_this.table) {
82                 _this.table.footer.onClick('first');
83             }
84             
85         },
86        render : function (_self)
87         {
88             _this.grid = this;
89         }
90       },
91       xns : Roo.bootstrap.panel,
92       '|xns' : 'Roo.bootstrap.panel',
93       toolbar : {
94        xtype : 'NavSimplebar',
95        xns : Roo.bootstrap,
96        '|xns' : 'Roo.bootstrap',
97        items  : [
98         {
99          xtype : 'NavGroup',
100          xns : Roo.bootstrap,
101          '|xns' : 'Roo.bootstrap',
102          items  : [
103           {
104            xtype : 'NavItem',
105            xns : Roo.bootstrap,
106            '|xns' : 'Roo.bootstrap',
107            items  : [
108             {
109              xtype : 'Element',
110              xns : Roo.bootstrap,
111              '|xns' : 'Roo.bootstrap',
112              items  : [
113               {
114                xtype : 'Row',
115                cls : 'roo-toolbar',
116                xns : Roo.bootstrap,
117                '|xns' : 'Roo.bootstrap',
118                items  : [
119                 {
120                  xtype : 'Column',
121                  md : 4,
122                  xns : Roo.bootstrap,
123                  '|xns' : 'Roo.bootstrap',
124                  items  : [
125                   {
126                    xtype : 'Input',
127                    placeholder : _this._strings['cffbd822c38679e2fbf11cc182c945e5'] /* search for email template */,
128                    listeners : {
129                     render : function (_self)
130                      {
131                          _this.searchBox = this;
132                      },
133                     specialkey : function (_self, e)
134                      {    
135                           if(e.keyCode == e.ENTER) {
136                              if (_this.table) {
137                                  _this.table.footer.onClick('first'); 
138                              }
139                          
140                          }
141                          
142                      }
143                    },
144                    xns : Roo.bootstrap,
145                    '|xns' : 'Roo.bootstrap',
146                    after : {
147                     xtype : 'Button',
148                     html : _this._strings['cdb6b6bab1fd18b9dbfe3fb84a5d34ae'] /* <i class="fa fa-search"></i> */,
149                     listeners : {
150                      click : function (_self, e)
151                       {
152                           _this.table.footer.onClick('first');
153                       }
154                     },
155                     xns : Roo.bootstrap,
156                     '|xns' : 'Roo.bootstrap'
157                    }
158                   }
159                  ]
160                 },
161                 {
162                  xtype : 'Column',
163                  md : 8,
164                  style : 'text-align: right;',
165                  xns : Roo.bootstrap,
166                  '|xns' : 'Roo.bootstrap',
167                  items  : [
168                   {
169                    xtype : 'Button',
170                    cls : 'roo-toolbar-button',
171                    html : _this._strings['27a7146e1e1890e289bc7fad72876831'] /* <i class="fa fa-plus"></i> Create a template */,
172                    xns : Roo.bootstrap,
173                    '|xns' : 'Roo.bootstrap',
174                    menu : {
175                     xtype : 'Menu',
176                     xns : Roo.bootstrap,
177                     '|xns' : 'Roo.bootstrap',
178                     items  : [
179                      {
180                       xtype : 'MenuItem',
181                       fa : 'file-o',
182                       html : _this._strings['03c2e7e41ffc181a4e84080b4710e81e'] /* New */,
183                       listeners : {
184                        click : function (_self, e)
185                         {
186                             if (!_this.dialog) {
187                                 return;
188                             }
189                             
190                             _this.dialog.show( { id : 0, module : 'core_email' } , function() {
191                                 _this.table.footer.onClick('first');
192                            });
193                         }
194                       },
195                       xns : Roo.bootstrap,
196                       '|xns' : 'Roo.bootstrap'
197                      },
198                      {
199                       xtype : 'MenuItem',
200                       fa : 'link',
201                       html : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
202                       listeners : {
203                        click : function (_self, e)
204                         {
205                             Pman.Dialog.BAdminImportUrl.show(
206                                 {
207                                     target : '/Core/ImportMailMessage.php'
208                                 },
209                             
210                                 function(data) {
211                                     if (data) {
212                                         Pman.Dialog.BAdminEmail.dialog.show();
213                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
214                                     }
215                                 }
216                             );
217                         }
218                       },
219                       xns : Roo.bootstrap,
220                       '|xns' : 'Roo.bootstrap'
221                      },
222                      {
223                       xtype : 'MenuItem',
224                       fa : 'code',
225                       html : _this._strings['73ea6b4441cdced246d236b22c8f991c'] /* HTML File */,
226                       listeners : {
227                        click : function (_self, e)
228                         {
229                             Pman.Dialog.BAdminImage.show(
230                                 {
231                                     _url : '/Core/ImportMailMessage.php'
232                                 },
233                             
234                                 function(data) {
235                                     if (data) {
236                                         Pman.Dialog.BAdminEmail.dialog.show();
237                                         Pman.Dialog.BAdminEmail.form.findField('bodytext').setValue(data);
238                                     }
239                                 }
240                             );
241                         }
242                       },
243                       xns : Roo.bootstrap,
244                       '|xns' : 'Roo.bootstrap'
245                      }
246                     ]
247                    }
248                   },
249                   {
250                    xtype : 'Button',
251                    cls : 'roo-toolbar-button',
252                    html : _this._strings['694e249c3a9503141fa5ce3fb71d5477'] /* <i class="fa fa-edit"></i> Edit */,
253                    listeners : {
254                     click : function (_self, e)
255                      {
256                          var sel = _this.grid.grid.selModel.getSelected();
257                          
258                          if (!sel || sel.data.id * 1 < 1) {
259                              Roo.MessageBox.alert("Error", "Select a message to edit");
260                              return;
261                          }
262                          
263                          Pman.Dialog.BAdminEmail.show( {id : sel.data.id, module : 'core_email'} , function() {
264                              _this.table.footer.onClick('first');
265                          }); 
266                      },
267                     render : function (_self)
268                      {
269                          _this.edit_btn = this;
270                          
271                          this.hide();
272                      }
273                    },
274                    xns : Roo.bootstrap,
275                    '|xns' : 'Roo.bootstrap'
276                   },
277                   {
278                    xtype : 'Button',
279                    cls : 'roo-toolbar-button',
280                    html : _this._strings['cd6df251f262cc64514b25f04aecf3c8'] /* <i class="fa fa-clipboard"></i> Copy */,
281                    listeners : {
282                     click : function (_self, e)
283                      {
284                          var sel = _this.grid.grid.selModel.getSelected();
285                          if (!sel) {
286                              Roo.MessageBox.alert("Error", "Select a message to copy");
287                              return;
288                          }
289                          new Pman.Request({
290                              url : baseURL + '/Roo/Core_email',
291                              method : 'POST',
292                              params : {
293                                  id : sel.data.id,
294                                  _make_copy : 1
295                              },
296                              success : function() {
297                                  _this.table.footer.onClick('refresh');
298                              }
299                          });
300                      },
301                     render : function (_self)
302                      {
303                          _this.copy_btn = this;
304                          
305                          this.hide();
306                      }
307                    },
308                    xns : Roo.bootstrap,
309                    '|xns' : 'Roo.bootstrap'
310                   },
311                   {
312                    xtype : 'Button',
313                    cls : 'roo-toolbar-button',
314                    html : _this._strings['ed807858fcb68abdd180481f1fcba5c5'] /* <i class="fa fa-trash"></i> Delete */,
315                    weight : 'primary',
316                    listeners : {
317                     click : function (_self, e)
318                      {
319                          Pman.genericDelete(_this.grid, 'core_email');
320                      },
321                     render : function (_self)
322                      {
323                          _this.delete_btn = this;
324                          
325                          this.hide();
326                      }
327                    },
328                    xns : Roo.bootstrap,
329                    '|xns' : 'Roo.bootstrap'
330                   }
331                  ]
332                 }
333                ]
334               }
335              ]
336             }
337            ]
338           }
339          ]
340         }
341        ]
342       },
343       grid : {
344        xtype : 'Table',
345        cellSelection : true,
346        hover : true,
347        loadMask : true,
348        responsive : true,
349        rowSelection : true,
350        listeners : {
351         cellclick : function (_self, el, rowIndex, columnIndex, e)
352          {
353              var di = this.colModel.getDataIndex(columnIndex);
354              
355               if(di != 'active'){
356                   return;
357               }
358               
359               var r = this.store.getAt(rowIndex);
360               
361              if(r.data.active * 1  < 1){
362              
363                  Pman.Dialog.BAdminEmail.show( {id : r.data.id, module : 'core_email'} , function() {
364                      _this.table.footer.onClick('refresh');
365                  });
366                  
367                  return;
368              }
369              
370              r.set('active', 0);
371              r.commit();
372               
373          },
374         render : function (_self)
375          {
376              
377              _this.table = this;
378              
379              _this.dialog = Pman.Dialog.BAdminEmail;
380          },
381         rowdblclick : function (_self, el, rowIndex, e)
382          {
383              if (!_this.dialog) {
384                  return;
385              }
386              
387              //var data = this.getDataSource().getAt(rowIndex).data;
388              var data = _this.table.store.getAt(rowIndex).data;
389              
390              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
391                  
392                  _this.table.footer.onClick('refresh');
393              }); 
394          }
395        },
396        xns : Roo.bootstrap,
397        '|xns' : 'Roo.bootstrap',
398        footer : {
399         xtype : 'PagingToolbar',
400         displayInfo : true,
401         pageSize : 25,
402         xns : Roo.bootstrap,
403         '|xns' : 'Roo.bootstrap'
404        },
405        store : {
406         xtype : 'Store',
407         remoteSort : true,
408         sortInfo : {field:'description',direction:'ASC'},
409         listeners : {
410          beforeload : function (_self, options)
411           {
412               if (!Pman.buildCompleted) {
413                   return false;
414               }
415               
416               options.params = options.params || {};
417               
418               var s = _this.searchBox.getValue();
419               
420               if(s.length){
421                   options.params['search[nameortitle]'] = s;
422               }
423           
424           },
425          load : function (_self, records, options)
426           {
427               _this.edit_btn.hide();
428               _this.copy_btn.hide();
429               _this.delete_btn.hide();
430           },
431          update : function (_self, record, operation)
432           {
433               if (operation != 'commit') {
434                   return;
435               }
436           
437               new Pman.Request({
438                   url : baseURL + '/Roo/Core_email',
439                   method : 'POST',
440                   params : {
441                     id : record.data.id,
442                     active : record.data.active
443                   },
444                   success : function() { 
445                       _this.table.footer.onClick('refresh');
446                   }
447             });
448           }
449         },
450         xns : Roo.data,
451         '|xns' : 'Roo.data',
452         proxy : {
453          xtype : 'HttpProxy',
454          method : 'GET',
455          url : baseURL+'/Roo/Core_email.php',
456          xns : Roo.data,
457          '|xns' : 'Roo.data'
458         },
459         reader : {
460          xtype : 'JsonReader',
461          fields : [
462              {
463                  "name":"name",
464                  "type":"string"
465              },
466              {
467                  "name":"subject",
468                  "type":"string"
469              },
470              {
471                  "name":"description",
472                  "type":"string"
473              }
474          ],
475          id : 'id',
476          root : 'data',
477          totalProperty : 'total',
478          xns : Roo.data,
479          '|xns' : 'Roo.data'
480         }
481        },
482        sm : {
483         xtype : 'RowSelectionModel',
484         singleSelect : true,
485         listeners : {
486          afterselectionchange : function (_self)
487           {
488               _this.edit_btn.hide();
489               _this.copy_btn.hide();
490               _this.delete_btn.hide();
491               
492               if (!this.getSelected()) {
493                   _this.viewPanel.setContent("Nothing Selected");
494                   return;
495               }
496               
497               if(this.getSelected().data) {
498                   _this.viewPanel.setContent(this.getSelected().data.bodytext);
499               }
500               
501               _this.edit_btn.show();
502               _this.copy_btn.show();
503               _this.delete_btn.show();
504               
505           }
506         },
507         xns : Roo.bootstrap.Table,
508         '|xns' : 'Roo.bootstrap.Table'
509        },
510        cm : [
511         {
512          xtype : 'ColumnModel',
513          align : 'center',
514          cursor : 'pointer',
515          dataIndex : 'active',
516          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
517          renderer : function(v) {  
518          
519              var state = v > 0 ?  'check-' : '';
520              var cls = v > 0 ? 'text-primary' : '';
521              
522              return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
523                          
524           },
525          sortable : true,
526          xs : 1,
527          xns : Roo.grid,
528          '|xns' : 'Roo.grid'
529         },
530         {
531          xtype : 'ColumnModel',
532          cursor : 'pointer',
533          dataIndex : 'description',
534          header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
535          renderer : function(v,x,r) 
536          { 
537              vv = (v.length) ? v : r.data.name;
538              
539              if(r.data.active * 1 < 1){
540                  return '<small style="color: #999;">' + vv + '</small>';
541              }
542              
543              return '<b>' + vv + '</b>';
544          },
545          sortable : true,
546          xs : 4,
547          xns : Roo.grid,
548          '|xns' : 'Roo.grid'
549         },
550         {
551          xtype : 'ColumnModel',
552          cursor : 'pointer',
553          dataIndex : 'from_email',
554          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
555          renderer : function(v,x,r)
556          {
557              if(r.data.active * 1 < 1){
558                  return '';
559              }
560              
561              return String.format('<small>{0}</small>', r.data.from_name );
562              
563          },
564          xs : 2,
565          xns : Roo.grid,
566          '|xns' : 'Roo.grid'
567         },
568         {
569          xtype : 'ColumnModel',
570          cursor : 'pointer',
571          dataIndex : 'to_group_name',
572          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
573          renderer : function(v,x,r)
574          { 
575              if(r.data.active * 1 < 1){
576                  return '';
577              }
578              
579              var nid = r.data.to_group_id * 1 ;
580              var n = nid > 0 ? r.data.group_member_count * 1 : 0;
581              var grp_str = String.format('<small>To: {0} ' + 
582                      '<span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small><br>',
583                      r.data.to_group_id_name,
584                      nid < 1 ? 'Not set' : n
585                  );
586             
587              if (nid < 0) { // no To needed..
588                  grp_str = '';
589              }
590              nid = r.data.bcc_group_id * 1;
591              n = nid > 0 ? r.data.bcc_group_member_count * 1 : 0;
592          
593              var bcc_str = String.format('<small>BCC: {0} <span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small>',
594                      r.data.bcc_group_id_name,
595                      nid < 1 ? 'Not set' : n
596                  );
597                  
598              if (nid < 0) { // no To needed..
599                  bcc_str = '';
600              }  
601              
602              return grp_str + bcc_str;
603          },
604          xs : 5,
605          xns : Roo.grid,
606          '|xns' : 'Roo.grid'
607         }
608        ]
609       }
610      },
611      {
612       xtype : 'Content',
613       fitToFrame : true,
614       region : 'south',
615       title : _this._strings['9e11143e29a031212f2cdefcf61f39e9'] /* View Message */,
616       listeners : {
617        render : function (_self)
618         {
619             _this.viewPanel = this;
620         }
621       },
622       xns : Roo.bootstrap.panel,
623       '|xns' : 'Roo.bootstrap.panel'
624      }
625     ]
626    }
627   };  }
628 });