]> _ Git - cubist_cms-back.git/commitdiff
wip #3359 @1
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Jan 2020 18:24:06 +0000 (19:24 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Tue, 21 Jan 2020 18:24:06 +0000 (19:24 +0100)
src/app/Magic/Controllers/CubistMagicController.php
src/app/Magic/Fields/Field.php
src/app/Magic/Fields/SiteVariant.php
src/app/Magic/Models/CMSPage.php
src/resources/views/columns/select_from_array.blade.php

index c2ad3f57edb4c017e69fa318644c5d6a9567463c..b22fbf5b1934ab8f29cc4ae73839e51716c0151b 100644 (file)
@@ -140,9 +140,15 @@ class CubistMagicController extends CubistCrudController
         /** @var $field Field */
         if ($field->isDisplayColumn()) {
             $this->crud->addColumn($field->getColumnData());
+            $moveAfter = $field->getAttribute('column_move_after', false);
+            if ($moveAfter !== false) {
+                $this->crud->afterColumn($moveAfter);
+            }
         }
         $this->crud->addField($field->getDefinition(), $field->getCRUDForm());
 
+        $this->crud->orderFields(['id','variant']);
+
         $this->_fields[$field->getAttribute('name')] = $field;
     }
 
index b05ccd9284787be0edc89892e3675f4c52812108..cc5c373c9d55124a6e5bd39d15ed6ce36f6fdddf 100644 (file)
@@ -16,6 +16,8 @@ class Field implements \ArrayAccess
     protected $_rules = [];
     protected $_columnType = 'text';
 
+    protected $_columnMoveAfter = false;
+
     protected $_adminType = 'text';
     protected $_viewNamespace = 'crud::fields';
     protected $_columnViewNamespace = 'crud::columns';
@@ -99,7 +101,8 @@ class Field implements \ArrayAccess
         return ['type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '',
             'fillable' => true, 'guarded' => false, 'hidden' => false,
             'translatable' => $this->_translatable, 'migrateTranslatable' => $this->_migrateTranslatable,
-            'column_type' => $this->_columnType, 'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
+            'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter,
+            'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
             'allow_null' => true,
             'fake' => false, 'store_in' => 'extras', 'attributes' => []];
     }
@@ -225,4 +228,9 @@ class Field implements \ArrayAccess
     {
         return $value;
     }
+
+    public function filterColumn($value)
+    {
+        return $value;
+    }
 }
index d624633d8f7ec3b246955e7a218826fac908bf1f..ebb08b6c612fc304d58dd9e0b5d3cca5c57949c9 100644 (file)
@@ -19,6 +19,8 @@ class SiteVariant extends SelectFromArray
             $attributes['options'] = ['default' => 'default'];
             $attributes['default'] = 'default';
         } else {
+            $attributes['column'] = true;
+            $attributes['column_move_after'] = 'id';
             $attributes['options'] = array_combine($variants, $variants);
             $attributes['default'] = array_values($attributes['options']);
         }
index 75038fd8a295ceca9af5d962cb6f2a2fb794f5bb..532e20963e317d5a380da890a62fb2af3e8553ea 100644 (file)
@@ -49,7 +49,7 @@ class CMSPage extends CubistMagicNestedModel
             'label' => trans('Page name'),
             'type' => 'Text',
             'column' => true,
-            'column_move_after'=>'id',
+            'column_move_after' => 'id',
             'translatable' => false,
             'hint' => trans('for admin use'),
             'tab' => 'Informations principales',
index a722fead1cf5fd104c8bc73a7878622384fd6180..63070b181b646297631691316278d76ef47d1f0d 100644 (file)
                 $array_of_values[] = $column['options'][$value];
             }
 
-            if (count($array_of_values) > 1) {
-                echo implode(', ', $array_of_values);
-            } else {
-                echo $array_of_values;
-            }
+            echo implode(', ', $array_of_values);
         } else {
             if (isset($column['options'][$values])) {
                 echo $column['options'][$values];
-            }else{
+            } else {
                 echo '-';
             }
         }