]> _ Git - cubist_cms-back.git/commitdiff
wip #4612 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Jul 2021 14:51:01 +0000 (16:51 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 26 Jul 2021 14:51:01 +0000 (16:51 +0200)
src/app/Magic/BunchOfFields.php
src/app/Magic/Fields/Field.php

index 92c181d28b22e49adb12c8d8b7d9a9620445cdf7..617a015255e4c56d06b147d7d93073aca6fc6e14 100644 (file)
@@ -69,6 +69,15 @@ trait BunchOfFields
      */
     public function getField($name)
     {
-        return isset($this->_fields[$name]) ? $this->_fields[$name] : null;
+        return $this->_fields[$name] ?? null;
+    }
+
+    /**
+     * @param $name string
+     * @return bool
+     */
+    public function hasField($name): bool
+    {
+        return isset($this->_fields[$name]);
     }
 }
index bd9983ec383ff4c2fb55623cc702b068a8f65431..42caacda3246b320d185be3358de0c6932124c65 100644 (file)
@@ -23,6 +23,7 @@ class Field implements \ArrayAccess
     protected $_columnType = 'text';
     protected $_columnMoveAfter = false;
     protected $_columnFormat = null;
+
     protected $_preview = true;
 
     protected $_filterType = 'simple';
@@ -132,7 +133,8 @@ class Field implements \ArrayAccess
             'fillable' => true, 'guarded' => false, 'hidden' => false,
             'filter' => false, 'filter_type' => $this->_filterType, 'filter_label' => null, 'filter_values' => $this->_filterValues,
             'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable,
-            'preview' => $this->_preview, 'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat,
+            'preview' => $this->_preview,
+            'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'column_width' => 300,
             'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
             'allow_null' => true,
             'can' => $this->_can, 'can_write' => $this->_canWrite, 'auth' => $this->_auth,
@@ -203,6 +205,14 @@ class Field implements \ArrayAccess
             'orderable' => true,
         ];
 
+        if ($this->hasAttribute('column_function_name')) {
+            $res['function_name'] = $this->getAttribute('column_function_name');
+        }
+
+        if ($this->hasAttribute('column_limit')) {
+            $res['limit'] = $this->getAttribute('column_limit');
+        }
+
 
         return $res;
     }
@@ -357,7 +367,8 @@ class Field implements \ArrayAccess
         return $value;
     }
 
-    public function filterDefault($value){
+    public function filterDefault($value)
+    {
         return $value;
     }