]> _ Git - cubist_cms-back.git/commitdiff
wip #4211 @1.5
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Nov 2021 15:57:05 +0000 (16:57 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 5 Nov 2021 15:57:05 +0000 (16:57 +0100)
src/app/Magic/Fields/Locale.php
src/app/Magic/Fields/LocaleEnabled.php
src/resources/views/columns/fromfield.blade.php [new file with mode: 0644]

index cc9a25714db089ebdd9ce61b807010d718972fcf..b7317a3706b30db919c7d3acc3ca490f1c359e9a 100644 (file)
@@ -7,6 +7,8 @@ use Illuminate\Support\Facades\App;
 
 class Locale extends SelectFromArray
 {
+    protected $_limitToLocales = null;
+
     public function __construct($attributes)
     {
         $this->_options = $this->_getLocales();
@@ -19,6 +21,16 @@ class Locale extends SelectFromArray
     protected function _getLocales()
     {
         $list = \Cubist\Locale\Locale::getList(App::getLocale());
+        if ($this->_limitToLocales !== null) {
+            $limitedList = [];
+            foreach ($list as $code => $name) {
+                if (!in_array($code, $this->_limitToLocales)) {
+                    continue;
+                }
+                $limitedList[$code] = $name;
+            }
+            $list = $limitedList;
+        }
 
         $res = [];
         foreach ($list as $code => $name) {
index 8148c1a24057fb1bcf26c61dcde5904c8f2e7556..a38cb0e8f92a7e6a197d9f2715780f8b3b3678e2 100644 (file)
@@ -1,24 +1,8 @@
 <?php
 
-
 namespace Cubist\Backpack\Magic\Fields;
 
-use Illuminate\Support\Facades\App;
-
 class LocaleEnabled extends Locale
 {
-    /**
-     * @return array
-     */
-    protected function _getLocales()
-    {
-        $list = \Cubist\Locale\Locale::getList(App::getLocale());
-
-        $res = [];
-        foreach ($list as $code => $name) {
-            $res[$code] = $code . ' | ' . $name;
-        }
 
-        return $res;
-    }
 }
diff --git a/src/resources/views/columns/fromfield.blade.php b/src/resources/views/columns/fromfield.blade.php
new file mode 100644 (file)
index 0000000..c1b6150
--- /dev/null
@@ -0,0 +1,17 @@
+{{-- regular object attribute --}}
+@php
+    $value = data_get($entry, $column['name']);
+    $value = is_array($value) ? json_encode($value) : $value;
+    try{
+        $v=$entry->getField($column['name'])->filterColumn($value);
+    }catch (Exception $e){
+        $v=$value;
+    }
+
+@endphp
+
+<span>
+    @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_start')
+    {!!$v !!}
+    @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_end')
+</span>