updated code visibility and streamline category type handling
This commit is contained in:
parent
31df25305d
commit
ce25e05b64
|
|
@ -228,7 +228,7 @@ export default {
|
||||||
<div class="swiper-button-prev bg-body text-white flex items-center justify-center left-0">
|
<div class="swiper-button-prev bg-body text-white flex items-center justify-center left-0">
|
||||||
<span class="material-icons text-purple text-4xl">chevron_left</span>
|
<span class="material-icons text-purple text-4xl">chevron_left</span>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
item.querySelector('[data-tabs-swiper]').innerHTML = html;
|
item.querySelector('[data-tabs-swiper]').innerHTML = html;
|
||||||
slides_view = Number(item.getAttribute('data-swiper')) != 0 ? Number(item.getAttribute('data-swiper')) : slides_view;
|
slides_view = Number(item.getAttribute('data-swiper')) != 0 ? Number(item.getAttribute('data-swiper')) : slides_view;
|
||||||
|
|
@ -301,6 +301,28 @@ export default {
|
||||||
this.form[key] = event.target.files[0];
|
this.form[key] = event.target.files[0];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isCategoryCodeFieldVisible() {
|
||||||
|
if (!this.form || !this.form.type || !this.form.type_codes) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
let type_codes = this.form.type_codes;
|
||||||
|
|
||||||
|
if (typeof type_codes === 'string') {
|
||||||
|
try {
|
||||||
|
type_codes = JSON.parse(type_codes);
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof type_codes[this.form.type] === 'undefined') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !Boolean(type_codes[this.form.type]);
|
||||||
|
},
|
||||||
|
|
||||||
// Bulk Action Select all
|
// Bulk Action Select all
|
||||||
onSelectAllBulkAction() {
|
onSelectAllBulkAction() {
|
||||||
this.bulk_action.selectAll();
|
this.bulk_action.selectAll();
|
||||||
|
|
|
||||||
|
|
@ -31,31 +31,15 @@ const app = new Vue({
|
||||||
bulk_action: new BulkAction('categories'),
|
bulk_action: new BulkAction('categories'),
|
||||||
categoriesBasedTypes: null,
|
categoriesBasedTypes: null,
|
||||||
selected_type: true,
|
selected_type: true,
|
||||||
type_codes: {},
|
|
||||||
show_code_field: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
|
||||||
if (typeof type_codes !== 'undefined') {
|
|
||||||
this.type_codes = type_codes;
|
|
||||||
|
|
||||||
if (this.form.type) {
|
|
||||||
this.show_code_field = this.type_codes[this.form.type] || false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
changeCategories(event) {
|
updateParentCategories(event) {
|
||||||
if (event === '') {
|
if (event === '') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.type_codes[event] !== undefined) {
|
|
||||||
this.show_code_field = this.type_codes[event];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof JSON.parse(this.form.categories)[event] === 'undefined') {
|
if (typeof JSON.parse(this.form.categories)[event] === 'undefined') {
|
||||||
this.categoriesBasedTypes = [];
|
this.categoriesBasedTypes = [];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
>
|
>
|
||||||
<template #option="{option}">
|
<template #option="{option}">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
<span class="{{ (! $group) ? 'ltr:ml-2 rtl:mr-2 ' : '' }}w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
||||||
|
|
||||||
@if ($option_field['value'] == 'title')
|
@if ($option_field['value'] == 'title')
|
||||||
<span>@{{ option.option.title }}</span>
|
<span>@{{ option.option.title }}</span>
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
>
|
>
|
||||||
<template #option="{option}">
|
<template #option="{option}">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
<span class="{{ (! $group) ? 'ltr:ml-2 rtl:mr-2 ' : '' }}w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
||||||
|
|
||||||
@if ($option_field['value'] == 'title')
|
@if ($option_field['value'] == 'title')
|
||||||
<span>@{{ option.option.title }}</span>
|
<span>@{{ option.option.title }}</span>
|
||||||
|
|
@ -99,7 +99,7 @@
|
||||||
>
|
>
|
||||||
<template #option="{option}">
|
<template #option="{option}">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
<span class="{{ (! $group) ? 'ltr:ml-2 rtl:mr-2 ' : '' }}w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
||||||
|
|
||||||
@if ($option_field['value'] == 'title')
|
@if ($option_field['value'] == 'title')
|
||||||
<span>@{{ option.option.title }}</span>
|
<span>@{{ option.option.title }}</span>
|
||||||
|
|
@ -129,7 +129,7 @@
|
||||||
>
|
>
|
||||||
<template #option="{option}">
|
<template #option="{option}">
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
<span class="{{ (! $group) ? 'ltr:ml-2 rtl:mr-2 ' : '' }}w-5 h-4 rounded-full" :style="{backgroundColor: option.option.color_hex_code}"></span>
|
||||||
|
|
||||||
@if ($option_field['value'] == 'title')
|
@if ($option_field['value'] == 'title')
|
||||||
<span>@{{ option.option.title }}</span>
|
<span>@{{ option.option.title }}</span>
|
||||||
|
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
||||||
|
|
||||||
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$categories" not-required sort-options="false" searchable form-group-class="col-span-6" />
|
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$categories" not-required sort-options="false" searchable form-group-class="col-span-6" />
|
||||||
|
|
||||||
@if (!empty($types) && count($types) > 1)
|
@if (! empty($types) && count($types) > 1)
|
||||||
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" value="{{ $type }}" form-group-class="col-span-6" change="changeCategories" />
|
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" value="{{ $type }}" form-group-class="col-span-6" :group="$type_group" />
|
||||||
|
|
||||||
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" v-show="show_code_field" />
|
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" v-show="isCategoryCodeFieldVisible()" />
|
||||||
@else
|
@else
|
||||||
<x-form.input.hidden name="type" value="{{ $type }}" />
|
<x-form.input.hidden name="type" value="{{ $type }}" />
|
||||||
|
|
||||||
@if ($show_code_field)
|
@if (empty($hide_code_types[$type]) || ! $hide_code_types[$type])
|
||||||
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" />
|
<x-form.group.text name="code" label="{{ trans('general.code') }}" form-group-class="col-span-6" />
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
@ -21,12 +21,6 @@
|
||||||
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
||||||
|
|
||||||
<x-form.input.hidden name="enabled" value="1" />
|
<x-form.input.hidden name="enabled" value="1" />
|
||||||
|
<x-form.input.hidden name="type_codes" value="{{ json_encode($hide_code_types) }}" />
|
||||||
</div>
|
</div>
|
||||||
</x-form>
|
</x-form>
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
if (typeof type_codes === 'undefined') {
|
|
||||||
var type_codes = {!! json_encode($type_codes) !!};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,16 @@
|
||||||
|
|
||||||
<x-form.group.color name="color" label="{{ trans('general.color') }}" />
|
<x-form.group.color name="color" label="{{ trans('general.color') }}" />
|
||||||
|
|
||||||
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" :selected="config('general.types')" change="changeCategories" group />
|
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" :selected="config('general.types')" change="updateParentCategories" :group="$type_group" />
|
||||||
|
|
||||||
<x-form.group.text name="code" label="{{ trans('general.code') }}" v-show="show_code_field" />
|
<x-form.group.text name="code" label="{{ trans('general.code') }}" v-show="isCategoryCodeFieldVisible()" />
|
||||||
|
|
||||||
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="[]" not-required dynamicOptions="categoriesBasedTypes" sort-options="false" v-disabled="selected_type" />
|
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="[]" not-required dynamicOptions="categoriesBasedTypes" sort-options="false" v-disabled="selected_type" />
|
||||||
|
|
||||||
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
||||||
|
|
||||||
<x-form.input.hidden name="categories" value="{{ json_encode($categories) }}" />
|
<x-form.input.hidden name="categories" value="{{ json_encode($categories) }}" />
|
||||||
|
<x-form.input.hidden name="type_codes" value="{{ json_encode($hide_code_types) }}" />
|
||||||
</x-slot>
|
</x-slot>
|
||||||
</x-form.section>
|
</x-form.section>
|
||||||
|
|
||||||
|
|
@ -43,11 +44,5 @@
|
||||||
</x-form.container>
|
</x-form.container>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
@push('scripts_start')
|
|
||||||
<script type="text/javascript">
|
|
||||||
var type_codes = {!! json_encode($type_codes) !!};
|
|
||||||
</script>
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
<x-script folder="settings" file="categories" />
|
<x-script folder="settings" file="categories" />
|
||||||
</x-layouts.admin>
|
</x-layouts.admin>
|
||||||
|
|
|
||||||
|
|
@ -14,22 +14,22 @@
|
||||||
<x-slot name="body">
|
<x-slot name="body">
|
||||||
<x-form.group.text name="name" label="{{ trans('general.name') }}" />
|
<x-form.group.text name="name" label="{{ trans('general.name') }}" />
|
||||||
|
|
||||||
|
|
||||||
<x-form.group.color name="color" label="{{ trans('general.color') }}" />
|
<x-form.group.color name="color" label="{{ trans('general.color') }}" />
|
||||||
|
|
||||||
@if ($type_disabled)
|
@if ($type_disabled)
|
||||||
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" v-disabled="true" group />
|
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" v-disabled="true" :group="$type_group" />
|
||||||
|
|
||||||
<input type="hidden" name="type" value="{{ $category->type }}" />
|
<input type="hidden" name="type" value="{{ $category->type }}" />
|
||||||
@else
|
@else
|
||||||
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" change="changeCategories" group />
|
<x-form.group.select name="type" label="{{ trans_choice('general.types', 1) }}" :options="$types" change="updateParentCategories" :group="$type_group" />
|
||||||
|
|
||||||
<x-form.group.text name="code" label="{{ trans('general.code') }}" v-show="show_code_field" />
|
<x-form.group.text name="code" label="{{ trans('general.code') }}" v-show="isCategoryCodeFieldVisible()" />
|
||||||
|
|
||||||
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$parent_categories" not-required dynamicOptions="categoriesBasedTypes" sort-options="false" />
|
<x-form.group.select name="parent_id" label="{{ trans('general.parent') . ' ' . trans_choice('general.categories', 1) }}" :options="$parent_categories" not-required dynamicOptions="categoriesBasedTypes" sort-options="false" />
|
||||||
|
|
||||||
<x-form.input.hidden name="parent_category_id" value="{{ $category->parent_id }}" />
|
<x-form.input.hidden name="parent_category_id" value="{{ $category->parent_id }}" />
|
||||||
<x-form.input.hidden name="categories" value="{{ json_encode($categories) }}" />
|
<x-form.input.hidden name="categories" value="{{ json_encode($categories) }}" />
|
||||||
|
<x-form.input.hidden name="type_codes" value="{{ json_encode($hide_code_types) }}" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
<x-form.group.textarea name="description" label="{{ trans('general.description') }}" not-required />
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
</x-form.section>
|
</x-form.section>
|
||||||
|
|
||||||
@if (! $type_disabled)
|
@if (! $type_disabled)
|
||||||
<x-form.group.switch name="enabled" label="{{ trans('general.enabled') }}" />
|
<x-form.group.switch name="enabled" label="{{ trans('general.enabled') }}" />
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@can('update-settings-categories')
|
@can('update-settings-categories')
|
||||||
|
|
@ -51,11 +51,5 @@
|
||||||
</x-form.container>
|
</x-form.container>
|
||||||
</x-slot>
|
</x-slot>
|
||||||
|
|
||||||
@push('scripts_start')
|
|
||||||
<script type="text/javascript">
|
|
||||||
var type_codes = {!! json_encode($type_codes) !!};
|
|
||||||
</script>
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
<x-script folder="settings" file="categories" />
|
<x-script folder="settings" file="categories" />
|
||||||
</x-layouts.admin>
|
</x-layouts.admin>
|
||||||
|
|
|
||||||
|
|
@ -136,8 +136,8 @@
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
<x-table.td class="{{ $name_class }}">
|
<x-table.td class="{{ $name_class }}">
|
||||||
<div class="flex items-center">
|
@if ($item->sub_categories->count())
|
||||||
@if ($item->sub_categories->count())
|
<div class="flex items-center">
|
||||||
<x-tooltip id="tooltip-category-{{ $item->id }}" placement="bottom" message="{{ trans('categories.collapse') }}">
|
<x-tooltip id="tooltip-category-{{ $item->id }}" placement="bottom" message="{{ trans('categories.collapse') }}">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -152,7 +152,7 @@
|
||||||
<div class="flex items-center font-bold">
|
<div class="flex items-center font-bold">
|
||||||
{{ $item->name }}
|
{{ $item->name }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@else
|
@else
|
||||||
<div class="flex items-center">
|
<div class="flex items-center">
|
||||||
<span class="material-icons text-{{ $item->color }}" class="text-3xl" style="color:{{ $item->color }};">circle</span>
|
<span class="material-icons text-{{ $item->color }}" class="text-3xl" style="color:{{ $item->color }};">circle</span>
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@
|
||||||
@php
|
@php
|
||||||
$sub_category->load(['sub_categories']);
|
$sub_category->load(['sub_categories']);
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@include('settings.categories.sub_category', ['parent_category' => $parent_category, 'sub_category' => $sub_category, 'tree_level' => $tree_level, 'hide_code_column' => $hide_code_column, 'name_class' => $name_class])
|
@include('settings.categories.sub_category', ['parent_category' => $parent_category, 'sub_category' => $sub_category, 'tree_level' => $tree_level, 'hide_code_column' => $hide_code_column, 'name_class' => $name_class])
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue