Fixes on adding price & errors

This commit is contained in:
Ludovic CANDELLIER
2021-07-27 17:33:18 +02:00
parent 0d421226fa
commit 734ec87b89
18 changed files with 123 additions and 76 deletions

View File

@@ -0,0 +1,12 @@
<tr>
<input type="hidden" name="price_list_values[{{ $index }}][id]" value="{{ $price_list_value['id'] ?? null }}">
<td>
@include('components.input', ['name' => 'price_list_values[' . $index . '][code]', 'value' => $price_list_value['code'] ?? null, 'required' => true])
</td>
<td>
@include('components.number', ['name' => 'price_list_values[' . $index . '][quantity]', 'value' => $price_list_value['quantity'] ?? null, 'required' => true, 'meta' => "step = '.01'"])
</td>
<td>
@include('components.money', ['name' => 'price_list_values[' . $index . '][price]', 'value' => $price_list_value['price'] ?? null, 'required' => true])
</td>
</tr>

View File

@@ -4,26 +4,25 @@
<input type="hidden" name="tariff_id" value="{{ $price_list['tariff_id'] ?? null }}">
<div class="row mb-3">
<div class="col-6">
<div class="col-8">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $price_list['name'] ?? null, 'required' => true])
</div>
<div class="col-4">
{{ Form::label('status_id', 'Etat') }}
@include('components.select', ['name' => 'status_id', 'list' => $statuses ?? [], 'value' => $price_list['status_id'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('sale_channel_id', 'Canal de vente') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $price_list['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $price_list['name'] ?? null, 'required' => true])
</div>
</div>
@component('components.card', ['title' => 'Prix'])
<table class="table table-bordered table-hover table-striped w-100 mb-0 dataTable">
<table class="table table-bordered table-hover table-striped w-100 mb-0 dataTable" id="prices-table">
<thead>
<tr>
<th>Code</th>
@@ -33,20 +32,37 @@
</thead>
<tbody>
@foreach ($price_list['price_list_values'] as $price_list_value)
<tr>
<td>
@include('components.input', ['name' => 'price_list_values[' . $loop->index . '][code]', 'value' => $price_list_value['name'] ?? null, 'required' => true])
</td>
<td>
@include('components.number', ['name' => 'price_list_values[' . $loop->index . '][quantity]', 'value' => $price_list_value['quantity'] ?? null, 'required' => true, 'meta' => "step = '.01'"])
</td>
<td>
@include('components.money', ['name' => 'price_list_values[' . $loop->index . '][price]', 'value' => $price_list_value['price'] ?? null, 'required' => true])
</td>
</tr>
@include('admin.Shop.PriceListValues.partials.row_price', ['index' => $loop->index])
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="3">
<button type='button' class='btn btn-primary btn-xs' id='add_price'>
Ajouter un seuil
<i class='pl-2 fa fa-plus'></i>
</button>
</td>
</tr>
</tfoot>
</table>
@endcomponent
</form>
</form>
<script>
function handleAddPrice() {
$('#add_price').click( function () {
var index = $('#prices-table tbody tr').length;
$.get("{{ route('Admin.Shop.PriceListValues.addPrice') }}/" + index, function(data) {
$("#prices-table").prepend(data);
})
})
}
$(function() {
handleAddPrice();
});
</script>

View File

@@ -2,37 +2,39 @@
<div class="col-6">
<div class="row mb-3">
<div class="col-12">
<div class="col-8">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $tariff['name'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-6">
{{ Form::label('name', 'Canal de vente') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $tariff['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
<div class="col-6">
<div class="col-4">
{{ Form::label('name', 'Etat') }}
@include('components.select', ['name' => 'status_id', 'list' => $statuses ?? [], 'value' => $tariff['status_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-3">
<div class="col-6">
{{ Form::label('name', 'Code') }}
@include('components.input', ['name' => 'code', 'value' => $tariff['code'] ?? null, 'required' => true])
</div>
<div class="col-3">
<div class="col-6">
{{ Form::label('name', 'Ref') }}
@include('components.input', ['name' => 'ref', 'value' => $tariff['ref'] ?? null, 'required' => true])
</div>
<div class="col-6">
</div>
<div class="row mb-3">
<div class="col-8">
{{ Form::label('name', 'Canal de vente par défaut') }}
@include('components.select', ['name' => 'sale_channel_id', 'list' => $sale_channels ?? [], 'value' => $tariff['sale_channel_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
<div class="col-4">
{{ Form::label('name', 'Unité du tarif') }}
@include('components.select', ['name' => 'tariff_unity_id', 'list' => $tariff_unities ?? [], 'value' => $tariff['tariff_unity_id'] ?? null, 'required' => true, 'with_empty' => ''])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('description', 'Description') }}

View File

@@ -26,13 +26,12 @@
@include('components.save')
@include('boilerplate::load.tinymce')
@include('load.form.editor')
@push('js')
<script>
$(function() {
$('.editor').tinymce({});
initEditor();
});
</script>
@endpush