瀏覽代碼

Merge branch '2.0' into gitee2

jqh 4 年之前
父節點
當前提交
7742034c83

+ 10 - 0
resources/assets/dcat/sass/components/_button.scss

@@ -136,6 +136,16 @@ a.btn-sm, .btn-group-sm > a.btn {
   color: #444!important;
 }
 
+.btn-secondary {
+  border-color: darken($border-color, 2.2%)!important;
+  background-color: lighten(#eee, 2.5%)!important;
+  color: $font-color!important;
+  box-shadow: none;
+}
+.btn-secondary:hover, .btn-secondary:focus {
+  box-shadow: $btn-shadow-hover!important;
+}
+
 .btn-no-shadow {
   box-shadow: none;
 }

+ 1 - 1
resources/assets/dcat/sass/mixins/_scrollbar.scss

@@ -8,7 +8,7 @@
     background-color: #eee;
   }
   #{$selector}::-webkit-scrollbar-thumb {
-    background-color: darken(#ddd, 8%);
+    background-color: darken(#ddd, 7.5%);
     border-radius: .4rem;
   }
 }

文件差異過大導致無法顯示
+ 0 - 0
resources/dist/adminlte/adminlte-blue-light.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/adminlte/adminlte-blue.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/adminlte/adminlte-green.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/dcat/css/dcat-app-blue-light.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/dcat/css/dcat-app-blue.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/dcat/css/dcat-app-green.css


文件差異過大導致無法顯示
+ 0 - 0
resources/dist/dcat/css/dcat-app.css


+ 1 - 1
src/Admin.php

@@ -159,7 +159,7 @@ class Admin
     }
 
     /**
-     * 启用或禁用Pjax
+     * 启用或禁用Pjax.
      *
      * @param bool $value
      *

+ 3 - 3
src/Contracts/Repository.php

@@ -77,7 +77,7 @@ interface Repository
      *
      * @param Form $form
      *
-     * @return mixed
+     * @return int|bool|\Dcat\Admin\Http\JsonResponse
      */
     public function store(Form $form);
 
@@ -95,7 +95,7 @@ interface Repository
      *
      * @param Form $form
      *
-     * @return bool
+     * @return bool|\Dcat\Admin\Http\JsonResponse
      */
     public function update(Form $form);
 
@@ -105,7 +105,7 @@ interface Repository
      * @param Form  $form
      * @param array $deletingData
      *
-     * @return mixed
+     * @return mixed|\Dcat\Admin\Http\JsonResponse
      */
     public function delete(Form $form, array $deletingData);
 

+ 16 - 0
src/Form.php

@@ -11,6 +11,7 @@ use Dcat\Admin\Form\Concerns;
 use Dcat\Admin\Form\Condition;
 use Dcat\Admin\Form\Field;
 use Dcat\Admin\Form\NestedForm;
+use Dcat\Admin\Http\JsonResponse;
 use Dcat\Admin\Support\Helper;
 use Dcat\Admin\Traits\HasBuilderEvents;
 use Dcat\Admin\Traits\HasFormResponse;
@@ -568,6 +569,11 @@ class Form implements Renderable
 
             $result = $this->repository->delete($this, $data);
 
+            // 返回 JsonResponse 对象,直接中断后续逻辑
+            if ($result instanceof JsonResponse) {
+                return $this->sendResponse($result);
+            }
+
             if ($response = $this->callDeleted($result)) {
                 return $this->sendResponse($response);
             }
@@ -628,6 +634,11 @@ class Form implements Renderable
 
             $id = $this->repository->store($this);
 
+            // 返回 JsonResponse 对象,直接中断后续逻辑
+            if ($id instanceof JsonResponse) {
+                return $this->sendResponse($id);
+            }
+
             $this->builder->setResourceId($id);
 
             if (($response = $this->callSaved($id))) {
@@ -804,6 +815,11 @@ class Form implements Renderable
 
             $updated = $this->repository->update($this);
 
+            // 返回 JsonResponse 对象,直接中断后续逻辑
+            if ($updated instanceof JsonResponse) {
+                return $this->sendResponse($updated);
+            }
+
             if ($response = $this->callSaved($updated)) {
                 return $this->sendResponse($response);
             }

+ 54 - 54
src/Form/Field/CanLoadFields.php

@@ -1,54 +1,54 @@
-<?php
-
-namespace Dcat\Admin\Form\Field;
-
-use Illuminate\Support\Str;
-
-trait CanLoadFields
-{
-    /**
-     * 联动加载.
-     *
-     * @param string $field
-     * @param string $sourceUrl
-     * @param string $idField
-     * @param string $textField
-     *
-     * @return $this
-     */
-    public function load($field, $sourceUrl, string $idField = 'id', string $textField = 'text')
-    {
-        return $this->loads($field, $sourceUrl, $idField, $textField);
-    }
-
-    /**
-     * 联动加载多个字段.
-     *
-     * @param array|string $fields
-     * @param array|string $sourceUrls
-     * @param string $idField
-     * @param string $textField
-     *
-     * @return $this
-     */
-    public function loads($fields = [], $sourceUrls = [], string $idField = 'id', string $textField = 'text')
-    {
-        $fieldsStr = implode('^', array_map(function ($field) {
-            if (Str::contains($field, '.')) {
-                return $this->normalizeElementClass($field).'_';
-            }
-
-            return $this->normalizeElementClass($field);
-        }, (array) $fields));
-        $urlsStr = implode('^', array_map(function ($url) {
-            return admin_url($url);
-        }, (array) $sourceUrls));
-
-        return $this->addVariables(['loads' => [
-            'fields'    => $fieldsStr,
-            'urls'      => $urlsStr,
-            'idField'   => $idField,
-            'textField' => $textField,
-        ]]);
-    }
-}
+<?php
+
+namespace Dcat\Admin\Form\Field;
+
+use Illuminate\Support\Str;
+
+trait CanLoadFields
+{
+    /**
+     * 联动加载.
+     *
+     * @param string $field
+     * @param string $sourceUrl
+     * @param string $idField
+     * @param string $textField
+     *
+     * @return $this
+     */
+    public function load($field, $sourceUrl, string $idField = 'id', string $textField = 'text')
+    {
+        return $this->loads($field, $sourceUrl, $idField, $textField);
+    }
+
+    /**
+     * 联动加载多个字段.
+     *
+     * @param array|string $fields
+     * @param array|string $sourceUrls
+     * @param string $idField
+     * @param string $textField
+     *
+     * @return $this
+     */
+    public function loads($fields = [], $sourceUrls = [], string $idField = 'id', string $textField = 'text')
+    {
+        $fieldsStr = implode('^', array_map(function ($field) {
+            if (Str::contains($field, '.')) {
+                return $this->normalizeElementClass($field).'_';
+            }
+
+            return $this->normalizeElementClass($field);
+        }, (array) $fields));
+        $urlsStr = implode('^', array_map(function ($url) {
+            return admin_url($url);
+        }, (array) $sourceUrls));
+
+        return $this->addVariables(['loads' => [
+            'fields'    => $fieldsStr,
+            'urls'      => $urlsStr,
+            'idField'   => $idField,
+            'textField' => $textField,
+        ]]);
+    }
+}

+ 19 - 2
src/Grid.php

@@ -41,8 +41,6 @@ class Grid
     const CREATE_MODE_DEFAULT = 'default';
     const CREATE_MODE_DIALOG = 'dialog';
 
-    const IFRAME_QUERY_NAME = '_grid_iframe_';
-
     /**
      * The grid data model instance.
      *
@@ -309,6 +307,25 @@ class Grid
         return $this->allColumns;
     }
 
+    /**
+     * 删除列.
+     *
+     * @param string|Column $column
+     *
+     * @return $this
+     */
+    public function dropColumn($column)
+    {
+        if ($column instanceof Column) {
+            $column = $column->getName();
+        }
+
+        $this->columns->offsetUnset($column);
+        $this->allColumns->offsetUnset($column);
+
+        return $this;
+    }
+
     /**
      * Add column to grid.
      *

+ 4 - 4
src/Repositories/Repository.php

@@ -124,7 +124,7 @@ abstract class Repository implements RepositoryInterface, TreeRepository
      *
      * @param Form $form
      *
-     * @return mixed
+     * @return int|bool|\Dcat\Admin\Http\JsonResponse
      */
     public function store(Form $form)
     {
@@ -136,7 +136,7 @@ abstract class Repository implements RepositoryInterface, TreeRepository
      *
      * @param Form $form
      *
-     * @return array
+     * @return array|\Illuminate\Contracts\Support\Arrayable
      */
     public function updating(Form $form)
     {
@@ -148,7 +148,7 @@ abstract class Repository implements RepositoryInterface, TreeRepository
      *
      * @param Form $form
      *
-     * @return bool
+     * @return bool|\Dcat\Admin\Http\JsonResponse
      */
     public function update(Form $form)
     {
@@ -161,7 +161,7 @@ abstract class Repository implements RepositoryInterface, TreeRepository
      * @param Form  $form
      * @param array $deletingData
      *
-     * @return mixed
+     * @return bool|int|\Dcat\Admin\Http\JsonResponse
      */
     public function delete(Form $form, array $deletingData)
     {

+ 2 - 1
src/Widgets/Lazy.php

@@ -4,6 +4,7 @@ namespace Dcat\Admin\Widgets;
 
 use Dcat\Admin\Contracts\LazyRenderable;
 use Dcat\Admin\Traits\InteractsWithRenderApi;
+use Illuminate\Support\Str;
 
 class Lazy extends Widget
 {
@@ -17,7 +18,7 @@ class Lazy extends Widget
         $this->setRenderable($renderable);
         $this->load($load);
 
-        $this->class($this->elementClass = 'lazy-box');
+        $this->class(['lazy-box', $this->elementClass = 'lazy-'.Str::random(8)]);
     }
 
     /**

+ 10 - 2
src/Widgets/LazyTable.php

@@ -3,6 +3,7 @@
 namespace Dcat\Admin\Widgets;
 
 use Dcat\Admin\Grid\LazyRenderable;
+use Illuminate\Support\Str;
 
 class LazyTable extends Widget
 {
@@ -29,6 +30,11 @@ class LazyTable extends Widget
      */
     protected $simple;
 
+    /**
+     * @var string
+     */
+    protected $loadScript = '';
+
     /**
      * LazyTable constructor.
      *
@@ -40,7 +46,7 @@ class LazyTable extends Widget
         $this->from($renderable);
         $this->load($load);
 
-        $this->class($this->elementClass = 'async-table');
+        $this->class(['async-table', $this->elementClass = 'async-table-'.Str::random(8)]);
     }
 
     /**
@@ -106,7 +112,7 @@ class LazyTable extends Widget
      */
     public function onLoad(string $script)
     {
-        $this->script .= "\$this.on('table:loaded', function (event) { {$script} });";
+        $this->loadScript .= "\$this.on('table:loaded', function (event) { {$script} });";
 
         return $this;
     }
@@ -117,6 +123,8 @@ class LazyTable extends Widget
 Dcat.init('{$this->getElementSelector()}', function (\$this) {
     Dcat.grid.AsyncTable({container: \$this})
 
+    {$this->loadScript}
+
     {$this->getLoadScript()}
 });
 JS;

+ 5 - 1
src/Widgets/Widget.php

@@ -14,7 +14,7 @@ use Illuminate\Contracts\Support\Renderable;
 use Illuminate\Support\Arr;
 
 /**
- * @method $this class(string $class, bool $append = false)
+ * @method $this class(array|string $class, bool $append = false)
  * @method $this style(string $style, bool $append = true)
  * @method $this id(string $id = null)
  */
@@ -314,6 +314,10 @@ abstract class Widget implements Renderable
             $value = $parameters[0] ?? null;
             $append = $parameters[1] ?? ($method === 'class' ? false : true);
 
+            if (is_array($value)) {
+                $value = implode(' ', $value);
+            }
+
             if ($append) {
                 $original = $this->htmlAttributes[$method] ?? '';
 

部分文件因文件數量過多而無法顯示