]> _ Git - cubist_cms-back.git/commitdiff
wip #6915 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 May 2024 11:57:40 +0000 (13:57 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 27 May 2024 11:57:40 +0000 (13:57 +0200)
src/app/Http/Controllers/CubistSelect2Controller.php
src/app/Magic/Models/CubistMagicAbstractModel.php
src/resources/views/fields/select2_from_array.blade.php
src/resources/views/when.blade.php

index 389e0927aaa3d1fd4769220f98f6680af31c2817..60bbb2e2b33d59ab47667133ce533b7bc54a79b5 100644 (file)
@@ -12,13 +12,6 @@ class CubistSelect2Controller
 {
     public function search($hash)
     {
-        if (!Auth::check()) {
-            return response(null)->setStatusCode('401');
-        }
-        if (!can('edition')) {
-            return response(null)->setStatusCode('403');
-        }
-
         $perPage = 10;
         $data = Cache::get('select2_' . $hash) ?? [];
         $term = request()->get('q', null);
index 08e9c480a69eca0a14964b67c2719ce8fd950878..bf5c251fa74fd354cb69758eb0a19f0b0500d175 100644 (file)
@@ -716,7 +716,7 @@ class CubistMagicAbstractModel extends Model implements HasMedia
                 $res->set($key, $v);
                 continue;
             }
-            $res->set($key, Json::decodeRecursive($v, Json::TYPE_ARRAY));
+            $res->setRaw($key, Json::decodeRecursive($v, Json::TYPE_ARRAY));
         }
         return $res;
     }
index 55044bc2cf849ae84e87ca2c636dc398b65f3a84..d8785673f6453a31702e93087267ae06f56421b6 100644 (file)
@@ -16,6 +16,7 @@
             if(is_scalar($o)){
                 return $o==$key;
             }
+            $o=\Cubist\Util\ArrayUtil::asArray($o);
             return in_array($key,$o);
         }
     }
@@ -28,22 +29,22 @@ if($ajax){
 }
 @endphp
 
-        <!-- select2 from array -->
+    <!-- select2 from array -->
 @include('crud::fields.inc.wrapper_start')
 <label>{!! $field['label'] !!}</label>
 @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)
     <input type="hidden" name="{{ $field['name'] }}" value=""/>
 @endif
 <select
-        name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
-        style="width: 100%"
-        @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
-        @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
-        @if($ajax) data-ajax="{{$field['ajax']}}" @endif
-        @if($allows_html) data-allow-html="1" @endif
-        data-options="{{ json_encode($field['options']) }}"
-        @if(isset($field['free']) && $field['free']) data-free="1" @endif
-        data-value="{{is_scalar($o)?$o:json_encode($o)}}"
+    name="{{ $field['name'] }}@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)[]@endif"
+    style="width: 100%"
+    @include('crud::fields.inc.attributes', ['default_class' =>  'form-control select2_from_array'])
+    @if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
+    @if($ajax) data-ajax="{{$field['ajax']}}" @endif
+    @if($allows_html) data-allow-html="1" @endif
+    data-options="{{ json_encode($field['options']) }}"
+    @if(isset($field['free']) && $field['free']) data-free="1" @endif
+    data-value="{{is_scalar($o)?$o:json_encode($o)}}"
 >
     @if (isset($field['allows_null']) && $field['allows_null']==true)
         @if($is_null)
@@ -98,8 +99,8 @@ if($ajax){
         <link href="{{ asset('packages/select2/dist/css/select2.min.css') }}" rel="stylesheet"
               type="text/css"/>
         <link
-                href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
-                rel="stylesheet" type="text/css"/>
+            href="{{ asset('packages/select2-bootstrap-theme/dist/select2-bootstrap.min.css') }}"
+            rel="stylesheet" type="text/css"/>
     @endpush
 
     {{-- FIELD JS - will be loaded in the after_scripts section --}}
index 99d17ec34e133b2b7af248de862694b5ae51d4d1..a4d2449957dd7149c199ed1c406cbdda0c86cd93 100644 (file)
@@ -85,6 +85,9 @@
                     if (condition.id === undefined) {
                         condition.id = '';
                     }
+                    if (condition.id === '_empty_' || condition.operator === 'empty') {
+                        return val.toString().length === 0;
+                    }
                     if (condition.id === '_not_empty_' || condition.operator === 'not_empty') {
                         return val.toString().length > 0;
                     }