From ce25e05b640f81e83f5ce10c0f5339bdcbb1da0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= Date: Sat, 14 Mar 2026 00:56:18 +0300 Subject: [PATCH] updated code visibility and streamline category type handling --- resources/assets/js/mixins/global.js | 24 ++++++++++++++++++- .../assets/js/views/settings/categories.js | 18 +------------- .../components/form/group/category.blade.php | 8 +++---- .../views/modals/categories/create.blade.php | 16 ++++--------- .../settings/categories/create.blade.php | 11 +++------ .../views/settings/categories/edit.blade.php | 16 ++++--------- .../views/settings/categories/index.blade.php | 6 ++--- .../categories/sub_category.blade.php | 1 + 8 files changed, 45 insertions(+), 55 deletions(-) diff --git a/resources/assets/js/mixins/global.js b/resources/assets/js/mixins/global.js index 3a19616ff..7adcd3f6c 100644 --- a/resources/assets/js/mixins/global.js +++ b/resources/assets/js/mixins/global.js @@ -228,7 +228,7 @@ export default {
chevron_left
- `; + `; item.querySelector('[data-tabs-swiper]').innerHTML = html; 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]; }, + 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 onSelectAllBulkAction() { this.bulk_action.selectAll(); diff --git a/resources/assets/js/views/settings/categories.js b/resources/assets/js/views/settings/categories.js index 683d5f0e4..c60350dd5 100644 --- a/resources/assets/js/views/settings/categories.js +++ b/resources/assets/js/views/settings/categories.js @@ -31,31 +31,15 @@ const app = new Vue({ bulk_action: new BulkAction('categories'), categoriesBasedTypes: null, 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: { - changeCategories(event) { + updateParentCategories(event) { if (event === '') { return; } - if (this.type_codes[event] !== undefined) { - this.show_code_field = this.type_codes[event]; - } - if (typeof JSON.parse(this.form.categories)[event] === 'undefined') { this.categoriesBasedTypes = []; diff --git a/resources/views/components/form/group/category.blade.php b/resources/views/components/form/group/category.blade.php index 9c7c6de95..11662ef61 100644 --- a/resources/views/components/form/group/category.blade.php +++ b/resources/views/components/form/group/category.blade.php @@ -27,7 +27,7 @@ >