Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev main #1

Merged
merged 28 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ce0cf17
set correct autoload patch
roncodes Oct 10, 2023
6d0de1b
Pallet Main Folder Structure
TemuulenBM Nov 10, 2023
1870085
Audit Models
TemuulenBM Nov 10, 2023
8352561
fixed product details controller
TemuulenBM Nov 10, 2023
3820ee8
created crud of warehouses,products,suppliers
TemuulenBM Nov 15, 2023
ed32db6
added delete_at column on the tables and created supplier
TemuulenBM Nov 16, 2023
ab06ef5
created warehouse tables on database and created purchase and sales o…
TemuulenBM Nov 17, 2023
0219311
created basic structure of inventory and batch
TemuulenBM Nov 21, 2023
9eae4ec
fixed supplier and models
TemuulenBM Nov 22, 2023
89e093b
fixed supplier details component
TemuulenBM Nov 22, 2023
33cb9f2
edited product form panel based on task
TemuulenBM Nov 22, 2023
1744274
updated product
TemuulenBM Nov 23, 2023
82da83e
Warehouse changes
TemuulenBM Nov 24, 2023
cd47a15
Created models
TemuulenBM Nov 27, 2023
332fc46
created layout section
TemuulenBM Nov 28, 2023
97614d2
created bin,racks,aisles section
TemuulenBM Nov 29, 2023
017da90
created resources of Warehouse dependecies and generated createRecord…
TemuulenBM Nov 30, 2023
182738f
Created Dock
TemuulenBM Dec 1, 2023
b38e1f5
update `.gitignore` remove `server_vendor` directory
roncodes Dec 1, 2023
5c9694f
remove `.php-cs-fixer.cache`
roncodes Dec 1, 2023
b18992c
minor tweaks
roncodes Dec 1, 2023
0f14ede
minor tweak to display product in inventory cell
roncodes Dec 1, 2023
4650c3e
created low stock,expired stock pages
TemuulenBM Dec 4, 2023
5c30f6d
edited sales-order table, added column on sales-order-form-panel,crea…
TemuulenBM Dec 5, 2023
2a959e9
completed Product,Sales and Purchases page
TemuulenBM Dec 6, 2023
ab42a92
fixed inventory,sales-order,purchase-order, and product small issues
TemuulenBM Dec 7, 2023
c18c349
created Product Category page
TemuulenBM Dec 8, 2023
9e7592e
Product Category
TemuulenBM Dec 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions addon/adapters/expired-stock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/low-stock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/warehouse-aisle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/warehouse-bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/warehouse-dock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/warehouse-rack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
1 change: 1 addition & 0 deletions addon/adapters/warehouse-section.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './pallet';
32 changes: 32 additions & 0 deletions addon/components/admin/product-category.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<ContentPanel @title="Categories" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
<div class="mt-3 flex items-center justify-end">
<Button @type="primary" @size="sm" @icon="plus" @text="Add category" @onClick={{this.addCategory}} @disabled={{this.isLoading}} @isLoading={{this.isLoading}} />
</div>
<div class="mt-3">
<ul>
{{#each this.categories as |category|}}
<div class="flex justify-between items-center border-b border-gray-700 py-2">
<span>{{category.name}}</span>
<div class="flex items-center space-x-2">
<Button @type="info" @size="sm" @icon="eye" @text="Add subcategories" @onClick={{fn this.addSubCategory category}} />
<Button @type="danger" @size="sm" @icon="trash" @text="Delete" @onClick={{fn this.deleteCategory category}} />
</div>
</div>

{{#if category.subcategories}}
<ul class="ml-4">
{{#each category.subcategories as |subCategory|}}
<div class="flex justify-between items-center border-b border-gray-700 py-2">
<li>{{subCategory.name}}</li>
<div class="flex items-center space-x-2">
<Button @type="info" @size="sm" @icon="eye" @text="Add subcategories" @onClick={{fn this.addSubCategory subCategory}} />
<Button @type="danger" @size="sm" @icon="trash" @text="Delete" @onClick={{fn this.deleteCategory subCategory}} />
</div>
</div>
{{/each}}
</ul>
{{/if}}
{{/each}}
</ul>
</div>
</ContentPanel>
139 changes: 139 additions & 0 deletions addon/components/admin/product-category.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
}
}
55 changes: 55 additions & 0 deletions addon/components/batch-form-panel.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<Overlay
@onLoad={{this.setOverlayContext}}
@position="right"
@noBackdrop={{true}}
@fullHeight={{true}}
@isResizeble={{or this.isResizable @isResizable}}
@width={{or this.width @width "600px"}}
>
<Overlay::Header
@title={{if this.batch.public_id this.batch.name "Add Batch"}}
@status={{this.batch.public_id}}
@hideStatusDot={{true}}
@createdAt={{this.batch.createdAt}}
@titleWrapperClass="leading-5"
>
<div class="flex flex-1 justify-end">
<Button
@icon={{if this.batch.id "save" "check"}}
@type="primary"
@text={{if this.batch.id "Save Batch" "Add Batch"}}
@onClick={{this.save}}
@wrapperClass="mr-2"
/>
{{#if this.batch.id}}
<Button @type="default" @icon="batch" @helpText="View batch details" @onClick={{this.onViewDetails}} @wrapperClass="mr-2" />
{{/if}}
<Button @type="default" @icon="times" @helpText={{if this.batch.id "Cancel edit batch" "Cancel add batch"}} @onClick={{this.onPressCancel}} />
</div>
</Overlay::Header>

<Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4" @increaseInnerBodyHeightBy={{1000}}>
<div class="grid grid-cols-1 text-xs dark:text-gray-100">
<InputGroup @name="Product">
<ModelSelect
@modelName="pallet-product"
@selectedModel={{this.batch.product}}
@placeholder="Select Product"
@triggerClass="form-select form-input"
@infiniteScroll={{false}}
@renderInPlace={{true}}
@onChange={{fn (mut this.batch.product)}}
@onChangeId={{fn (mut this.batch.product_uuid)}}
as |model|
>
{{model.name}}
</ModelSelect>
</InputGroup>
<InputGroup @name="Quantity" @type="number" @value={{this.batch.quantity}} />
<InputGroup @name="Batch Number" @type="number" @value={{this.batch.batch_number}} />
<InputGroup @name="Batch Reason">
<Textarea @value={{this.batch.reason}} aria-label="Reason" class="w-full form-input" placeholder="Reason" rows={{5}} />
</InputGroup>
</div>
</Overlay::Body>
</Overlay>
128 changes: 128 additions & 0 deletions addon/components/batch-form-panel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { inject as service } from '@ember/service';
import { action } from '@ember/object';
import contextComponentCallback from '../utils/context-component-callback';
import applyContextComponentArguments from '../utils/apply-context-component-arguments';

export default class BatchFormPanelComponent extends Component {
/**
* @service store
*/
@service store;

/**
* @service notifications
*/
@service notifications;

/**
* @service hostRouter
*/
@service hostRouter;

/**
* @service loader
*/
@service loader;

/**
* @service contextPanel
*/
@service contextPanel;

/**
* Overlay context.
* @type {any}
*/
@tracked context;

/**
* Indicates whether the component is in a loading state.
* @type {boolean}
*/
@tracked isLoading = false;

/**
* Fuel Report status
* @type {Array}
*/
@tracked statusOptions = ['draft', 'pending-approval', 'approved', 'rejected', 'revised', 'submitted', 'in-review', 'confirmed', 'processed', 'archived', 'cancelled'];

/**
* Constructs the component and applies initial state.
*/
constructor() {
super(...arguments);
this.batch = this.args.batch;
applyContextComponentArguments(this);
}

/**
* Sets the overlay context.
*
* @action
* @param {OverlayContextObject} overlayContext
*/
@action setOverlayContext(overlayContext) {
this.context = overlayContext;
contextComponentCallback(this, 'onLoad', ...arguments);
}

/**
* Saves the fuel report changes.
*
* @action
* @returns {Promise<any>}
*/
@action save() {
const { batch } = this;

this.loader.showLoader('.next-content-overlay-panel-container', { loadingMessage: 'Saving batch...', preserveTargetPosition: true });
this.isLoading = true;

contextComponentCallback(this, 'onBeforeSave', batch);

try {
return batch
.save()
.then((batch) => {
this.notifications.success(`Batch saved successfully.`);
contextComponentCallback(this, 'onAfterSave', batch);
})
.catch((error) => {
this.notifications.serverError(error);
})
.finally(() => {
this.loader.removeLoader('.next-content-overlay-panel-container ');
this.isLoading = false;
});
} catch (error) {
this.loader.removeLoader('.next-content-overlay-panel-container ');
this.isLoading = false;
}
}

/**
* View the details of the fuel-report.
*
* @action
*/
@action onViewDetails() {
const isActionOverrided = contextComponentCallback(this, 'onViewDetails', this.batch);

if (!isActionOverrided) {
this.contextPanel.focus(this.batch, 'viewing');
}
}

/**
* Handles cancel button press.
*
* @action
* @returns {any}
*/
@action onPressCancel() {
return contextComponentCallback(this, 'onPressCancel', this.batch);
}
}
Loading
Loading