Przeglądaj źródła

表格默认使用table_collapse模式

jqh 5 lat temu
rodzic
commit
a9179ed782

+ 0 - 1
src/Form/Concerns/HasFieldValidator.php

@@ -309,7 +309,6 @@ trait HasFieldValidator
         return false;
     }
 
-
     /**
      * @param $rules
      * @param $rule

+ 11 - 2
src/Grid.php

@@ -174,7 +174,7 @@ class Grid
         'show_row_selector'      => true,
         'show_create_button'     => true,
         'show_bordered'          => false,
-        'table_collapse'         => false,
+        'table_collapse'         => true,
         'show_toolbar'           => true,
         'create_mode'            => self::CREATE_MODE_DEFAULT,
         'dialog_form_area'       => ['700px', '670px'],
@@ -687,7 +687,7 @@ HTML;
     public function option($key, $value = null)
     {
         if (is_null($value)) {
-            return $this->options[$key];
+            return $this->options[$key] ?? null;
         }
 
         $this->options[$key] = $value;
@@ -695,6 +695,13 @@ HTML;
         return $this;
     }
 
+    protected function setUpOptions()
+    {
+        if ($this->options['show_bordered']) {
+            $this->tableCollapse(false);
+        }
+    }
+
     /**
      * Disable row selector.
      *
@@ -942,6 +949,8 @@ HTML;
             $this->build();
 
             $this->applyFixColumns();
+
+            $this->setUpOptions();
         } catch (\Throwable $e) {
             return Admin::makeExceptionHandler()->handle($e);
         }

+ 15 - 7
src/Grid/Displayers/Actions.php

@@ -11,7 +11,7 @@ use Illuminate\Contracts\Support\Renderable;
 
 class Actions extends AbstractDisplayer
 {
-    protected static $resolvedWindow;
+    protected static $resolvedDialog;
 
     /**
      * @var array
@@ -227,8 +227,10 @@ class Actions extends AbstractDisplayer
      */
     protected function renderView()
     {
+        $label = trans('admin.show');
+
         return <<<EOT
-<a href="{$this->resource()}/{$this->getKey()}">
+<a href="{$this->resource()}/{$this->getKey()}" title="{$label}">
     <i class="feather icon-eye grid-action-icon"></i>
 </a>&nbsp;
 EOT;
@@ -241,8 +243,10 @@ EOT;
      */
     protected function renderEdit()
     {
+        $label = trans('admin.edit');
+
         return <<<EOT
-<a href="{$this->resource()}/{$this->getKey()}/edit">
+<a href="{$this->resource()}/{$this->getKey()}/edit" title="{$label}">
     <i class="feather icon-edit-1 grid-action-icon"></i>
 </a>&nbsp;
 EOT;
@@ -253,8 +257,8 @@ EOT;
      */
     protected function renderQuickEdit()
     {
-        if (! static::$resolvedWindow) {
-            static::$resolvedWindow = true;
+        if (! static::$resolvedDialog) {
+            static::$resolvedDialog = true;
 
             [$width, $height] = $this->grid->option('dialog_form_area');
 
@@ -264,8 +268,10 @@ EOT;
                 ->success('Dcat.reload()');
         }
 
+        $label = trans('admin.quick_edit');
+
         return <<<EOF
-<a class="{$this->grid->getRowName()}-edit" data-url="{$this->resource()}/{$this->getKey()}/edit" href="javascript:void(0);">
+<a title="{$label}" class="{$this->grid->getRowName()}-edit" data-url="{$this->resource()}/{$this->getKey()}/edit" href="javascript:void(0);">
     <i class="feather icon-edit grid-action-icon"></i>
 </a>&nbsp;
 EOF;
@@ -278,8 +284,10 @@ EOF;
      */
     protected function renderDelete()
     {
+        $label = trans('admin.delete');
+
         return <<<EOT
-<a href="javascript:void(0);" data-message="ID - {$this->getKey()}" data-url="{$this->resource()}/{$this->getKey()}" data-action="delete">
+<a title="{$label}" href="javascript:void(0);" data-message="ID - {$this->getKey()}" data-url="{$this->resource()}/{$this->getKey()}" data-action="delete">
     <i class="feather icon-trash grid-action-icon"></i>
 </a>&nbsp;
 EOT;