Fix api sync Formulary orderby
This commit is contained in:
parent
733b6d64d2
commit
192de3cd76
2 changed files with 28 additions and 27 deletions
|
|
@ -157,7 +157,7 @@ class SyncController extends Controller
|
|||
*/
|
||||
public function getFormularies()
|
||||
{
|
||||
return FormularyResource::collection(Formulary::all());
|
||||
return FormularyResource::collection(Formulary::query()->orderBy('order')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,38 +1,39 @@
|
|||
<div class="row">
|
||||
{{-- SELECT INPUT COMPONENT --}}
|
||||
<div class="col-12 mb-3">
|
||||
{{-- FIXME: OLD VALUES not PASSED --}}
|
||||
@php
|
||||
if(old('type') || old('name') || old('placeholder') || old('details') || old('is_visible') || old('required')) {
|
||||
$oldModel = [];
|
||||
$oldModel["type"] = intval(old('type'));
|
||||
$oldModel["name"] = old('name');
|
||||
$oldModel["placeholder"] = old('placeholder');
|
||||
$oldModel["details"] = old('details');
|
||||
$oldModel["is_visible"] = old('is_visible');
|
||||
$oldModel["required"] = old('required');
|
||||
}
|
||||
$data = [
|
||||
'id' => 'FormulariesSelectInput',
|
||||
'inputType' => \App\Enums\Formularies\InputTypeEnum::toArray(),
|
||||
'inputStatus' => \App\Enums\Formularies\InputStatusEnum::toArray(),
|
||||
'model' => $oldModel ?? $formularyModel ?? null,
|
||||
'errors' => $errors->getBag('default')->getMessages() ?? []
|
||||
];
|
||||
if (old('type') || old('name') || old('placeholder') || old('details') || old('is_visible') || old('required')) {
|
||||
$oldModel = [];
|
||||
$oldModel['type'] = intval(old('type'));
|
||||
$oldModel['name'] = old('name');
|
||||
$oldModel['placeholder'] = old('placeholder');
|
||||
$oldModel['details'] = old('details');
|
||||
$oldModel['is_visible'] = old('is_visible');
|
||||
$oldModel['required'] = old('required');
|
||||
}
|
||||
$data = [
|
||||
'id' => 'FormulariesSelectInput',
|
||||
'inputType' => \App\Enums\Formularies\InputTypeEnum::toArray(),
|
||||
'inputStatus' => \App\Enums\Formularies\InputStatusEnum::toArray(),
|
||||
'model' => $oldModel ?? ($formularyModel ?? null),
|
||||
'errors' => $errors->getBag('default')->getMessages() ?? [],
|
||||
];
|
||||
@endphp
|
||||
<div class="formularies-select-input" data-json='@json($data)'></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@push('scripts')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
<script nonce="{{ $nonce }}">
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
// Submit button clone.
|
||||
const submit = document.getElementById('formSubmit')
|
||||
submitClone = document.getElementById('formSubmitClone');
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
submitClone.addEventListener('click', (event) => {
|
||||
event.preventDefault();
|
||||
submit.click('');
|
||||
})
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue