Merge pull request #3348 from CihanSenturk/add-category-tabs
Improve category tabs
This commit is contained in:
commit
729834a0ef
|
|
@ -53,6 +53,7 @@ class Categories extends BulkAction
|
||||||
public function edit($request)
|
public function edit($request)
|
||||||
{
|
{
|
||||||
$selected = $this->getSelectedInput($request);
|
$selected = $this->getSelectedInput($request);
|
||||||
|
|
||||||
$types = $this->getCategoryTypes();
|
$types = $this->getCategoryTypes();
|
||||||
|
|
||||||
return $this->response('bulk-actions.settings.categories.edit', compact('selected', 'types'));
|
return $this->response('bulk-actions.settings.categories.edit', compact('selected', 'types'));
|
||||||
|
|
|
||||||
|
|
@ -35,36 +35,12 @@ class Categories extends Controller
|
||||||
{
|
{
|
||||||
$type = $request->get('type', Category::ITEM_TYPE);
|
$type = $request->get('type', Category::ITEM_TYPE);
|
||||||
|
|
||||||
$type_codes = [];
|
$category_types = $this->getTypeCategoryTypes($type);
|
||||||
|
$hide_code_types = $this->hideCodeCategoryTypes($category_types);
|
||||||
switch ($type) {
|
|
||||||
case Category::INCOME_TYPE:
|
|
||||||
$types = $this->getIncomeCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Category::EXPENSE_TYPE:
|
|
||||||
$types = $this->getExpenseCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Category::ITEM_TYPE:
|
|
||||||
$types = $this->getItemCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Category::OTHER_TYPE:
|
|
||||||
$types = $this->getOtherCategoryTypes();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$types = [$type];
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($types as $type) {
|
|
||||||
$config_type = config('type.category.' . $type, []);
|
|
||||||
$type_codes[$type] = empty($config_type['hide']) || ! in_array('code', $config_type['hide']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$config_type = config('type.category.' . $type, []);
|
|
||||||
$show_code_field = ! empty($config_type['hide']) && in_array('code', $config_type['hide']) ? false : true;
|
|
||||||
|
|
||||||
$categories = collect();
|
$categories = collect();
|
||||||
|
|
||||||
Category::type($types)
|
Category::type($category_types)
|
||||||
->enabled()
|
->enabled()
|
||||||
->orderBy('name')
|
->orderBy('name')
|
||||||
->get()
|
->get()
|
||||||
|
|
@ -76,7 +52,10 @@ class Categories extends Controller
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$html = view('modals.categories.create', compact('type', 'types', 'categories', 'show_code_field', 'type_codes'))->render();
|
$type_group = count($category_types) > 1 ? true : false;
|
||||||
|
$types = $this->getCategoryTypes(group: true, types: $category_types);
|
||||||
|
|
||||||
|
$html = view('modals.categories.create', compact('type', 'types', 'categories', 'type_group', 'hide_code_types'))->render();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,17 @@ class Categories extends Controller
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
$types = $this->getCategoryTypes(true, true);
|
|
||||||
|
|
||||||
$categories = [];
|
$categories = [];
|
||||||
$type_codes = [];
|
|
||||||
|
|
||||||
foreach (config('type.category') as $type => $config) {
|
foreach (config('type.category') as $type => $config) {
|
||||||
$type_codes[$type] = empty($config['hide']) || ! in_array('code', $config['hide']);
|
|
||||||
$categories[$type] = [];
|
$categories[$type] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type_group = $this->isGroupCategoryType();
|
||||||
|
$hide_code_types = $this->hideCodeCategoryTypes(array_keys($categories));
|
||||||
|
|
||||||
|
$types = $this->getCategoryTypes(group: $type_group);
|
||||||
|
|
||||||
Category::enabled()->orderBy('name')->get()->each(function ($category) use (&$categories) {
|
Category::enabled()->orderBy('name')->get()->each(function ($category) use (&$categories) {
|
||||||
$categories[$category->type][] = [
|
$categories[$category->type][] = [
|
||||||
'id' => $category->id,
|
'id' => $category->id,
|
||||||
|
|
@ -99,7 +100,7 @@ class Categories extends Controller
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
return view('settings.categories.create', compact('types', 'categories', 'type_codes'));
|
return view('settings.categories.create', compact('types', 'categories', 'type_group', 'hide_code_types'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -163,20 +164,21 @@ class Categories extends Controller
|
||||||
*/
|
*/
|
||||||
public function edit(Category $category)
|
public function edit(Category $category)
|
||||||
{
|
{
|
||||||
$types = $this->getCategoryTypes(true, true);
|
|
||||||
|
|
||||||
$type_disabled = (Category::where('type', $category->type)->count() == 1) ?: false;
|
$type_disabled = (Category::where('type', $category->type)->count() == 1) ?: false;
|
||||||
|
|
||||||
$edited_category_id = $category->id;
|
$edited_category_id = $category->id;
|
||||||
|
|
||||||
$categories = [];
|
$categories = [];
|
||||||
$type_codes = [];
|
|
||||||
|
|
||||||
foreach (config('type.category') as $type => $config) {
|
foreach (config('type.category') as $type => $config) {
|
||||||
$type_codes[$type] = empty($config['hide']) || ! in_array('code', $config['hide']);
|
|
||||||
$categories[$type] = [];
|
$categories[$type] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$type_group = $this->isGroupCategoryType();
|
||||||
|
$hide_code_types = $this->hideCodeCategoryTypes(array_keys($categories));
|
||||||
|
|
||||||
|
$types = $this->getCategoryTypes(group: $type_group);
|
||||||
|
|
||||||
$skip_categories = [];
|
$skip_categories = [];
|
||||||
$skip_categories[] = $edited_category_id;
|
$skip_categories[] = $edited_category_id;
|
||||||
|
|
||||||
|
|
@ -206,7 +208,7 @@ class Categories extends Controller
|
||||||
|
|
||||||
$parent_categories = $categories[$category->type] ?? [];
|
$parent_categories = $categories[$category->type] ?? [];
|
||||||
|
|
||||||
return view('settings.categories.edit', compact('category', 'types', 'type_disabled', 'categories', 'parent_categories', 'type_codes'));
|
return view('settings.categories.edit', compact('category', 'types', 'type_disabled', 'categories', 'parent_categories', 'type_group', 'hide_code_types'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class AddExpenseCategories extends Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
// send true for add limit on search and filter..
|
// send true for add limit on search and filter..
|
||||||
$event->class->filters['categories'] = $this->getExpenseCategories(true);
|
$event->class->filters['categories'] = $this->getExpenseCategories();
|
||||||
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . $this->getExpenseCategoryTypes('string') . ' enabled:1'];
|
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . $this->getExpenseCategoryTypes('string') . ' enabled:1'];
|
||||||
$event->class->filters['multiple']['categories'] = true;
|
$event->class->filters['multiple']['categories'] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class AddIncomeCategories extends Listener
|
||||||
}
|
}
|
||||||
|
|
||||||
// send true for add limit on search and filter..
|
// send true for add limit on search and filter..
|
||||||
$event->class->filters['categories'] = $this->getIncomeCategories(true);
|
$event->class->filters['categories'] = $this->getIncomeCategories();
|
||||||
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . $this->getIncomeCategoryTypes('string') . ' enabled:1'];
|
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . $this->getIncomeCategoryTypes('string') . ' enabled:1'];
|
||||||
$event->class->filters['multiple']['categories'] = true;
|
$event->class->filters['multiple']['categories'] = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,10 @@ class AddIncomeExpenseCategories extends Listener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$event->class->filters['categories'] = $this->getIncomeExpenseCategories(true);
|
$types = array_merge($this->getIncomeCategoryTypes(), $this->getExpenseCategoryTypes());
|
||||||
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . implode(',', array_merge($this->getIncomeCategoryTypes(), $this->getExpenseCategoryTypes())) . ' enabled:1'];
|
|
||||||
|
$event->class->filters['categories'] = $this->getIncomeExpenseCategories();
|
||||||
|
$event->class->filters['routes']['categories'] = ['categories.index', 'search=type:' . implode(',', $types) . ' enabled:1'];
|
||||||
$event->class->filters['multiple']['categories'] = true;
|
$event->class->filters['multiple']['categories'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -292,10 +292,9 @@ class Category extends Model
|
||||||
*/
|
*/
|
||||||
public function getDisplayNameAttribute(): string
|
public function getDisplayNameAttribute(): string
|
||||||
{
|
{
|
||||||
$typeConfig = config('type.category.' . $this->type, []);
|
$hideCode = $this->hideCodeCategoryType($this->type);
|
||||||
$hideCode = isset($typeConfig['hide']) && in_array('code', $typeConfig['hide']);
|
|
||||||
|
|
||||||
$typeNames = $this->getCategoryTypes();
|
$typeNames = $this->getCategoryTypes();
|
||||||
|
|
||||||
$typeName = $typeNames[$this->type] ?? ucfirst($this->type);
|
$typeName = $typeNames[$this->type] ?? ucfirst($this->type);
|
||||||
|
|
||||||
$prefix = (!$hideCode && $this->code) ? $this->code . ' - ' : '';
|
$prefix = (!$hideCode && $this->code) ? $this->code . ' - ' : '';
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,28 @@ trait Categories
|
||||||
return in_array($type, $this->getOtherCategoryTypes());
|
return in_array($type, $this->getOtherCategoryTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getTypeCategoryTypes(string $type, string $return = 'array'): string|array
|
||||||
|
{
|
||||||
|
switch ($type) {
|
||||||
|
case Category::INCOME_TYPE:
|
||||||
|
$types = $this->getIncomeCategoryTypes($return);
|
||||||
|
break;
|
||||||
|
case Category::EXPENSE_TYPE:
|
||||||
|
$types = $this->getExpenseCategoryTypes($return);
|
||||||
|
break;
|
||||||
|
case Category::ITEM_TYPE:
|
||||||
|
$types = $this->getItemCategoryTypes($return);
|
||||||
|
break;
|
||||||
|
case Category::OTHER_TYPE:
|
||||||
|
$types = $this->getOtherCategoryTypes($return);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$types = ($return == 'array') ? [$type] : $type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $types;
|
||||||
|
}
|
||||||
|
|
||||||
public function getIncomeCategoryTypes(string $return = 'array'): string|array
|
public function getIncomeCategoryTypes(string $return = 'array'): string|array
|
||||||
{
|
{
|
||||||
return $this->getCategoryTypesByIndex(Category::INCOME_TYPE, $return);
|
return $this->getCategoryTypesByIndex(Category::INCOME_TYPE, $return);
|
||||||
|
|
@ -98,10 +120,46 @@ trait Categories
|
||||||
])->save();
|
])->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCategoryTypes(bool $translate = true, bool $group = false): array
|
public function isGroupCategoryType(): bool
|
||||||
{
|
{
|
||||||
$types = [];
|
$setting_category_types = setting('category.type');
|
||||||
$configs = config('type.category');
|
|
||||||
|
foreach ($setting_category_types as $type => $category) {
|
||||||
|
$categories = explode(',', $category);
|
||||||
|
|
||||||
|
if (count($categories) > 1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hideCodeCategoryType(string $type, bool $default = true): bool
|
||||||
|
{
|
||||||
|
return $this->hideCodeCategoryTypes($type)[$type] ?? $default;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hideCodeCategoryTypes(string|array $types): array
|
||||||
|
{
|
||||||
|
$types = is_string($types) ? explode(',', $types) : $types;
|
||||||
|
|
||||||
|
$type_codes = [];
|
||||||
|
|
||||||
|
foreach ($types as $type) {
|
||||||
|
$config_type = config('type.category.' . $type, []);
|
||||||
|
|
||||||
|
$type_codes[$type] = ! empty($config_type['hide']) && in_array('code', $config_type['hide']) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $type_codes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCategoryTypes(bool $translate = true, bool $group = false, array $types = []): array
|
||||||
|
{
|
||||||
|
$category_types = [];
|
||||||
|
|
||||||
|
$configs = empty($types) ? config('type.category') : array_intersect_key(config('type.category'), array_flip($types));
|
||||||
|
|
||||||
foreach ($configs as $type => $attr) {
|
foreach ($configs as $type => $attr) {
|
||||||
$plural_type = Str::plural($type);
|
$plural_type = Str::plural($type);
|
||||||
|
|
@ -114,13 +172,14 @@ trait Categories
|
||||||
|
|
||||||
if ($group) {
|
if ($group) {
|
||||||
$group_key = $attr['group'] ?? $type;
|
$group_key = $attr['group'] ?? $type;
|
||||||
$types[$group_key][$type] = $translate ? trans_choice($name, 1) : $name;
|
|
||||||
|
$category_types[$group_key][$type] = $translate ? trans_choice($name, 1) : $name;
|
||||||
} else {
|
} else {
|
||||||
$types[$type] = $translate ? trans_choice($name, 1) : $name;
|
$category_types[$type] = $translate ? trans_choice($name, 1) : $name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $types;
|
return $category_types;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getCategoryTabs(): array
|
public function getCategoryTabs(): array
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ trait Import
|
||||||
{
|
{
|
||||||
$id = isset($row['contact_id']) ? $row['contact_id'] : null;
|
$id = isset($row['contact_id']) ? $row['contact_id'] : null;
|
||||||
|
|
||||||
$type = !empty($type) ? $type : (!empty($row['type']) ? (($row['type'] == Transaction::INCOME_TYPE) ? 'customer' : 'vendor') : 'customer');
|
$type = !empty($type) ? $type : (!empty($row['type']) ? (($row['type'] == Transaction::INCOME_TYPE) ? Contact::CUSTOMER_TYPE : Contact::VENDOR_TYPE) : Contact::CUSTOMER_TYPE);
|
||||||
|
|
||||||
if (empty($row['contact_id']) && !empty($row['contact_email'])) {
|
if (empty($row['contact_id']) && !empty($row['contact_email'])) {
|
||||||
$id = $this->getContactIdFromEmail($row, $type);
|
$id = $this->getContactIdFromEmail($row, $type);
|
||||||
|
|
|
||||||
|
|
@ -39,27 +39,13 @@ class Category extends Form
|
||||||
$this->name = 'category_id';
|
$this->name = 'category_id';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($this->type) {
|
$types = $this->getTypeCategoryTypes($this->type);
|
||||||
case Model::INCOME_TYPE:
|
$types_string = implode(',', $types);
|
||||||
$types = $this->getIncomeCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Model::EXPENSE_TYPE:
|
|
||||||
$types = $this->getExpenseCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Model::ITEM_TYPE:
|
|
||||||
$types = $this->getItemCategoryTypes();
|
|
||||||
break;
|
|
||||||
case Model::OTHER_TYPE:
|
|
||||||
$types = $this->getOtherCategoryTypes();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$types = [$this->type];
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->path = route('modals.categories.create', ['type' => $this->type]);
|
$this->path = route('modals.categories.create', ['type' => $this->type]);
|
||||||
$this->remoteAction = route('categories.index', ['search' => 'type:' . implode(',', $types) . ' enabled:1']);
|
$this->remoteAction = route('categories.index', ['search' => 'type:' . $types_string . ' enabled:1']);
|
||||||
|
|
||||||
$typeLabels = collect($this->getCategoryTypes())->only($types)->all();
|
$typeLabels = $this->getCategoryTypes(types: $types);
|
||||||
|
|
||||||
$is_code = false;
|
$is_code = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 />
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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