jqh 5 years ago
parent
commit
fc68a77782
3 changed files with 12 additions and 5 deletions
  1. 8 1
      src/Grid/Tools.php
  2. 3 1
      src/Grid/Tools/BatchActions.php
  3. 1 3
      src/SimpleGrid.php

+ 8 - 1
src/Grid/Tools.php

@@ -2,6 +2,7 @@
 
 namespace Dcat\Admin\Grid;
 
+use Dcat\Admin\Actions\Action;
 use Dcat\Admin\Grid;
 use Dcat\Admin\Grid\Tools\AbstractTool;
 use Dcat\Admin\Grid\Tools\BatchActions;
@@ -184,6 +185,12 @@ class Tools implements Renderable
      */
     public function render()
     {
-        return $this->tools->map([Helper::class, 'render'])->implode(' ');
+        return $this->tools->map(function ($tool) {
+            if ($tool instanceof Action && ! $tool->allowed()) {
+                return;
+            }
+
+            return Helper::render($tool);
+        })->implode(' ');
     }
 }

+ 3 - 1
src/Grid/Tools/BatchActions.php

@@ -116,7 +116,9 @@ $('.{$rowName}-checkbox').on('change', function () {
     } else {
         btn.hide()
     }
-    btn.find('.selected').html("{$selected}".replace('{n}', LA.grid.selectedRows('$name').length));
+    setTimeout(function () {
+         btn.find('.selected').html("{$selected}".replace('{n}', LA.grid.selectedRows('$name').length));
+    }, 50)
 });
 JS;
 

+ 1 - 3
src/SimpleGrid.php

@@ -18,12 +18,10 @@ class SimpleGrid extends Grid
         $this->disableExporter();
         $this->disablePerPages();
         $this->disableBatchActions();
+        $this->disableFilterButton();
 
         $this->option('row_selector_clicktr', true);
 
-        $this->tools->disableBatchActions();
-        $this->tools->disableFilterButton();
-
         Content::composing(function (Content $content) {
             $content->simple();
         }, true);