fixes accoeding comment

This commit is contained in:
rahul shukla 2021-01-29 12:40:48 +05:30
parent 9ceddf20ec
commit bbeccdeaaf
3 changed files with 47 additions and 18 deletions

View File

@ -30,10 +30,17 @@ class SliderDataGrid extends DataGrid
{
parent::__construct();
$this->locale = request()->get('locale') ?? 'all';
$this->channel = request()->get('channel')
? Channel::find(request()->get('channel'))->code
: 'all';
/* locale */
$this->locale = request()->get('locale') ?? app()->getLocale();
/* channel */
$this->channel = request()->get('channel') ?? (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
/* finding channel code */
if ($this->channel !== 'all') {
$this->channel = Channel::query()->find($this->channel);
$this->channel = $this->channel ? $this->channel->code : 'all';
}
}
public function prepareQueryBuilder()

View File

@ -2,6 +2,12 @@
$locale = request()->get('locale') ?: app()->getLocale();
$channel = request()->get('channel') ?: (core()->getCurrentChannelCode() ?: core()->getDefaultChannelCode());
$customer_group = request()->get('customer_group');
if ($channel == 'all') {
$locales = core()->getAllLocales();
} else {
$locales = app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales;
}
@endphp
<div class="table">
@ -27,8 +33,8 @@
</option>
@foreach ($results['extraFilters']['channels'] as $channelModel)
<option
value="{{ $channelModel->id }}"
{{ (isset($channel) && ($channelModel->id) == $channel) ? 'selected' : '' }}>
value="{{ $channelModel->code }}"
{{ (isset($channel) && ($channelModel->code) == $channel) ? 'selected' : '' }}>
{{ $channelModel->name }}
</option>
@endforeach
@ -45,7 +51,7 @@
<option value="all" {{ ! isset($locale) ? 'selected' : '' }}>
{{ __('admin::app.admin.system.all-locales') }}
</option>
@foreach ($results['extraFilters']['locales'] as $localeModel)
@foreach ($locales as $localeModel)
<option
value="{{ $localeModel->code }}" {{ (isset($locale) && ($localeModel->code) == $locale) ? 'selected' : '' }}>
{{ $localeModel->name }}
@ -715,7 +721,7 @@
case "channel":
obj.label = "Channel";
if ('channels' in this.extraFilters) {
obj.prettyValue = this.extraFilters['channels'].find(channel => channel.id == obj.val).name
obj.prettyValue = this.extraFilters['channels'].find(channel => channel.code == obj.val).name
}
break;
case "locale":

View File

@ -33,11 +33,12 @@
<input type="hidden" name="channel" value="{{ $channel }}" />
<div class="control-group">
<select class="control" id="channel-switcher" onChange="window.location.href = this.value">
@foreach (core()->getAllChannels() as $ch)
<select class="control" id="channel-switcher" name="channel">
@foreach (core()->getAllChannels() as $channelModel)
<option value="{{ route('velocity.admin.meta-data') . '?channel=' . $ch->code . '&locale=' . $locale }}" {{ ($ch->code) == $channel ? 'selected' : '' }}>
{{ $ch->name }}
<option
value="{{ $channelModel->code }}" {{ ($channelModel->code) == $channel ? 'selected' : '' }}>
{{ $channelModel->name }}
</option>
@endforeach
@ -45,10 +46,11 @@
</div>
<div class="control-group">
<select class="control" id="locale-switcher" onChange="window.location.href = this.value">
@foreach (core()->getAllLocales() as $localeModel)
<select class="control" id="locale-switcher" name="locale">
@foreach (app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales as $localeModel)
<option value="{{ route('velocity.admin.meta-data') . '?locale=' . $localeModel->code . '&channel=' . $channel }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
<option
value="{{ $localeModel->code }}" {{ ($localeModel->code) == $locale ? 'selected' : '' }}>
{{ $localeModel->name }}
</option>
@ -105,9 +107,9 @@
value="{{ $metaData ? $metaData->header_content_count : '5' }}" />
</div>
<div class="control-group">
<label style="width:100%;">
{{ __('velocity::app.admin.meta-data.home-page-content') }}
@ -181,7 +183,7 @@
'url' => asset('/themes/velocity/assets/images/kids.webp'),
];
@endphp
<image-wrapper
:multiple="true"
input-name="images[4]"
@ -351,6 +353,20 @@
plugins: 'image imagetools media wordcount save fullscreen code',
toolbar1: 'formatselect | bold italic strikethrough forecolor backcolor | link | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code',
});
$('#channel-switcher, #locale-switcher').on('change', function (e) {
$('#channel-switcher').val()
if (event.target.id == 'channel-switcher') {
let locale = "{{ app('Webkul\Core\Repositories\ChannelRepository')->findOneByField('code', $channel)->locales->first()->code }}";
$('#locale-switcher').val(locale);
}
var query = '?channel=' + $('#channel-switcher').val() + '&locale=' + $('#locale-switcher').val();
window.location.href = "{{ route('velocity.admin.meta-data') }}" + query;
})
});
</script>
@endpush