protected $_adminType = 'bunch_multiple';
protected $_cast = 'array';
protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+ protected $_show_empty = true;
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['bunch' => [], "add_label" => __('Add an item')]);
+ return array_merge(parent::getDefaultAttributes(), ['bunch' => [], "add_label" => __('Add an item'), 'show_empty' => $this->_show_empty]);
}
public function _postSetAttributes()
class KeyValueBunchOfFieldsMultiple extends BunchOfFieldsMultiple
{
protected $_adminType = 'bunch_keyvalue_multiple';
+ protected $_show_empty = false;
}
var initValues = this.element.data('values');
- if (initValues.length === 0) {
+ if (initValues.length === 0 && this.element.hasClass('showEmpty')) {
this.initItem();
} else {
$.each(initValues, function (k, v) {
resize: function () {
this.element.find('.legendsize').each(function () {
var parent = $(this).closest('.legend');
- var aw = $(parent).innerWidth() - 130;
+ var aw = $(parent).innerWidth() - 100;
$(this).css({width: aw, maxWidth: aw, minWidth: aw});
});
},
removeItem: function (item) {
$(item).remove();
- if (this.element.find('.item' + this.bmidselector + ':not(.sample)').length === 0) {
- this.initItem();
+ if(this.element.hasClass('showEmpty') && this.element.find('.item' + this.bmidselector + ':not(.sample)').length === 0) {
+ this.initItem();
}
var $this = this;
}
?>
-<div class="bunchmultiple bunchmultiple_keyvalue" id="{!! $field['rand'] !!}" data-bunch-name="{{$field['name']}}" data-values="{{ $value }}">
+<div class="bunchmultiple bunchmultiple_keyvalue{{ ($field['show_empty']?' showEmpty':'') }}"
+ id="{!! $field['rand'] !!}" data-bunch-name="{{$field['name']}}" data-values="{{ $value }}">
<input type="hidden" class="hiddenfield" name="{{$field['name']}}" value="{{ $value }}"
data-bmid="{!! $field['rand'] !!}"/>
<div class="bunchmultiple__wrapper" data-bmid="{!! $field['rand'] !!}">
<div class="legendsize">
@include('cubist_back::inc.show_bunch_fields', array('bunchfields'=>$field['bunchfields'],'bmid'=>$field['rand'],'keyvalue'=>true))
</div>
- <a href="#" class="action edit" data-bmid="{!! $field['rand'] !!}"><i class="la la-pencil"
- role="presentation"
- aria-hidden="true"></i></a>
<a href="#" class="action remove" data-bmid="{!! $field['rand'] !!}"><i class="la la-trash"
role="presentation"
aria-hidden="true"></i></a>
}
?>
-<div class="bunchmultiple" id="{!! $field['rand'] !!}" data-bunch-name="{{$field['name']}}" data-values="{{ $value }}">
+<div class="bunchmultiple{{ ($field['show_empty']?' showEmpty':'') }}" id="{!! $field['rand'] !!}" data-bunch-name="{{$field['name']}}" data-values="{{ $value }}">
<input type="hidden" class="hiddenfield" name="{{$field['name']}}" value="{{ $value }}" data-bmid="{!! $field['rand'] !!}"/>
<div class="bunchmultiple__wrapper" data-bmid="{!! $field['rand'] !!}">
@include('crud::fields.inc.wrapper_start')
}
});
+ $('.bunchmultiple__items').each(function () {
+ if ($(this).find('.item:not(.sample)').length > 0) {
+ $(this).closest('.form-group').addClass('non-default');
+ } else {
+ $(this).closest('.form-group').removeClass('non-default');
+ }
+ });
+
$("#form_shortcuts nav a").each(function () {
var hasNonDefault = $($(this).attr('href')).closest('.card').find('.non-default').length > 0;
if (hasNonDefault) {
bottom: -8px;
}
+ .bunchfields .non-default::after, .bunchfields .live-change::after {
+ display: none;
+ }
+
+ .bunchmultiple__wrapper .non-default::after, .bunchmultiple__wrapper .live-change::after {
+ left: -20px;
+ }
+
#form_shortcuts .non-default::after {
left: -30px;
top: -0px;