diff --git a/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php b/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php index efbc18e645..c9478c054a 100644 --- a/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php +++ b/app/Http/Livewire/CustomFieldSetDefaultValuesForModel.php @@ -15,43 +15,21 @@ class CustomFieldSetDefaultValuesForModel extends Component public $fields; public $model_id; - - public function __construct() - { - \Log::info("INSTANTIATING A THING!!!"); // WORKS! - \Log::info("MY COMPONENT ID IS: ".$this->id); - } - - public function foo() - { - \Log::info("Uh, foo?"); - } - public function mount() { $this->model = AssetModel::find($this->model_id); // It's possible to do some clever route-model binding here, but let's keep it simple, shall we? $this->fieldset_id = $this->model->fieldset_id; $this->fields = CustomFieldset::find($this->fieldset_id)->fields; $this->add_default_values = ( $this->model->defaultValues->count() > 0); - \Log::error("Model ID is: ".$this->model_id." And its fieldset is: ".$this->fieldset_id); - \Log::error("Mount at least fired, that's got to count for something, yeah?"); //WORKS! YAY! - - } - - public function updatingFielsetId() - { - \Log::error("ABOUT TO UPDATE FIELDSET ID!!!"); } public function updatedFieldsetId() { - \Log::error("UPDATED FIELDSET ID!!!!!!"); $this->fields = CustomFieldset::find($this->fieldset_id)->fields; } public function render() { - //return '
Hi: {{ $this->add_default_values ? "TRUTH" : "FALSEHOOD" }} yeah?
'; return view('livewire.custom-field-set-default-values-for-model'); } } diff --git a/resources/views/livewire/custom-field-set-default-values-for-model.blade.php b/resources/views/livewire/custom-field-set-default-values-for-model.blade.php index e1c689a9cf..b296b7bc56 100644 --- a/resources/views/livewire/custom-field-set-default-values-for-model.blade.php +++ b/resources/views/livewire/custom-field-set-default-values-for-model.blade.php @@ -1,31 +1,20 @@ -
+ {{-- This doesn't seem to fix it, neither does a div? --}}
{{-- wire:ignore is because Select 2 mangles the dom in many awful ways, and so does iCheckbox --}}
- {{ Form::select('custom_fieldset', Helper::customFieldsetList(),old('custom_fieldset', 0000 /*$item->fieldset_id*/), array('class'=>'select2 js-fieldset-field', 'style'=>'width:350px', 'aria-label'=>'custom_fieldset', 'wire:model' => 'fieldset_id','id' => 'glooobits')) }} {{-- when we have this wrapped in 'ignore', the wire:model won't work --}} + {{ Form::select('custom_fieldset', Helper::customFieldsetList(), old('custom_fieldset', $fieldset_id), array('class'=>'select2 js-fieldset-field', 'style'=>'width:350px', 'aria-label'=>'custom_fieldset', 'wire:model' => 'fieldset_id', 'id' => 'glooobits')) }} {{-- when we have this wrapped in 'ignore', the wire:model won't work --}} {!! $errors->first('custom_fieldset', '') !!}
- @if($this->add_default_values) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}} + @if( $this->add_default_values ) {{-- 'if the checkbox is enabled *AND* there are more than 0 fields in the fieldsset' --}}
- - {{-- GET READY TO ADD ME SOME CRAAAAAAZY DEFAULT VALUES MOTHER FLIPPER! For, of course, fieldset: {{ $fieldset_id }} --}} - {{-- @livewire('custom-fields-for-fieldset',['fieldset_id' => $fieldset_id]) --}} - - {{-- NOTE: This stuff could work well also for the 'view this asset and do its custom fields' thing --}} - {{-- I don't know if we break *here* or if we break per field element? --}} @foreach ($fields as $field)
@@ -36,17 +25,21 @@ @if ($field->element == "text") @elseif($field->element == "textarea") -
+
@elseif($field->element == "listbox") - - @foreach($field->field_values as $field_value) - + @foreach(explode("\r\n", $field->field_values) as $field_value) + @endforeach + @elseif($field->element == "radio") + @foreach(explode("\r\n", $field->field_values) as $field_value) + defaultValue($model_id) == $field_value ? 'checked="checked"': '' }} />{{ $field_value }}
+ @endforeach @elseif($field->element == "checkbox") - + defaultValue($model_id) ? 'checked="checked"': '' }}/> @else Unknown field element: {{ $field->element }} @@ -61,38 +54,33 @@
@endif @push('js') @endpush -
+ diff --git a/resources/views/models/edit.blade.php b/resources/views/models/edit.blade.php index e782cf3cbe..9f8b22a249 100755 --- a/resources/views/models/edit.blade.php +++ b/resources/views/models/edit.blade.php @@ -34,29 +34,7 @@
-
- {{--
- -
- {{ Form::select('custom_fieldset', Helper::customFieldsetList(),old('custom_fieldset', $item->fieldset_id), array('class'=>'select2 js-fieldset-field', 'style'=>'width:350px', 'aria-label'=>'custom_fieldset')) }} - {!! $errors->first('custom_fieldset', '') !!} - -
-
--}} - - {{-- - --}} - @livewire('custom-field-set-default-values-for-model',["model_id" => $item->id]) - -
+@livewire('custom-field-set-default-values-for-model',["model_id" => $item->id]) @include ('partials.forms.edit.notes') @include ('partials.forms.edit.requestable', ['requestable_text' => trans('admin/models/general.requestable')]) @@ -80,14 +58,4 @@ @include ('partials.forms.edit.image-upload') -@stop -@push('js') -console.log("hi there") -@endpush -{{-- @section('moar_scripts') - -@endsection --}} +@stop \ No newline at end of file