From: Vincent Vanwaelscappel Date: Mon, 5 Dec 2022 14:35:37 +0000 (+0100) Subject: wait #5625 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=dba3961c66904568563f38baeaebec4cc73f7bb7;p=cubist_cms-back.git wait #5625 @2 --- diff --git a/src/app/Magic/Fields/Date.php b/src/app/Magic/Fields/Date.php index f6f986c..9ed2c5f 100644 --- a/src/app/Magic/Fields/Date.php +++ b/src/app/Magic/Fields/Date.php @@ -10,4 +10,5 @@ class Date extends Datetime protected $_cast = 'date'; protected $_columnType = 'date'; protected $_columnFormat = 'YYYY-MM-DD'; + protected $_pickerFormat = 'yyyy-mm-dd'; } diff --git a/src/app/Magic/Fields/Datetime.php b/src/app/Magic/Fields/Datetime.php index 3c61d48..e5a7c65 100644 --- a/src/app/Magic/Fields/Datetime.php +++ b/src/app/Magic/Fields/Datetime.php @@ -3,11 +3,14 @@ namespace Cubist\Backpack\Magic\Fields; +use Cubist\Backpack\Facades\App; +use Illuminate\Support\Facades\Session; + class Datetime extends Field { protected $_adminType = 'datetime_picker'; protected $_cast = 'datetime'; - protected $pickerOptions = ['format' => 'DD/MM/YYYY HH:mm', 'language' => 'fr']; + protected $_pickerFormat = 'yyyy-mm-dd hh:ii'; protected $_databaseType = 'datetime'; protected $_databaseIndex = true; protected $_columnType = 'datetime'; @@ -21,6 +24,18 @@ class Datetime extends Field public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['datetime_picker_options' => $this->pickerOptions]); + return array_merge(parent::getDefaultAttributes(), ['picker_format' => $this->_pickerFormat]); + } + + protected function _postSetAttributes() + { + parent::_postSetAttributes(); + $this->setAttributeIfNotSet('datetime_picker_options', $this->_getDatePickerOptions()); + $this->setAttributeIfNotSet('date_picker_options', $this->_getDatePickerOptions()); + } + + protected function _getDatePickerOptions() + { + return ['format' => $this->getAttribute('picker_format'), 'language' => __('fr'), 'todayHighlight' => true]; } } diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index 6227586..76abfaa 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -397,6 +397,15 @@ class Field implements \ArrayAccess { if (null !== $this->getAttribute('can', null)) { if (!self::can($this->getAttribute('can'))) { + $this->setAttribute('preview', false); + $this->setAttribute('filter', false); + $this->setAttribute('column', false); + $this->setAttribute('auth', false); + $this->setAttribute('type', 'noteditable'); + $this->setAttribute('view_namespace', CubistBackpackServiceProvider::NAMESPACE . '::fields'); + } + }else if (null !== $this->getAttribute('can_hidden', null)) { + if (!self::can($this->getAttribute('can_hidden'))) { $this->setAttribute('preview', false); $this->setAttribute('filter', false); $this->setAttribute('column', false); diff --git a/src/resources/views/fields/authhidden.blade.php b/src/resources/views/fields/authhidden.blade.php index e69de29..71052fa 100644 --- a/src/resources/views/fields/authhidden.blade.php +++ b/src/resources/views/fields/authhidden.blade.php @@ -0,0 +1,18 @@ +@php + // if not otherwise specified, the hidden input should take up no space in the form + $field['wrapper']['class'] = $field['wrapper']['class'] ?? $field['wrapperAttributes']['class'] ?? "hidden"; + $v=old(square_brackets_to_dots($field['name'])) ?? $field['value'] ?? $field['default'] ?? ''; + if(!is_string($v)){ + $v=json_encode($v); + } +@endphp + + +@include('crud::fields.inc.wrapper_start') + +@include('crud::fields.inc.wrapper_end') diff --git a/src/resources/views/fields/noteditable.blade.php b/src/resources/views/fields/noteditable.blade.php new file mode 100644 index 0000000..e69de29