This commit is contained in:
Ludovic CANDELLIER
2021-10-04 13:49:45 +02:00
parent 9d21f28d9e
commit a7f661ab10
9 changed files with 42 additions and 14 deletions

View File

@@ -30,8 +30,8 @@ class ArticlesDataTable extends DataTable
return [ return [
Column::make('article_nature.name')->title('Nature'), Column::make('article_nature.name')->title('Nature'),
Column::make('name')->title('Nom'), Column::make('name')->title('Nom'),
Column::make('tags_count')->title('Tags')->class('text-right'), Column::make('tags_count')->title('Tags')->class('text-right')->searchable(false),
Column::make('categories_count')->title('Rayons')->class('text-right'), Column::make('categories_count')->title('Rayons')->class('text-right')->searchable(false),
self::makeColumnButtons(), self::makeColumnButtons(),
]; ];
} }

View File

@@ -48,7 +48,7 @@ class SpecieController extends Controller
public function edit($id) public function edit($id)
{ {
$data['specie'] = Species::get($id); $data['specie'] = Species::getFull($id);
$data['genres'] = Genres::getOptions(); $data['genres'] = Genres::getOptions();
$data['tags_list'] = TagGroups::getTreeTags(); $data['tags_list'] = TagGroups::getTreeTags();
return view('Admin.Botanic.Species.edit', $data); return view('Admin.Botanic.Species.edit', $data);

View File

@@ -20,7 +20,7 @@ class OfferController extends Controller
public function create() public function create()
{ {
$data['articles'] = Articles::getOptions(); $data['articles'] = Articles::getOptionsWithNature();
$data['tariffs'] = Tariffs::getOptions(); $data['tariffs'] = Tariffs::getOptions();
$data['variations'] = Variations::getOptions(); $data['variations'] = Variations::getOptions();
return view('Admin.Shop.Offers.create', $data); return view('Admin.Shop.Offers.create', $data);
@@ -29,7 +29,7 @@ class OfferController extends Controller
public function edit($id) public function edit($id)
{ {
$data['offer'] = Offers::get($id)->toArray(); $data['offer'] = Offers::get($id)->toArray();
$data['articles'] = Articles::getOptions(); $data['articles'] = Articles::getOptionsWithNature();
$data['tariffs'] = Tariffs::getOptions(); $data['tariffs'] = Tariffs::getOptions();
$data['variations'] = Variations::getOptions(); $data['variations'] = Variations::getOptions();
return view('Admin.Shop.Offers.edit', $data); return view('Admin.Shop.Offers.edit', $data);

View File

@@ -36,6 +36,20 @@ class Species
return self::get($id)->tags->toArray(); return self::get($id)->tags->toArray();
} }
public static function getFull($id)
{
$specie = self::get($id);
$data = $specie->toArray();
$data['tags'] = self::getTagsBySpecie($specie);
return $data;
}
public static function getTagsBySpecie($specie)
{
return Tag::getTagsByModel($specie);
}
public static function get($id) public static function get($id)
{ {
return Specie::findOrFail($id); return Specie::findOrFail($id);

View File

@@ -28,6 +28,16 @@ class Articles
return Article::orderBy('name','asc')->pluck('name','id')->toArray(); return Article::orderBy('name','asc')->pluck('name','id')->toArray();
} }
public static function getOptionsWithNature()
{
$articles = Article::with(['article_nature'])->get();
foreach ($articles as $article) {
$data[$article->id] = $article->article_nature->name . ' - ' . $article->name;
}
asort($data, SORT_NATURAL);
return $data;
}
public static function getAll() public static function getAll()
{ {
return Article::orderBy('name', 'asc')->get(); return Article::orderBy('name', 'asc')->get();

View File

@@ -29,7 +29,7 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-12"> <div class="col-12">
{{ Form::label('tags', 'Tags') }} {{ Form::label('tags', 'Tags') }}
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $tags ?? null, 'class' => 'select2 form-control', 'multiple' => true]) @include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $specie['tags'] ?? null, 'class' => 'select2 form-control', 'multiple' => true])
</div> </div>
</div> </div>

View File

@@ -31,7 +31,7 @@
<div class="col-3"> <div class="col-3">
@component('components.card', ['title' => 'Disponibilité']) @component('components.card', ['title' => 'Disponibilité'])
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-12 col-xl-6">
{{ Form::label('stock_current', 'Appro immédiate') }} {{ Form::label('stock_current', 'Appro immédiate') }}
@include('components.money', ['name' => 'stock_current', 'value' => $offer['stock_current'] ?? 0]) @include('components.money', ['name' => 'stock_current', 'value' => $offer['stock_current'] ?? 0])
</div> </div>

View File

@@ -2,7 +2,7 @@
<div class="col-6"> <div class="col-6">
{{ Form::open(['route' => 'Admin.Shop.Tariffs.store', 'id' => 'tariffs-form', 'autocomplete' => 'off']) }} {{ Form::open(['route' => 'Admin.Shop.Tariffs.store', 'id' => 'tariffs-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" id="id" value="{{ $tariff['id'] }}"> <input type="hidden" name="id" id="id" value="{{ $tariff['id'] ?? null }}">
<div class="row mb-3"> <div class="row mb-3">
<div class="col-8"> <div class="col-8">

View File

@@ -1,23 +1,27 @@
@if(!defined('LOAD_SELECT2')) @if(!defined('LOAD_SELECT2'))
@push('scripts') @push('scripts')
<script src="{{ asset('/assets/plugins/select2/js/select2.full.min.js') }}"></script> <script src="/assets/plugins/select2/js/select2.full.min.js"></script>
<script src="{{ asset('/assets/plugins/select2/js/i18n/' . App::getLocale() .'.js') }}"></script> <script src="/assets/plugins/select2/js/i18n/" . App::getLocale() . ".js"></script>
<script> <script>
function initSelect2(sel) {
function initSelect2() { var selector = (typeof(sel) == 'undefined') ? '.select2' : sel;
$(".select2").select2({ $(selector).select2({
placeholder: "{{ __('select_a_value') }}", placeholder: "{{ __('select_a_value') }}",
allowClear: false, allowClear: false,
width: { width: {
value: '100%' value: '100%'
} }
}); });
$(document).on('select2:open', () => {
document.querySelector('.select2-search__field').focus();
});
} }
</script> </script>
@endpush @endpush
@push('css') @push('css')
<link rel="stylesheet" href="{!! asset('/assets/plugins/select2/css/select2.min.css') !!}"> <link rel="stylesheet" href="/assets/plugins/select2/css/select2.min.css">
@endpush @endpush
@php(define('LOAD_SELECT2', true)) @php(define('LOAD_SELECT2', true))
@endif @endif