]> _ Git - cubist_cms-back.git/commitdiff
wait #5928 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 May 2023 17:43:22 +0000 (19:43 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 10 May 2023 17:43:22 +0000 (19:43 +0200)
src/app/Magic/Fields/Field.php
src/resources/views/columns/textwrap.blade.php [new file with mode: 0644]

index 7e932888cc8a8bcace8a9080468f6eda9b35de6a..8f9837a714e3a66120249ac702b8cb18ecd11888 100644 (file)
@@ -148,7 +148,7 @@ class Field implements \ArrayAccess
             '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, 'column_width' => 300, 'column_escape' => true,
+            'column_type' => $this->_columnType, 'column_move_after' => $this->_columnMoveAfter, 'column_format' => $this->_columnFormat, 'column_width' => 300, 'column_escape' => true, 'column_limit' => 50,
             'default' => $this->_default, 'non_default_tracking' => true,
             'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
             'allow_null' => true,
@@ -263,6 +263,7 @@ class Field implements \ArrayAccess
             'format' => $this->getAttribute('column_format', null),
             'orderable' => true,
             'escaped' => $this->getAttribute('column_escape', true),
+            'limit' => $this->getAttribute('column_limit', 50),
         ];
 
         if ($this->hasAttribute('column_function_name')) {
@@ -273,7 +274,6 @@ class Field implements \ArrayAccess
             $res['limit'] = $this->getAttribute('column_limit');
         }
 
-
         return $res;
     }
 
diff --git a/src/resources/views/columns/textwrap.blade.php b/src/resources/views/columns/textwrap.blade.php
new file mode 100644 (file)
index 0000000..ccd4f7d
--- /dev/null
@@ -0,0 +1,31 @@
+{{-- regular object attribute --}}
+@php
+    $column['value'] = $column['value'] ?? data_get($entry, $column['name']);
+    $column['escaped'] = $column['escaped'] ?? true;
+    $column['limit'] = $column['limit'] ?? 32;
+    $column['prefix'] = $column['prefix'] ?? '';
+    $column['suffix'] = $column['suffix'] ?? '';
+    $column['text'] = $column['default'] ?? '-';
+
+    if($column['value'] instanceof \Closure) {
+        $column['value'] = $column['value']($entry);
+    }
+
+    if(is_array($column['value'])) {
+        $column['value'] = json_encode($column['value']);
+    }
+
+    if(!empty($column['value'])) {
+        $column['text'] = $column['prefix'].Str::limit($column['value'], $column['limit'], '…').$column['suffix'];
+    }
+@endphp
+
+<span style="white-space: normal">
+    @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_start')
+        @if($column['escaped'])
+            {{ $column['text'] }}
+        @else
+            {!! $column['text'] !!}
+        @endif
+    @includeWhen(!empty($column['wrapper']), 'crud::columns.inc.wrapper_end')
+</span>