Browse Source

调整Actions

jqh 4 years ago
parent
commit
0cddacbb22

+ 1 - 1
src/Grid/Actions/Delete.php

@@ -15,7 +15,7 @@ class Delete extends RowAction
             return $this->title;
         }
 
-        return '<i class="feather icon-trash"></i> '.__('admin.delete');
+        return '<i class="feather icon-trash"></i> '.__('admin.delete').' &nbsp;&nbsp;';
     }
 
     public function render()

+ 1 - 1
src/Grid/Actions/Edit.php

@@ -15,7 +15,7 @@ class Edit extends RowAction
             return $this->title;
         }
 
-        return '<i class="feather icon-edit-1"></i> '.__('admin.edit');
+        return '<i class="feather icon-edit-1"></i> '.__('admin.edit').' &nbsp;&nbsp;';
     }
 
     /**

+ 1 - 1
src/Grid/Actions/QuickEdit.php

@@ -16,7 +16,7 @@ class QuickEdit extends RowAction
             return $this->title;
         }
 
-        return '<i class="feather icon-edit"></i> '.__('admin.quick_edit');
+        return '<i class="feather icon-edit"></i> '.__('admin.quick_edit').' &nbsp;&nbsp;';
     }
 
     public function render()

+ 1 - 1
src/Grid/Actions/Show.php

@@ -15,7 +15,7 @@ class Show extends RowAction
             return $this->title;
         }
 
-        return '<i class="feather icon-eye"></i> '.__('admin.show');
+        return '<i class="feather icon-eye"></i> '.__('admin.show').' &nbsp;&nbsp;';
     }
 
     /**

+ 43 - 33
src/Grid/Displayers/Actions.php

@@ -3,7 +3,6 @@
 namespace Dcat\Admin\Grid\Displayers;
 
 use Dcat\Admin\Actions\Action;
-use Dcat\Admin\Form;
 use Dcat\Admin\Grid\Actions\Delete;
 use Dcat\Admin\Grid\Actions\Edit;
 use Dcat\Admin\Grid\Actions\QuickEdit;
@@ -15,8 +14,6 @@ use Illuminate\Contracts\Support\Renderable;
 
 class Actions extends AbstractDisplayer
 {
-    protected static $resolvedDialog;
-
     /**
      * @var array
      */
@@ -251,16 +248,22 @@ class Actions extends AbstractDisplayer
      */
     protected function renderView()
     {
-        $label = trans('admin.show');
-
-        return Show::make(
-            "<i title='{$label}' class=\"feather icon-eye grid-action-icon\"></i> &nbsp;"
-        )
+        return Show::make($this->getViewLabel())
             ->setGrid($this->grid)
             ->setRow($this->row)
             ->render();
     }
 
+    /**
+     * @return string
+     */
+    protected function getViewLabel()
+    {
+        $label = trans('admin.show');
+
+        return "<i title='{$label}' class=\"feather icon-eye grid-action-icon\"></i> &nbsp;";
+    }
+
     /**
      * Render edit action.
      *
@@ -268,11 +271,7 @@ class Actions extends AbstractDisplayer
      */
     protected function renderEdit()
     {
-        $label = trans('admin.edit');
-
-        return Edit::make(
-            "<i title='{$label}' class=\"feather icon-edit-1 grid-action-icon\"></i> &nbsp;"
-        )
+        return Edit::make($this->getEditLabel())
             ->setGrid($this->grid)
             ->setRow($this->row)
             ->render();
@@ -281,29 +280,34 @@ class Actions extends AbstractDisplayer
     /**
      * @return string
      */
-    protected function renderQuickEdit()
+    protected function getEditLabel()
     {
-        if (! static::$resolvedDialog) {
-            static::$resolvedDialog = true;
-
-            [$width, $height] = $this->grid->option('dialog_form_area');
-
-            Form::dialog(trans('admin.edit'))
-                ->click(".{$this->grid->getRowName()}-edit")
-                ->dimensions($width, $height)
-                ->success('Dcat.reload()');
-        }
+        $label = trans('admin.show');
 
-        $label = trans('admin.quick_edit');
+        return "<i title='{$label}' class=\"feather icon-edit-1 grid-action-icon\"></i> &nbsp;";
+    }
 
-        return QuickEdit::make(
-            "<i title='{$label}' class=\"feather icon-edit grid-action-icon\"></i> &nbsp;"
-        )
+    /**
+     * @return string
+     */
+    protected function renderQuickEdit()
+    {
+        return QuickEdit::make($this->getQuickEditLabel())
             ->setGrid($this->grid)
             ->setRow($this->row)
             ->render();
     }
 
+    /**
+     * @return string
+     */
+    protected function getQuickEditLabel()
+    {
+        $label = trans('admin.quick_edit');
+
+        return "<i title='{$label}' class=\"feather icon-edit grid-action-icon\"></i> &nbsp;";
+    }
+
     /**
      * Render delete action.
      *
@@ -311,13 +315,19 @@ class Actions extends AbstractDisplayer
      */
     protected function renderDelete()
     {
-        $label = trans('admin.delete');
-
-        return Delete::make(
-            "<i class=\"feather icon-trash grid-action-icon\" title='{$label}'></i> &nbsp;"
-        )
+        return Delete::make($this->getDeleteLabel())
             ->setGrid($this->grid)
             ->setRow($this->row)
             ->render();
     }
+
+    /**
+     * @return string
+     */
+    protected function getDeleteLabel()
+    {
+        $label = trans('admin.delete');
+
+        return "<i class=\"feather icon-trash grid-action-icon\" title='{$label}'></i> &nbsp;";
+    }
 }

+ 1 - 0
src/Http/Controllers/UserController.php

@@ -56,6 +56,7 @@ class UserController extends AdminController
             $grid->showQuickEditButton();
             $grid->enableDialogCreate();
             $grid->showColumnSelector();
+            $grid->disableEditButton();
 
             $grid->actions(function (Grid\Displayers\Actions $actions) {
                 if ($actions->getKey() == AdministratorModel::DEFAULT_ID) {