From cd78448bb2d5875f9bc758d84a4dda604ae7e67e Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Wed, 27 Nov 2024 10:06:58 +0800 Subject: [PATCH] patched addon category, added product status selection, other patches --- .stylelintrc.js | 5 ++++ addon/components/modals/manage-addons.js | 8 +++-- .../products/index/category/new.js | 3 +- addon/controllers/products/index/index.js | 23 -------------- addon/models/product-addon-category.js | 3 ++ addon/styles/storefront-engine.css | 7 +++++ .../templates/products/index/category/new.hbs | 5 +++- composer.json | 2 +- extension.json | 2 +- package.json | 2 +- .../Http/Controllers/ProductController.php | 2 ++ server/src/Models/AddonCategory.php | 30 +++++++++---------- server/src/Models/Product.php | 19 ++++++------ server/src/Models/ProductAddonCategory.php | 2 ++ 14 files changed, 57 insertions(+), 56 deletions(-) diff --git a/.stylelintrc.js b/.stylelintrc.js index 62d4554..f1804fe 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -2,4 +2,9 @@ module.exports = { extends: ['stylelint-config-standard', 'stylelint-prettier/recommended'], + rules: { + 'selector-class-pattern': null, + 'no-descending-specificity': null, + 'color-function-notation': null, + }, }; diff --git a/addon/components/modals/manage-addons.js b/addon/components/modals/manage-addons.js index 6af7325..2b2e634 100644 --- a/addon/components/modals/manage-addons.js +++ b/addon/components/modals/manage-addons.js @@ -117,8 +117,12 @@ export default class ModalsManageAddonsComponent extends Component { owner_uuid: this.activeStore.id, }); - yield category.save(); - this.categories.pushObject(category); + try { + yield category.save(); + this.categories.pushObject(category); + } catch (error) { + this.notifications.serverError(error); + } } /** diff --git a/addon/controllers/products/index/category/new.js b/addon/controllers/products/index/category/new.js index c8dd0f2..345971c 100644 --- a/addon/controllers/products/index/category/new.js +++ b/addon/controllers/products/index/category/new.js @@ -21,11 +21,12 @@ export default class ProductsIndexCategoryNewController extends BaseController { @service crud; @service hostRouter; @alias('storefront.activeStore') activeStore; - @tracked product = this.store.createRecord('product', { store_uuid: this.activeStore.id, currency: this.activeStore.currency, tags: [], meta_array: [] }); + @tracked product = this.store.createRecord('product', { store_uuid: this.activeStore.id, currency: this.activeStore.currency, tags: [], meta_array: [], status: 'published' }); @tracked uploadQueue = []; @tracked uploadedFiles = []; @tracked primaryFile = null; @tracked isSaving = false; + @tracked statusOptions = ['published', 'draft']; abilityPermission = 'storefront create product'; /** overlay options */ diff --git a/addon/controllers/products/index/index.js b/addon/controllers/products/index/index.js index dddefe5..3c2bc09 100644 --- a/addon/controllers/products/index/index.js +++ b/addon/controllers/products/index/index.js @@ -7,32 +7,9 @@ import { timeout } from 'ember-concurrency'; import { task } from 'ember-concurrency-decorators'; export default class ProductsIndexIndexController extends BaseController { - /** - * Inject the `filters` service - * - * @var {Service} - */ @service filters; - - /** - * Inject the `intl` service - * - * @var {Service} - */ @service intl; - - /** - * Inject the `currentUser` service - * - * @var {Service} - */ @service currentUser; - - /** - * Inject the `currentUser` service - * - * @var {Service} - */ @service modalsManager; /** diff --git a/addon/models/product-addon-category.js b/addon/models/product-addon-category.js index f029a23..fa8c0a6 100644 --- a/addon/models/product-addon-category.js +++ b/addon/models/product-addon-category.js @@ -12,6 +12,8 @@ export default class ProductAddonCategoryModel extends Model { /** @attributes */ @attr('string') name; + @attr('number') max_selectable; + @attr('boolean') is_required; @attr('raw') excluded_addons; /** @dates */ @@ -25,6 +27,7 @@ export default class ProductAddonCategoryModel extends Model { category_uuid: this.category_uuid, product_uuid: this.product_uuid, name: this.name, + max_selectable: this.max_selectable, excluded_addons: getWithDefault(this, 'excluded_addons', []), updated_at: this.updated_at, created_at: this.created_at, diff --git a/addon/styles/storefront-engine.css b/addon/styles/storefront-engine.css index 0796010..ba47bbd 100644 --- a/addon/styles/storefront-engine.css +++ b/addon/styles/storefront-engine.css @@ -4,3 +4,10 @@ .ui-combo-box .selected-list a.combo-box-option.selected:hover { background-color: #76a9fa !important; } + +/** hotfix tag input */ +.emberTagInput.form-input { + flex-wrap: wrap !important; + gap: 0.35rem !important; + height: auto !important; +} diff --git a/addon/templates/products/index/category/new.hbs b/addon/templates/products/index/category/new.hbs index 3295b7b..1328c22 100644 --- a/addon/templates/products/index/category/new.hbs +++ b/addon/templates/products/index/category/new.hbs @@ -23,6 +23,9 @@