diff --git a/.gitignore b/.gitignore index f1e859b2..2fff49f9 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,16 @@ # broccoli-debug /DEBUG/ + +# server +.idea/* +.idea/codeStyleSettings.xml +composer.lock +/server_vendor +/server/vendor/ +.phpunit.result.cache +.php_cs.cache +.php-cs-fixer.cache +*.swp +*.swo +.DS_Store diff --git a/addon/adapters/expired-stock.js b/addon/adapters/expired-stock.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/expired-stock.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/low-stock.js b/addon/adapters/low-stock.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/low-stock.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/warehouse-aisle.js b/addon/adapters/warehouse-aisle.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/warehouse-aisle.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/warehouse-bin.js b/addon/adapters/warehouse-bin.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/warehouse-bin.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/warehouse-dock.js b/addon/adapters/warehouse-dock.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/warehouse-dock.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/warehouse-rack.js b/addon/adapters/warehouse-rack.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/warehouse-rack.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/adapters/warehouse-section.js b/addon/adapters/warehouse-section.js new file mode 100644 index 00000000..5728057c --- /dev/null +++ b/addon/adapters/warehouse-section.js @@ -0,0 +1 @@ +export { default } from './pallet'; diff --git a/addon/components/admin/product-category.hbs b/addon/components/admin/product-category.hbs new file mode 100644 index 00000000..7819d8cb --- /dev/null +++ b/addon/components/admin/product-category.hbs @@ -0,0 +1,32 @@ + +
+
+
+ +
+
\ No newline at end of file diff --git a/addon/components/admin/product-category.js b/addon/components/admin/product-category.js new file mode 100644 index 00000000..27ec16de --- /dev/null +++ b/addon/components/admin/product-category.js @@ -0,0 +1,139 @@ +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { dasherize } from '@ember/string'; + +export default class AdminProductCategoryComponent extends Component { + @service store; + @service modalsManager; + @service currentUser; + @service modalsManager; + @service notifications; + @service fetch; + @service hostRouter; + @tracked categories = []; + @tracked selectedCategory; + @tracked isLoading = false; + @tracked buttonTitle = null; + + constructor() { + super(...arguments); + this.category = this.args.category; + this.fetchCategoryHierarchy(); + } + + @action async addCategory() { + const category = this.store.createRecord('category', { + for: 'pallet_product', + }); + + this.modalsManager.show('modals/create-product-category', { + title: 'Create a new product category', + acceptButtonIcon: 'check', + acceptButtonIconPrefix: 'fas', + declineButtonIcon: 'times', + declineButtonIconPrefix: 'fas', + category, + uploadNewPhoto: (file) => { + this.fetch.uploadFile.perform( + file, + { + path: `uploads/${category.company_uuid}/product-category-icon/${dasherize(category.name ?? this.currentUser.companyId)}`, + subject_uuid: category.id, + subject_type: `category`, + type: `category_icon`, + }, + (uploadedFile) => { + category.setProperties({ + icon_file_uuid: uploadedFile.id, + icon_url: uploadedFile.url, + icon: uploadedFile, + }); + } + ); + }, + confirm: (modal) => { + modal.startLoading(); + + return category.save().then(() => { + this.notifications.success('New product category created.'); + return this.fetchCategoryHierarchy(); + }); + }, + }); + } + + @action async fetchCategoryHierarchy() { + const allCategories = await this.store.query('category', { + for: 'pallet_product', + with_subcategories: true, + }); + + this.categories = allCategories.filter((category) => !category.parent); + this.categories.forEach((parentCategory) => { + parentCategory.subcategories = allCategories.filter((subcategory) => subcategory.parent?.id === parentCategory.id); + }); + } + + @action async addSubCategory(parentCategory) { + const subCategory = this.store.createRecord('category', { + parent: parentCategory, + for: 'pallet_product', + }); + + this.modalsManager.show('modals/create-product-category', { + title: 'Create a new subcategory', + acceptButtonIcon: 'check', + acceptButtonIconPrefix: 'fas', + declineButtonIcon: 'times', + declineButtonIconPrefix: 'fas', + category: subCategory, + uploadNewPhoto: (file) => { + this.fetch.uploadFile.perform( + file, + { + path: `uploads/${category.company_uuid}/product-category-icon/${dasherize(category.name ?? this.currentUser.companyId)}`, + subject_uuid: category.id, + subject_type: `category`, + type: `category_icon`, + }, + (uploadedFile) => { + category.setProperties({ + icon_file_uuid: uploadedFile.id, + icon_url: uploadedFile.url, + icon: uploadedFile, + }); + } + ); + }, + confirm: async (modal) => { + modal.startLoading(); + + try { + await subCategory.save(); + this.notifications.success('New subcategory created.'); + await this.fetchCategoryHierarchy(); + } catch (error) { + this.notifications.error('Error creating subcategory.'); + console.error('Error creating subcategory:', error); + } + }, + }); + } + + @action async deleteCategory(category) { + const confirmation = confirm(`Are you sure you want to delete the category "${category.name}"?`); + + if (confirmation) { + try { + await category.destroyRecord(); + this.notifications.success('Category deleted successfully.'); + await this.fetchCategoryHierarchy(); + } catch (error) { + this.notifications.error('Error deleting category.'); + console.error('Error deleting category:', error); + } + } + } +} diff --git a/addon/components/batch-form-panel.hbs b/addon/components/batch-form-panel.hbs new file mode 100644 index 00000000..9d275d44 --- /dev/null +++ b/addon/components/batch-form-panel.hbs @@ -0,0 +1,55 @@ + + +
+
+
+ + +
+ + + {{model.name}} + + + + + +