PHP8
[Pman.BAdmin] / Pman.Tab.BAdminEmailTemplates.js
index 6d7f4f3..1f28738 100644 (file)
@@ -13,15 +13,14 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
   '73ea6b4441cdced246d236b22c8f991c' :"HTML File",
   '694e249c3a9503141fa5ce3fb71d5477' :"<i class=\"fa fa-edit\"></i> Edit",
   'cffbd822c38679e2fbf11cc182c945e5' :"search for email template",
-  'b78a3223503896721cca1303f776159b' :"Title",
-  '68b00d723d37122f64da8d9939f836f0' :"BCC Group",
   '9e11143e29a031212f2cdefcf61f39e9' :"View Message",
   'f49559cda3fb906fbd7736f8b8a0e37d' :"Email Template",
   '27a7146e1e1890e289bc7fad72876831' :"<i class=\"fa fa-plus\"></i> Create a template",
   'cd6df251f262cc64514b25f04aecf3c8' :"<i class=\"fa fa-clipboard\"></i> Copy",
   'ed807858fcb68abdd180481f1fcba5c5' :"<i class=\"fa fa-trash\"></i> Delete",
   '03c2e7e41ffc181a4e84080b4710e81e' :"New",
-  '49ee3087348e8d44e1feda1917443987' :"Name",
+  '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
+  'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
   'e6b391a8d2c4d45902a23a8b6585703d' :"URL"
  },
 
@@ -40,6 +39,22 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
    xtype : 'Nest',
    background : true,
    title : _this._strings['f49559cda3fb906fbd7736f8b8a0e37d'] /* Email Template */,
+   listeners : {
+    activate : function (_self)
+     {
+         if(!document.getElementsByClassName('email-south-pane')) {
+             return;
+         }
+         
+         document.getElementsByClassName('email-south-pane')[0].classList.remove('disable-pane');
+         
+         if(
+             appDisabled.indexOf('Core.SuperAdmin') * 1 != -1
+         ) {
+             document.getElementsByClassName('email-south-pane')[0].classList.add('disable-pane');
+         }
+     }
+   },
    xns : Roo.bootstrap.panel,
    '|xns' : 'Roo.bootstrap.panel',
    layout : {
@@ -56,6 +71,7 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
     south : {
      xtype : 'Region',
      autoScroll : true,
+     cls : 'email-south-pane',
      height : 200,
      hideTabs : true,
      split : true,
@@ -139,6 +155,7 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
                              }
                          
                          }
+                         
                      }
                    },
                    xns : Roo.bootstrap,
@@ -169,6 +186,12 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
                    xtype : 'Button',
                    cls : 'roo-toolbar-button',
                    html : _this._strings['27a7146e1e1890e289bc7fad72876831'] /* <i class="fa fa-plus"></i> Create a template */,
+                   listeners : {
+                    render : function (_self)
+                     {
+                         this.hide();
+                     }
+                   },
                    xns : Roo.bootstrap,
                    '|xns' : 'Roo.bootstrap',
                    menu : {
@@ -342,11 +365,35 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
       },
       grid : {
        xtype : 'Table',
+       cellSelection : true,
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        listeners : {
+        cellclick : function (_self, el, rowIndex, columnIndex, e)
+         {
+             var di = this.colModel.getDataIndex(columnIndex);
+             
+              if(di != 'active'){
+                  return;
+              }
+              
+              var r = this.store.getAt(rowIndex);
+              
+             if(r.data.active * 1  < 1){
+             
+                 Pman.Dialog.BAdminEmail.show( {id : r.data.id, module : 'core_email'} , function() {
+                     _this.table.footer.onClick('refresh');
+                 });
+                 
+                 return;
+             }
+             
+             r.set('active', 0);
+             r.commit();
+             
+              
+         },
         render : function (_self)
          {
              
@@ -365,7 +412,7 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
              
              _this.dialog.show( {id : data.id, module : 'core_email'} , function() {
                  
-                 _this.table.footer.onClick('first');
+                 _this.table.footer.onClick('refresh');
              }); 
          }
        },
@@ -381,10 +428,14 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
        store : {
         xtype : 'Store',
         remoteSort : true,
-        sortInfo : {field:'name',direction:'ASC'},
+        sortInfo : {field:'description',direction:'ASC'},
         listeners : {
          beforeload : function (_self, options)
           {
+              if (!Pman.buildCompleted) {
+                  return false;
+              }
+              
               options.params = options.params || {};
               
               var s = _this.searchBox.getValue();
@@ -392,6 +443,10 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
               if(s.length){
                   options.params['search[nameortitle]'] = s;
               }
+              // hide our system emails.
+              if (appDisabled.indexOf('Core.SuperAdmin') > -1) {
+                  options.params._hide_system_emails = 1;
+              } 
           
           },
          load : function (_self, records, options)
@@ -399,6 +454,24 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
               _this.edit_btn.hide();
               _this.copy_btn.hide();
               _this.delete_btn.hide();
+          },
+         update : function (_self, record, operation)
+          {
+              if (operation != 'commit') {
+                  return;
+              }
+          
+              new Pman.Request({
+                  url : baseURL + '/Roo/Core_email',
+                  method : 'POST',
+                  params : {
+                    id : record.data.id,
+                    active : record.data.active
+                  },
+                  success : function() { 
+                      _this.table.footer.onClick('refresh');
+                  }
+            });
           }
         },
         xns : Roo.data,
@@ -420,6 +493,10 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
              {
                  "name":"subject",
                  "type":"string"
+             },
+             {
+                 "name":"description",
+                 "type":"string"
              }
          ],
          id : 'id',
@@ -460,39 +537,40 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
        cm : [
         {
          xtype : 'ColumnModel',
+         align : 'center',
          cursor : 'pointer',
-         dataIndex : 'name',
-         header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
-         renderer : function(v,x,r) 
-         { 
-             if(r.data.active * 1 < 1){
-             
-                 return String.format('<span style="font-size:12px;"><s>{0}</s><span>', v ? v : ''); 
-                 
-             }
+         dataIndex : 'active',
+         header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
+         renderer : function(v) {  
+         
+             var state = v > 0 ?  'check-' : '';
+             var cls = v > 0 ? 'text-primary' : '';
              
-             return String.format('<span style="font-size:12px;">{0}<span>', v ? v : ''); 
-         },
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
+                         
+          },
          sortable : true,
-         xs : 3,
+         xs : 1,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
          cursor : 'pointer',
-         dataIndex : 'subject',
-         header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
+         dataIndex : 'description',
+         header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
          renderer : function(v,x,r) 
          { 
+             vv = (v.length) ? v : r.data.name;
+             
              if(r.data.active * 1 < 1){
-                 return String.format('<span style="font-size:12px;"><s>{0}</s></span>', v ? v : ''); 
+                 return '<small style="color: #999;">' + vv + '</small>';
              }
              
-             return String.format('<span style="font-size:12px;">{0}</span>', v ? v : ''); 
+             return '<b>' + vv + '</b>';
          },
          sortable : true,
-         xs : 3,
+         xs : 4,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
@@ -503,22 +581,12 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
          header : _this._strings['cae905999a2ad1dfb8f4eae0e8cda73b'] /* From Name<br/>Email */,
          renderer : function(v,x,r)
          {
-             var from_name = r.data.from_name ? r.data.from_name : '';
-             var from_email = r.data.from_email ? r.data.from_email : '';
-             
-             //var r = from_name + '<br>' + from_email ;
-             if(from_name =='') {
-                 return String.format('<span style="font-size:12px;">{0}</span>', from_email);
+             if(r.data.active * 1 < 1){
+                 return '';
              }
-             return String.format('<span style="font-size:12px;">{0} <br> {1}</span>', from_name, from_email);
              
-             /*
-             return String.format(
-                 '{0}'+'<'+'{1}'+'>',
-                 r.data.from_name ? r.data.from_name : '',
-                 r.data.from_email ? r.data.from_email : ''
-             );
-             */
+             return String.format('<small>{0}</small>', r.data.from_name );
+             
          },
          xs : 3,
          xns : Roo.grid,
@@ -531,43 +599,36 @@ Pman.Tab.BAdminEmailTemplates = new Roo.XComponent({
          header : _this._strings['98d2ee61ddce0c7666297d81639914f1'] /* To / BCC Group */,
          renderer : function(v,x,r)
          { 
-             if(
-                (r.data.group_member_count * 1 < 1 && r.data.to_group_name !='') ||
-                (r.data.bcc_group_member_count * 1 < 1 && r.data.bcc_group_name !='') 
-             ){
-              
-                 var grp_str = String.format('<span style="font-size:12px;">To: {0} <br>',r.data.to_group_name);
-                 
-                 if(r.data.group_member_count * 1 < 1 ){
-                     grp_str = String.format('<span style="font-size:12px;">To: {0} <span class="text-danger">(0)</span></span> <br>',r.data.to_group_name);
-                 }
-         
-                 var bcc_str = String.format('<span style="font-size:12px;">BCC: {0} </span>',r.data.bcc_group_name);
-                 
-                 if(r.data.bcc_group_member_count * 1 < 1 ){
-                     bcc_str = String.format('<span style="font-size:12px;">BCC: {0} <span class="text-danger">(0)</span></span>',r.data.bcc_group_name);
-                 }
-         
-                 return grp_str + bcc_str;
+             if(r.data.active * 1 < 1){
+                 return '';
              }
-             if(r.data.to_group_name ==''){
-                 return String.format('<span style="font-size:12px;">BCC: {0}</span>', r.data.bcc_group_name ); 
+             
+             var nid = r.data.to_group_id * 1 ;
+             var n = nid > 0 ? r.data.group_member_count * 1 : 0;
+             var grp_str = String.format('<small>To: {0} ' + 
+                     '<span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small><br>',
+                     r.data.to_group_id_name,
+                     nid < 1 ? 'Not set' : n
+                 );
+            
+             if (nid < 0) { // no To needed..
+                 grp_str = '';
              }
+             nid = r.data.bcc_group_id * 1;
+             n = nid > 0 ? r.data.bcc_group_member_count * 1 : 0;
          
-             return String.format('<span style="font-size:12px;">To: {0} <br>BCC: {1}</span>', r.data.to_group_name,r.data.bcc_group_name ); 
+             var bcc_str = String.format('<small>BCC: {0} <span class="badge' + (n > 0 ?  '' : ' badge-danger') + '">{1}</span></small>',
+                     r.data.bcc_group_id_name,
+                     nid < 1 ? 'Not set' : n
+                 );
+                 
+             if (nid < 0) { // no To needed..
+                 bcc_str = '';
+             }  
+             
+             return grp_str + bcc_str;
          },
-         xs : 3,
-         xns : Roo.grid,
-         '|xns' : 'Roo.grid'
-        },
-        {
-         xtype : 'ColumnModel',
-         cursor : 'pointer',
-         dataIndex : 'bcc_group_name',
-         header : _this._strings['68b00d723d37122f64da8d9939f836f0'] /* BCC Group */,
-         hidden : true,
-         renderer : function(v) { return String.format('{0}', v ? v : ''); },
-         xs : 2,
+         xs : 4,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         }