From: Vincent Vanwaelscappel Date: Mon, 18 Mar 2024 17:32:26 +0000 (+0100) Subject: wip #6775 @2 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=45432b2da519950a38ce57aeae51da9900791c06;p=cubist_cms-back.git wip #6775 @2 --- diff --git a/src/app/Magic/Fields/BunchOfFieldsMultiple.php b/src/app/Magic/Fields/BunchOfFieldsMultiple.php index e9d1e6f..ea49bce 100644 --- a/src/app/Magic/Fields/BunchOfFieldsMultiple.php +++ b/src/app/Magic/Fields/BunchOfFieldsMultiple.php @@ -15,9 +15,14 @@ class BunchOfFieldsMultiple extends BunchOfFields protected $_show_empty = true; protected $_bunch = []; + protected $_allowsAdd = true; + protected $_allowsDelete = true; + protected $_allowsClone = true; + protected $_allowsReorder = true; + public function getDefaultAttributes() { - return array_merge(parent::getDefaultAttributes(), ['bunch' => $this->_bunch, "add_label" => __('Add an item'), 'show_empty' => $this->_show_empty]); + return array_merge(parent::getDefaultAttributes(), ['allows_add' => $this->_allowsAdd, 'allows_delete' => $this->_allowsDelete, 'allows_clone' => $this->_allowsClone, 'allows_reorder' => $this->_allowsReorder, 'bunch' => $this->_bunch, "add_label" => __('Add an item'), 'show_empty' => $this->_show_empty]); } public function _postSetAttributes() @@ -31,7 +36,7 @@ class BunchOfFieldsMultiple extends BunchOfFields break; } - $this->setAttributeIfNotSet('edit_label',__('Edit « %:name »',['name'=>$first])); + $this->setAttributeIfNotSet('edit_label', __('Edit « %:name »', ['name' => $first])); } protected function _setBunchOfFields() @@ -72,6 +77,7 @@ class BunchOfFieldsMultiple extends BunchOfFields $crudfields[$name] = $field->getDefinition(); } $this->setAttribute('bunchfields', $crudfields); + } } diff --git a/src/resources/views/fields/bunch_multiple.blade.php b/src/resources/views/fields/bunch_multiple.blade.php index ecfdb30..af41c61 100644 --- a/src/resources/views/fields/bunch_multiple.blade.php +++ b/src/resources/views/fields/bunch_multiple.blade.php @@ -24,21 +24,27 @@
+ @if($field['allows_reorder']) + @endif + @if($field['allows_clone']) - - - - + @endif + @if($field['allows_delete']) + + + + @endif +  
@include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields'],'bmid'=>$field['rand'])) @@ -46,10 +52,12 @@
-
- -
+ @if($field['allows_add']) +
+ +
+ @endif