]> _ Git - cubist_cms-back.git/commitdiff
wip #6775 @2
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Mar 2024 17:32:26 +0000 (18:32 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 18 Mar 2024 17:32:26 +0000 (18:32 +0100)
src/app/Magic/Fields/BunchOfFieldsMultiple.php
src/resources/views/fields/bunch_multiple.blade.php

index e9d1e6fae718639403b46ea68652a12caf8080ce..ea49bce4b12601a42166c4f688296bb9e4771d68 100644 (file)
@@ -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);
+
     }
 
 }
index ecfdb308328a000a0d41b4bbf5b444416a2503a5..af41c6129e0daedf3cf8fe95eec230ec7364f48a 100644 (file)
         <div class="bunchmultiple__items" data-bmid="{!! $field['rand'] !!}">
             <div class="item sample" data-bmid="{!! $field['rand'] !!}">
                 <div class="legend" data-bmid="{!! $field['rand'] !!}">
+                    @if($field['allows_reorder'])
                     <a href="#" class="action sort-handle" data-bmid="{!! $field['rand'] !!}">
                         <i class="la la-sort" role="presentation" aria-hidden="true"></i>
                     </a>
+                    @endif
                     <span class="legendsize" data-legend="{{$field['edit_label']}}"
                           data-bmid="{!! $field['rand'] !!}"></span>
                     <a href="#" class="action edit" data-bmid="{!! $field['rand'] !!}">
                         <i class="la la-pencil" role="presentation" aria-hidden="true"></i>
                     </a>
+                    @if($field['allows_clone'])
                     <a href="#" class="action duplicate" data-bmid="{!! $field['rand'] !!}">
                         <i class="las la-copy"></i>
                     </a>
-                    <a href="#" class="action remove" data-bmid="{!! $field['rand'] !!}">
-                        <i class="la la-trash" role="presentation" aria-hidden="true"></i>
-                    </a>
-
+                    @endif
+                    @if($field['allows_delete'])
+                        <a href="#" class="action remove" data-bmid="{!! $field['rand'] !!}">
+                            <i class="la la-trash" role="presentation" aria-hidden="true"></i>
+                        </a>
+                    @endif
+                    <a>&nbsp;</a>
                 </div>
                 <div class="subform" data-bmid="{!! $field['rand'] !!}">
                     @include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields'],'bmid'=>$field['rand']))
             </div>
         </div>
 
-        <div class="btn-group m-t-10">
-            <button class="btn btn-sm btn-default additem" data-bmid="{!! $field['rand'] !!}" type="button"><i
-                    class="la la-plus"></i> {{$field['add_label']}}</button>
-        </div>
+        @if($field['allows_add'])
+            <div class="btn-group m-t-10">
+                <button class="btn btn-sm btn-default additem" data-bmid="{!! $field['rand'] !!}" type="button"><i
+                        class="la la-plus"></i> {{$field['add_label']}}</button>
+            </div>
+        @endif
 
         <div class="clearfix"></div>