Przeglądaj źródła

Merge pull request #725 from ybid/2.0

Grid中使用show宽度不能100% Show Label支持自定义宽度
Jiang Qinghua 4 lat temu
rodzic
commit
f0e558bd14
3 zmienionych plików z 10 dodań i 11 usunięć
  1. 2 2
      resources/views/show/field.blade.php
  2. 1 1
      src/Grid.php
  3. 7 8
      src/Show/Field.php

+ 2 - 2
resources/views/show/field.blade.php

@@ -1,9 +1,9 @@
 <div class="show-field form-group row">
-    <div class="col-sm-2 control-label">
+    <div class="col-sm-{{ $width['label'] }} control-label">
         <span>{{ $label }}</span>
     </div>
 
-    <div class="col-sm-{{ $width }}">
+    <div class="col-sm-{{ $width['field'] }}">
         @if($wrapped)
             <div class="box box-solid box-default no-margin box-show">
                 <div class="box-body">

+ 1 - 1
src/Grid.php

@@ -613,7 +613,7 @@ class Grid
         }
 
         return <<<HTML
-<div class="card-header clearfix" style="border-bottom: 0;background: transparent;padding: 0">{$content}</div>
+<div class="card-header clearfix" style="border-bottom: 0;background: transparent;padding: 0"><div class="col-md-12">{$content}</div></div>
 HTML;
     }
 

+ 7 - 8
src/Show/Field.php

@@ -92,7 +92,7 @@ class Field implements Renderable
     /**
      * @var int
      */
-    protected $width = 8;
+    protected $width = ['field' => 8, 'label' => 2];
 
     /**
      * Field constructor.
@@ -136,15 +136,14 @@ class Field implements Renderable
     /**
      * @param int $width
      *
-     * @return $this|int
+     * @return $this|array
      */
-    public function width(int $width = null)
+    public function width(int $field = 8, int $label = 2)
     {
-        if ($width === null) {
-            return $this->width;
-        }
-
-        $this->width = $width;
+        $this->width = [
+            'label' => $label,
+            'field' => $field,
+        ];
 
         return $this;
     }