-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created basic structure of inventory and batch
- Loading branch information
1 parent
ab06ef5
commit 0219311
Showing
111 changed files
with
2,517 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<Overlay | ||
@onLoad={{this.setOverlayContext}} | ||
@position="right" | ||
@noBackdrop={{true}} | ||
@fullHeight={{true}} | ||
@isResizable={{or this.isResizable @isResizable}} | ||
@width={{or this.width @width "600px"}} | ||
> | ||
<Overlay::Header @title="Batch Details" @status={{this.batch.public_id}} @hideStatusDot={{true}} @createdAt={{this.batch.createdAt}}> | ||
<Button @type="default" @icon="pen" @helpText="Edit fuel report" @onClick={{this.onEdit}} @wrapperClass="mr-2" /> | ||
<Button @type="default" @icon="times" @helpText={{if this.batch.id "Cancel edit fuel report" "Cancel new fuel report"}} @onClick={{this.onPressCancel}} /> | ||
</Overlay::Header> | ||
<Overlay::Body class="no-padding" @increaseInnerBodyHeightBy={{1000}}> | ||
<div class="section-header-actions w-full overflow-x-scroll lg:overflow-x-auto"> | ||
<div class="ui-tabs mt-4"> | ||
<nav> | ||
{{#each this.tabs as |tab|}} | ||
<a href="javascript:;" class="ui-tab {{if (eq this.tab.slug tab.slug) 'active'}}" {{on "click" (fn this.onTabChanged tab.slug)}}> | ||
<FaIcon @icon={{tab.icon}} class="mr-1" /> | ||
<span>{{tab.title}}</span> | ||
</a> | ||
{{/each}} | ||
</nav> | ||
</div> | ||
</div> | ||
<div class="tab-content tab-{{this.tab.slug}}"> | ||
{{component this.tab.component batch=this.batch tabOptions=this.tab options=this.tab.componentParams}} | ||
</div> | ||
</Overlay::Body> | ||
</Overlay> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
import Component from '@glimmer/component'; | ||
import { tracked } from '@glimmer/tracking'; | ||
import { inject as service } from '@ember/service'; | ||
import { action } from '@ember/object'; | ||
import { isArray } from '@ember/array'; | ||
import BatchPanelDetailsComponent from './batch-panel/details'; | ||
import contextComponentCallback from '../utils/context-component-callback'; | ||
import applyContextComponentArguments from '../utils/apply-context-component-arguments'; | ||
|
||
export default class BatchPanelComponent extends Component { | ||
/** | ||
* Service for fetching data. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service fetch; | ||
|
||
/** | ||
* Service for managing modals. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service modalsManager; | ||
|
||
/** | ||
* Universe service for managing global data and settings. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service universe; | ||
|
||
/** | ||
* Ember data store service. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service store; | ||
|
||
/** | ||
* Service for managing routing within the host app. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service hostRouter; | ||
|
||
/** | ||
* Service for managing the context panel. | ||
* | ||
* @type {Service} | ||
*/ | ||
@service contextPanel; | ||
|
||
/** | ||
* The current active tab. | ||
* | ||
* @type {Object} | ||
* @tracked | ||
*/ | ||
@tracked tab; | ||
|
||
/** | ||
* The batch being displayed or edited. | ||
* | ||
* @type {batch} | ||
* @tracked | ||
*/ | ||
@tracked batch; | ||
|
||
/** | ||
* Returns the array of tabs available for the panel. | ||
* | ||
* @type {Array} | ||
*/ | ||
get tabs() { | ||
const registeredTabs = this.universe.getMenuItemsFromRegistry('component:batch-panel'); | ||
const defaultTabs = [this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: BatchPanelDetailsComponent })]; | ||
|
||
if (isArray(registeredTabs)) { | ||
return [...defaultTabs, ...registeredTabs]; | ||
} | ||
|
||
return defaultTabs; | ||
} | ||
|
||
/** | ||
* Initializes the batch panel component. | ||
*/ | ||
constructor() { | ||
super(...arguments); | ||
this.batch = this.args.batch; | ||
this.tab = this.getTabUsingSlug(this.args.tab); | ||
applyContextComponentArguments(this); | ||
} | ||
|
||
/** | ||
* Sets the overlay context. | ||
* | ||
* @action | ||
* @param {OverlayContextObject} overlayContext | ||
*/ | ||
@action setOverlayContext(overlayContext) { | ||
this.context = overlayContext; | ||
contextComponentCallback(this, 'onLoad', ...arguments); | ||
} | ||
|
||
/** | ||
* Handles changing the active tab. | ||
* | ||
* @method | ||
* @param {String} tab - The new tab to switch to. | ||
* @action | ||
*/ | ||
@action onTabChanged(tab) { | ||
this.tab = this.getTabUsingSlug(tab); | ||
contextComponentCallback(this, 'onTabChanged', tab); | ||
} | ||
|
||
/** | ||
* Handles edit action for the batch. | ||
* | ||
* @method | ||
* @action | ||
*/ | ||
@action onEdit() { | ||
const isActionOverrided = contextComponentCallback(this, 'onEdit', this.batch); | ||
|
||
if (!isActionOverrided) { | ||
this.contextPanel.focus(this.batch, 'editing', { | ||
onAfterSave: () => { | ||
this.contextPanel.clear(); | ||
}, | ||
}); | ||
} | ||
} | ||
|
||
/** | ||
* Handles the cancel action. | ||
* | ||
* @method | ||
* @action | ||
* @returns {Boolean} Indicates whether the cancel action was overridden. | ||
*/ | ||
@action onPressCancel() { | ||
return contextComponentCallback(this, 'onPressCancel', this.batch); | ||
} | ||
|
||
/** | ||
* Finds and returns a tab based on its slug. | ||
* | ||
* @param {String} tabSlug - The slug of the tab. | ||
* @returns {Object|null} The found tab or null. | ||
*/ | ||
getTabUsingSlug(tabSlug) { | ||
if (tabSlug) { | ||
return this.tabs.find(({ slug }) => slug === tabSlug); | ||
} | ||
|
||
return this.tabs[0]; | ||
} | ||
} |
Oops, something went wrong.