Fixes
This commit is contained in:
@@ -13,7 +13,7 @@ class SpeciesDataTable extends DataTable
|
||||
|
||||
public function query(Specie $model)
|
||||
{
|
||||
$model = $model::withCount('varieties')->with(['genre','image']);
|
||||
$model = $model::withCount(['images','varieties','tags'])->with(['genre','image','tags']);
|
||||
return $this->buildQuery($model);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,14 @@ class SpeciesDataTable extends DataTable
|
||||
->editColumn('genre_name', function (Specie $specie) {
|
||||
return $specie->genre ? $specie->genre->name : '';
|
||||
})
|
||||
->rawColumns(['thumb', 'genre_name', 'action']);
|
||||
->editColumn('tags2', function (Specie $specie) {
|
||||
$html = '';
|
||||
foreach ($specie->tags as $tag) {
|
||||
$html .= '<span class="btn btn-xs btn-secondary pb-2">' . $tag->slug . '</span> ';
|
||||
}
|
||||
return $html;
|
||||
})
|
||||
->rawColumns(['thumb', 'tags2', 'genre_name', 'action']);
|
||||
return parent::modifier($datatables);
|
||||
}
|
||||
|
||||
@@ -38,7 +45,10 @@ class SpeciesDataTable extends DataTable
|
||||
Column::make('alias'),
|
||||
Column::make('genre.name')->data('genre_name')->title('Genre'),
|
||||
Column::make('latin'),
|
||||
Column::make('varieties_count')->title('Nb variétés')->searchable(false)->addClass('text-right'),
|
||||
Column::make('tags2')->title('Tags')->searchable(false)->orderable(false),
|
||||
Column::make('varieties_count')->title('#Var')->searchable(false)->addClass('text-right'),
|
||||
Column::make('tags_count')->title('#Tag')->searchable(false)->addClass('text-right'),
|
||||
Column::make('images_count')->title('#Pho')->searchable(false)->addClass('text-right'),
|
||||
$this->makeColumnButtons(),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ class ParentDataTable extends DataTable
|
||||
*/
|
||||
public function buildQuery($model)
|
||||
{
|
||||
// $model = $model->select($model->getTable() . '.*');
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ class ParentDataTable extends DataTable
|
||||
'colReorder' => $this->colReorder,
|
||||
'fixedColumns' => $this->fixedColumns,
|
||||
'fixedHeader' => $this->fixedHeader,
|
||||
'pageLength' => 5,
|
||||
'pageLength' => 10,
|
||||
'searchDelay' => 500,
|
||||
'scrollX' => $this->scrollX,
|
||||
'scrollCollapse' => $this->scrollCollapse,
|
||||
|
||||
@@ -28,6 +28,9 @@ class Shop
|
||||
$menu->addTo('shop', 'Tags', [ 'route' => 'Admin.Shop.Tags.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Admin.Shop.Tags.*'])->order(8);
|
||||
|
||||
$menu->addTo('shop', 'Groupes de tags', [ 'route' => 'Admin.Shop.TagGroups.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Admin.Shop.TagGroups.*'])->order(8);
|
||||
|
||||
$menu->addTo('shop', 'Natures d\'articles', [ 'route' => 'Admin.Shop.ArticleNatures.index', 'permission' => 'backend_access' ])
|
||||
->activeIfRoute(['Admin.Shop.ArticleNatures.*'])->order(9);
|
||||
|
||||
|
||||
@@ -4,8 +4,12 @@ namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
use Spatie\Translatable\HasTranslations;
|
||||
|
||||
class Tag extends Model
|
||||
{
|
||||
use HasTranslations;
|
||||
|
||||
protected $guarded = ['id'];
|
||||
public $translatable = ['name'];
|
||||
|
||||
@@ -40,9 +44,4 @@ class Tag extends Model
|
||||
{
|
||||
return $query->where($this->table . '.tag_group_id', $id);
|
||||
}
|
||||
|
||||
public function getNameAttribute($value)
|
||||
{
|
||||
return json_decode($value)->fr ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,13 +49,10 @@ class Tags
|
||||
|
||||
public static function create($data)
|
||||
{
|
||||
$slug = self::buildSlug($data);
|
||||
$tag = app('rinvex.tags.tag')->create([
|
||||
'name' => ['fr' => $data['name']],
|
||||
'slug' => $slug,
|
||||
'tag_group_id' => $data['tag_group_id'],
|
||||
'sort_order' => self::getNewOrder($data['tag_group_id'])
|
||||
]);
|
||||
$data['name'] = ['fr' => $data['name']];
|
||||
$data['slug'] = self::buildSlug($data);
|
||||
$data['sort_order'] = self::getNewOrder($data['tag_group_id']);
|
||||
$tag = Tag::create($data);
|
||||
return $tag;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@
|
||||
])
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Admin.Botanic.Species.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
@include('Admin.Botanic.Species.form')
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
])
|
||||
|
||||
@section('content')
|
||||
|
||||
{{ Form::open(['route' => 'Admin.Botanic.Species.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
|
||||
<input type="hidden" name="id" value="{{ $specie['id'] }}">
|
||||
<input type="hidden" name="id" id="id" value="{{ $specie['id'] }}">
|
||||
@include('Admin.Botanic.Species.form')
|
||||
</form>
|
||||
|
||||
@endsection
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
@include('boilerplate::load.fileinput')
|
||||
@include('boilerplate::load.select2')
|
||||
@include('boilerplate::load.tinymce')
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-8">
|
||||
<div class="row mb-3">
|
||||
@@ -43,7 +39,7 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
@include('components.uploader.widget', ['load_url' => route('Admin.Botanic.Species.getImages', ['id' => $specie['id'] ?? false]), 'delete_url' => route('Admin.Botanic.Species.deleteImage'), 'name' => 'images'])
|
||||
@include('components.uploader.widget', ['load_url' => ($specie['id'] ?? false) ? route('Admin.Botanic.Species.getImages', ['id' => $specie['id']]) : null, 'delete_url' => route('Admin.Botanic.Species.deleteImage'), 'name' => 'images'])
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -53,9 +49,7 @@
|
||||
@include('load.form.editor')
|
||||
@include('load.form.save')
|
||||
@include('load.form.select2')
|
||||
|
||||
@include('load.form.upload.fileinput')
|
||||
@include('boilerplate::load.tinymce')
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</button>
|
||||
@if ($can_edit ?? true)
|
||||
<button type="button" class="btn btn-xs btn-outline-danger">
|
||||
<i class="fas fa-trash" data-index="{{ $key }}"></i>
|
||||
<i class="fas fa-trash" data-index="{{ $key }}" data-id="{{ $image['id'] }}"></i>
|
||||
</button>
|
||||
@endif
|
||||
</figcaption>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
@endcomponent
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
@include('load.form.upload.fileinput')
|
||||
|
||||
@if ($no_popup ?? true)
|
||||
@push('js')
|
||||
@@ -52,9 +52,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@if ($load_url)
|
||||
$(function() {
|
||||
{{ $prefix ?? '' }}loadImages();
|
||||
});
|
||||
@endif
|
||||
</script>
|
||||
|
||||
@if ($no_popup ?? true)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@if(!defined('LOAD_SELECT2'))
|
||||
@push('scripts')
|
||||
<script src="/assets/plugins/select2/js/select2.full.min.js"></script>
|
||||
<script src="/assets/plugins/select2/js/i18n/" . App::getLocale() . ".js"></script>
|
||||
<script src="/assets/plugins/select2/js/i18n/{{ App::getLocale() }}.js"></script>
|
||||
|
||||
<script>
|
||||
function initSelect2(sel) {
|
||||
@@ -14,8 +14,14 @@
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('select2:open', () => {
|
||||
document.querySelector('.select2-search__field').focus();
|
||||
$(document).on('select2:open',(e) => {
|
||||
let t = $(e.target);
|
||||
console.log(t);
|
||||
if (t && t.length) {
|
||||
let id = t[0].id || t[0].name;
|
||||
let item = document.querySelector(`input[aria-controls*='${id}']`);
|
||||
return item ? item.focus() : false;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user