Sfoglia il codice sorgente

Merge branch 'master' into 2.0

jqh 5 anni fa
parent
commit
c682ebbc53

+ 0 - 1
resources/assets/dcat/extra/action.js

@@ -129,7 +129,6 @@
 
             return new Promise(function (resolve, reject) {
                 Object.assign(data, {
-                    _token: Dcat.token,
                     _action: options.calledClass,
                     _key: options.key,
                 });

+ 2 - 4
resources/assets/dcat/extra/grid-extend.js

@@ -95,9 +95,7 @@
             _this._req = 1;
             Dcat.loading();
 
-            var data = {
-                _token: Dcat.token,
-            };
+            var data = {};
 
             data[_this.options.parentIdQueryName] = key;
             data[_this.options.tierQueryName] = tier + 1;
@@ -232,7 +230,7 @@
             $.ajax({
                 type: 'POST',
                 url: _this.options.url.replace(':key', key),
-                data: {_method:'PUT', _token:Dcat.token, _orderable:direction},
+                data: {_method:'PUT', _orderable:direction},
                 success: function(data){
                     Dcat.loading(false);
                     _this._req = 0;

+ 0 - 2
resources/assets/dcat/js/bootstrappers/DataActions.js

@@ -23,7 +23,6 @@ let defaultActions = {
                     url: url,
                     data: {
                         _method: 'delete',
-                        _token: Dcat.token,
                     },
                     success: function (data) {
                         Dcat.NP.done();
@@ -56,7 +55,6 @@ let defaultActions = {
                     url: url + '/' + keys.join(','),
                     data: {
                         _method: 'delete',
-                        _token: Dcat.token,
                     },
                     success: function (data) {
                         Dcat.NP.done();

+ 9 - 6
resources/assets/dcat/js/dcat-app.js

@@ -82,12 +82,6 @@ function extend (Dcat) {
 function listen(Dcat) {
     // 只初始化一次
     Dcat.booting(() => {
-        // ajax全局设置
-        $.ajaxSetup({
-            cache: true,
-            error: Dcat.handleAjaxError
-        });
-
         Dcat.NP.configure({parent: '.app-content'});
 
         // layer弹窗设置
@@ -103,6 +97,15 @@ function listen(Dcat) {
 
     // 每个请求都初始化
     Dcat.bootingEveryRequest(() => {
+        // ajax全局设置
+        $.ajaxSetup({
+            cache: true,
+            error: Dcat.handleAjaxError,
+            headers: {
+                'X-CSRF-TOKEN': Dcat.token
+            }
+        });
+
         // pjax初始化功能
         new Pjax(Dcat);
         // data-action 动作绑定(包括删除、批量删除等操作)

File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/action.js


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/action.js.map


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/extra/grid-extend.js.map


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/js/dcat-app.js


File diff suppressed because it is too large
+ 0 - 0
resources/dist/dcat/js/dcat-app.js.map


+ 1 - 1
resources/views/helpers/scaffold.blade.php

@@ -329,7 +329,7 @@
 
             withSingularName(tb);
 
-            $.post('{{ admin_url('helpers/scaffold/table') }}', {db: db, tb: tb, _token: Dcat.token}, function (res) {
+            $.post('{{ admin_url('helpers/scaffold/table') }}', {db: db, tb: tb}, function (res) {
                 Dcat.loading(false);
 
                 if (!res.list) return;

+ 1 - 3
src/Extension/Grid/ImportButton.php

@@ -39,9 +39,7 @@ $('.import-extension').on('click', function () {
         req = 1;
         
         Dcat.loading();
-        $.post('$url?id='+id, {
-            _token: Dcat.token,
-        }, function (response) {
+        $.post('$url?id='+id, {}, function (response) {
            Dcat.loading(false);
            req = 0;
         

+ 9 - 1
src/Form/Builder.php

@@ -806,9 +806,17 @@ class Builder
             $this->form->updatedAtColumn(),
         ];
 
-        $this->fields = $this->fields()->reject(function (Field $field) use (&$reservedColumns) {
+        $reject = function (Field $field) use (&$reservedColumns) {
             return in_array($field->column(), $reservedColumns)
                 && $field instanceof Form\Field\Display;
+        };
+
+        $this->fields = $this->fields()->reject($reject);
+        
+        $this->form->getTab()->getTabs()->transform(function($item) use ($reject) {
+            $item['fields'] = $item['fields']->reject($reject);
+
+            return $item;
         });
     }
 

+ 16 - 18
src/Form/Field.php

@@ -493,41 +493,39 @@ class Field implements Renderable
      */
     public function options($options = [])
     {
-        $this->options = $this->prepareOptions($options);
+        if ($options instanceof \Closure) {
+            $options = $options->call($this->data(), $this->value());
+        }
+
+        $this->options = array_merge($this->options, Helper::array($options));
 
         return $this;
     }
 
     /**
-     * @param array|Arrayable $options
+     * @param array $options
      *
      * @return $this
      */
-    public function mergeOptions($options)
+    public function replaceOptions($options)
     {
-        $this->options = array_merge($this->options, $this->prepareOptions($options));
+        if ($options instanceof \Closure) {
+            $options = $options->call($this->data(), $this->value());
+        }
+
+        $this->options = $options;
 
         return $this;
     }
 
     /**
-     * Prepare options.
-     *
-     * @param $options
+     * @param array|Arrayable $options
      *
-     * @return array|mixed
+     * @return $this
      */
-    protected function prepareOptions($options)
+    public function mergeOptions($options)
     {
-        if ($options instanceof \Closure) {
-            $options = $options->call($this->data(), $this->value());
-        }
-
-        if ($options instanceof Arrayable) {
-            $options = $options->toArray();
-        }
-
-        return $options;
+        return $this->options($options);
     }
 
     /**

+ 0 - 1
src/Grid/Displayers/Checkbox.php

@@ -71,7 +71,6 @@ EOT;
     
         var data = {
             {$this->column->getName()}: values,
-            _token: Dcat.token,
             _method: 'PUT'
         };
         

+ 0 - 1
src/Grid/Displayers/Editable.php

@@ -79,7 +79,6 @@ $('.{$this->selector}+.save').on("click",function() {
     value = tmp.text().replace(new RegExp("<br>","g"), '').replace(new RegExp("&nbsp;","g"), '').trim();
     
     var data = {
-        _token: Dcat.token,
         _method: 'PUT'
     };
     if (name.indexOf('.') === -1) {

+ 0 - 1
src/Grid/Displayers/Radio.php

@@ -70,7 +70,6 @@ EOT;
             type: "POST",
             data: {
                 {$this->column->getName()}: value,
-                _token: Dcat.token,
                 _method: 'PUT'
             },
             success: function (data) {

+ 0 - 1
src/Grid/Displayers/Select.php

@@ -48,7 +48,6 @@ $('.{$this->selector}').off('change').select2().on('change', function(){
         name = $(this).data('name'),
         url = $(this).data('url'),
         data = {
-            _token: Dcat.token,
             _method: 'PUT'
         },
         reload = '{$refresh}';

+ 0 - 1
src/Grid/Displayers/SwitchDisplay.php

@@ -67,7 +67,6 @@ EOF;
          checked = that.is(':checked'),
          name = that.attr('name'), 
          data = {
-            _token: Dcat.token,
             _method: 'PUT'
          },
          value = checked ? 1 : 0;

+ 0 - 1
src/Grid/Displayers/SwitchGroup.php

@@ -72,7 +72,6 @@ EOT;
             checked = that.is(':checked'), 
             name = that.attr('name'), 
             data = {
-                _token: Dcat.token,
                 _method: 'PUT'
             },
             value = checked ? 1 : 0;

+ 1 - 1
src/Traits/InteractsWithApi.php

@@ -211,7 +211,7 @@ trait InteractsWithApi
           url: '{$this->getRequestUrl()}',
           dataType: 'json',
           method: '{$this->method}',
-          data: $.extend({_token: Dcat.token}, data),
+          data: data,
           success: function (response) {
             loading = 0;
             {$fetched};

+ 0 - 1
src/Tree.php

@@ -370,7 +370,6 @@ class Tree implements Renderable
         var serialize = tree.nestable('serialize'), _this = $(this);
         _this.buttonLoading();
         $.post('{$this->url}', {
-            _token: Dcat.token,
             _order: JSON.stringify(serialize)
         },
         function (data) {

Some files were not shown because too many files changed in this diff