PHP8
[Pman.BAdmin] / Pman.Tab.BAdminCoreEnum.js
index 8a66c52..fc7fa33 100644 (file)
@@ -9,11 +9,13 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
  _strings : {
   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
   '2df80d5febcde0c10a66818488622b7c' :"Pulldown Options",
+  '7dce122004969d56ae2e0245cb754d35' :"Edit",
   '01abfc750a0c942167651c40d088531d' :"#",
   'dae8ace18bdcbcc6ae5aece263e14fe8' :"Options",
   'b48968e1c912da07df5e8d6d246291ec' :"Display Name",
   'f2d346b1bb7c1c85ab6f7f21e3666b9f' :"Types",
   '49ee3087348e8d44e1feda1917443987' :"Name",
+  'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active"
  },
 
@@ -66,6 +68,8 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
       listeners : {
        activate : function (_self)
         {
+            _this.type_edit_btn.hide();
+            
             if(_this.type_grid) {
                 _this.type_grid.footer.onClick('first');
             }
@@ -93,24 +97,79 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
            '|xns' : 'Roo.bootstrap',
            items  : [
             {
-             xtype : 'Button',
-             glyphicon : 'plus',
-             html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
-             style : 'margin: 10px;',
-             weight : 'primary',
-             listeners : {
-              click : function (_self, e)
-               {
-                   Pman.Dialog.BAdminCoreEnum.show({ 
-                       id : 0
-                   }, function(res) {
-                       _this.type_grid.footer.onClick('first');
-                   });
-               
-               }
-             },
+             xtype : 'Element',
              xns : Roo.bootstrap,
-             '|xns' : 'Roo.bootstrap'
+             '|xns' : 'Roo.bootstrap',
+             items  : [
+              {
+               xtype : 'Row',
+               cls : 'roo-toolbar',
+               xns : Roo.bootstrap,
+               '|xns' : 'Roo.bootstrap',
+               items  : [
+                {
+                 xtype : 'Column',
+                 md : 12,
+                 xns : Roo.bootstrap,
+                 '|xns' : 'Roo.bootstrap',
+                 items  : [
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   glyphicon : 'plus',
+                   html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         Pman.Dialog.BAdminCoreEnum.show({ 
+                             id : 0
+                         }, function(res) {
+                             _this.type_grid.footer.onClick('first');
+                         });
+                     
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  },
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   glyphicon : 'edit',
+                   html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         var sel = _this.type_grid.getSelectionModel().getSelected();
+                         
+                         if(!sel || sel.data.id * 1 < 1){
+                             Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
+                             return;
+                         }
+                     
+                         Pman.Dialog.BAdminCoreEnum.show({ 
+                             id : sel.data.id
+                         }, function(res) {
+                             _this.type_grid.footer.onClick('first');
+                         });
+                     },
+                    render : function (_self)
+                     {
+                         _this.type_edit_btn = this;
+                         
+                         this.hide();
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  }
+                 ]
+                }
+               ]
+              }
+             ]
             }
            ]
           }
@@ -124,7 +183,6 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
        cls : 'table-fixed',
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : false,
        listeners : {
@@ -154,7 +212,7 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         xtype : 'PagingToolbar',
         displayInfo : false,
         name : 'footer',
-        pageSize : 25,
+        pageSize : 100,
         xns : Roo.bootstrap,
         '|xns' : 'Roo.bootstrap'
        },
@@ -165,10 +223,18 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         listeners : {
          beforeload : function (_self, o)
           {
+                if (!Pman.buildCompleted) {
+                  return false;
+              }
+              
               o.params = o.params || {};
               
               o.params['query[empty_etype]'] = 1;
               
+          },
+         load : function (_self, records, options)
+          {
+              _this.type_edit_btn.hide();
           }
         },
         xns : Roo.data,
@@ -221,6 +287,12 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         listeners : {
          selectionchange : function (_self)
           {
+              _this.type_edit_btn.hide();
+              
+              if(this.getSelected()){
+                  _this.type_edit_btn.show();
+              }
+              
               _this.option_grid.store.load({});
           }
         },
@@ -230,9 +302,14 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
        cm : [
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'display_name',
          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
-         renderer : function(v,x,r) { 
+         renderer : function(v,x,r) {
+             if (v.match(/Coba/g) || v.match(/Risk Question/g)) {
+                 return String.format('<span tooltip="{1}">Coba: {0}</span>', v, r.data.name);
+             }
+             
              return String.format('<span tooltip="{1}">{0}</span>', v, r.data.name); 
          },
          sortable : true,
@@ -253,9 +330,11 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
       listeners : {
        activate : function (_self)
         {
+            _this.edit_btn.hide();
+            _this.delete_btn.hide();
+            
             if (_this.option_grid) {
                 _this.option_grid.store.load({});
-        //        _this.option_grid.footer.onClick('first');
             }
         },
        render : function (_self)
@@ -281,31 +360,126 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
            '|xns' : 'Roo.bootstrap',
            items  : [
             {
-             xtype : 'Button',
-             glyphicon : 'plus',
-             html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
-             style : 'margin: 10px;',
-             weight : 'primary',
-             listeners : {
-              click : function (_self, e)
-               {
-                   var sel = _this.type_grid.getSelectionModel().getSelected();
-                   
-                   if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
-                       return;
-                   }
-               
-                   Pman.Dialog.BAdminCoreEnum.show({ 
-                       id : 0,
-                       etype : sel.data.name
-                   }, function(res) {
-                       _this.type_grid.footer.onClick('first');
-                   });
-               
-               }
-             },
+             xtype : 'Element',
              xns : Roo.bootstrap,
-             '|xns' : 'Roo.bootstrap'
+             '|xns' : 'Roo.bootstrap',
+             items  : [
+              {
+               xtype : 'Row',
+               cls : 'roo-toolbar',
+               xns : Roo.bootstrap,
+               '|xns' : 'Roo.bootstrap',
+               items  : [
+                {
+                 xtype : 'Column',
+                 md : 12,
+                 xns : Roo.bootstrap,
+                 '|xns' : 'Roo.bootstrap',
+                 items  : [
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   glyphicon : 'plus',
+                   html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         var sel = _this.type_grid.getSelectionModel().getSelected();
+                         
+                         if(!sel || sel.data.id * 1 < 1 || !sel.data.name.length ){
+                             Roo.bootstrap.MessageBox.alert('Error', 'Please select a type');
+                             return;
+                         }
+                     
+                         Pman.Dialog.BAdminCoreEnum.show({ 
+                             id : 0,
+                             etype : sel.data.name
+                         }, function(res) {
+                             _this.option_grid.store.load({});
+                         });
+                     
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  },
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   glyphicon : 'edit',
+                   html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
+                   weight : 'default',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         var sel = _this.option_grid.getSelectionModel().getSelected();
+                         
+                         if(!sel || sel.data.id * 1 < 1){
+                             Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
+                             return;
+                         }
+                     
+                         Pman.Dialog.BAdminCoreEnum.show({ 
+                             id : sel.data.id
+                         }, function(res) {
+                             _this.option_grid.store.load({});
+                         });
+                     
+                     },
+                    render : function (_self)
+                     {
+                         _this.edit_btn = this;
+                         
+                         this.hide();
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  },
+                  {
+                   xtype : 'Button',
+                   cls : 'roo-toolbar-button',
+                   glyphicon : 'trash',
+                   html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
+                   weight : 'primary',
+                   listeners : {
+                    click : function (_self, e)
+                     {
+                         var sel = _this.option_grid.getSelectionModel().getSelected();
+                         
+                         if(!sel || sel.data.id * 1 < 1){
+                             Roo.bootstrap.MessageBox.alert('Error', 'Please select a option');
+                             return;
+                         }
+                     
+                         new Pman.Request({
+                             url: baseURL + '/Roo/Core_enum.php',
+                             method : 'POST',
+                             params : {
+                                 _delete : sel.data.id
+                             }, 
+                             success : function(res) {
+                                 _this.option_grid.store.load({});
+                             }
+                         });
+                     
+                     },
+                    render : function (_self)
+                     {
+                         _this.delete_btn = this;
+                         
+                         this.hide();
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap'
+                  }
+                 ]
+                }
+               ]
+              }
+             ]
             }
            ]
           }
@@ -315,18 +489,58 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
       },
       grid : {
        xtype : 'Table',
+       cellSelection : true,
        cls : 'table-fixed',
        footerShow : false,
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : true,
        listeners : {
+        cellclick : function (_self, el, rowIndex, columnIndex, e)
+         {
+             var di = _this.option_grid.colModel.getDataIndex(columnIndex);
+             
+             if (di != 'active') {
+                 return;
+             }
+              
+             var rec = _this.option_grid.store.getAt(rowIndex);
+             
+             rec.set('active', rec.data.active ? 0 : 1);
+             
+             rec.commit();
+             
+             /*if(rec.data.active * 1 != 1){
+                 var el = _this.option_grid.getRowDom(rowIndex);
+                 
+                 el.addClass('x-grid-row-fadeout');
+                 
+                 el.on('transitionend',function(){
+                     _this.option_grid.ds.remove(rec);
+                     el.remove();
+                 },this,{single:true});
+             }*/
+         },
         render : function (_self)
          {
              _this.option_grid = _self; 
          
+         },
+        rowdblclick : function (_self, el, rowIndex, e)
+         {
+             var sel = _this.option_grid.store.getAt(rowIndex);
+             
+             if(!sel || sel.data.id * 1 < 1){
+                 return;
+             }
+             
+             Pman.Dialog.BAdminCoreEnum.show({ 
+                 id : sel.data.id
+             }, function(res) {
+                 _this.option_grid.store.load({});
+             });
+             
          }
        },
        xns : Roo.bootstrap,
@@ -334,10 +548,14 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
        store : {
         xtype : 'Store',
         remoteSort : true,
-        sortinfo : { field : 'display_name', direction: 'ASC' },
+        sortInfo : { field : 'display_name', direction: 'ASC' },
         listeners : {
          beforeload : function (_self, o)
           {
+              if (!Pman.buildCompleted) {
+                  return false;
+              }
+              
               o.params = o.params || {};
               
               var sel = _this.type_grid.getSelectionModel().getSelected();
@@ -349,6 +567,35 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
               
               o.params.etype = sel.data.name;
               
+          },
+         load : function (_self, records, options)
+          {
+              _this.edit_btn.hide();
+              _this.delete_btn.hide();
+          },
+         update : function (_self, record, operation)
+          {
+              if (operation != 'commit') {
+                  return;
+              }
+          
+              new Pman.Request({
+                  url : baseURL + '/Roo/Core_enum',
+                  method :'POST',
+                  params : {
+                      id : record.data.id,
+                      active: record.data.active
+                  },
+                  success : function() {
+          
+                  },
+                  failure : function() 
+                  {
+                      Roo.bootstrap.MessageBox.alert("Error", "saving failed", function() {
+                          _this.grid.footer.onClick('first');
+                      });
+                  }
+              });
           }
         },
         xns : Roo.data,
@@ -398,17 +645,40 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
        sm : {
         xtype : 'RowSelectionModel',
         singleSelect : true,
+        listeners : {
+         selectionchange : function (_self)
+          {
+              _this.edit_btn.hide();
+              _this.delete_btn.hide();
+              
+              if (!this.getSelected()) {
+                  return;
+              }
+              
+              _this.edit_btn.show();
+              _this.delete_btn.show();
+              
+          }
+        },
         xns : Roo.bootstrap.Table,
         '|xns' : 'Roo.bootstrap.Table'
        },
        cm : [
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'id',
          header : _this._strings['01abfc750a0c942167651c40d088531d'] /* # */,
          md : 2,
-         renderer : function(v,x,r) { 
-             return String.format('{0}', v ? v : '');
+         renderer : function(v,x,r) {
+             //console.log(r.data.seqid);
+             //return String.format('{0}', v ? v : '');
+             
+             return 
+                 String.format('{0}', r.data.seqid ? r.data.seqid : '')
+                 +" <span style='color:lightgrey'>"
+                 + String.format('{0}', r.data.id ? r.data.id : '')
+                 +"</span>";
          },
          sm : 2,
          sortable : false,
@@ -418,6 +688,7 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'name',
          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
          md : 4,
@@ -432,6 +703,7 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'display_name',
          header : _this._strings['b48968e1c912da07df5e8d6d246291ec'] /* Display Name */,
          md : 4,
@@ -446,13 +718,16 @@ Pman.Tab.BAdminCoreEnum = new Roo.XComponent({
         },
         {
          xtype : 'ColumnModel',
+         cursor : 'pointer',
          dataIndex : 'active',
          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
          md : 2,
          renderer : function(v,x,r) { 
-             var state = v > 0 ?  '-checked' : '';
-         
-             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+             
+             var state = v > 0 ? 'check-' : '';
+             
+             //return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';
+             return '<i class="far fa-'+ state + 'square-o fa-2x" aria-hidden="true"></i>';
          },
          sm : 2,
          sortable : false,