Skip to content

Commit

Permalink
created warehouse tables on database and created purchase and sales o…
Browse files Browse the repository at this point in the history
…rders
  • Loading branch information
TemuulenBM committed Nov 17, 2023
1 parent ed32db6 commit ab06ef5
Show file tree
Hide file tree
Showing 46 changed files with 1,495 additions and 336 deletions.
57 changes: 56 additions & 1 deletion addon/components/purchase-order-form-panel.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,56 @@
{{yield}}
<Overlay
@onLoad={{this.setOverlayContext}}
@position="right"
@noBackdrop={{true}}
@fullHeight={{true}}
@isResizeable={{or this.isResizable @isResizable}}
@width={{or this.width @width "600px"}}
>
<Overlay::Header
@title={{if this.purchaseOrder.public_id this.purchaseOrder.name "New Purchase Order"}}
@status={{this.purchaseOrder.public_id}}
@hideStatusDot={{true}}
@createdAt={{this.purchaseOrder.createdAt}}
@titleWrapperClass="leading-5"
>
<div class="flex flex-1 justify-end">
<Button
@icon={{if this.purchaseOrder.id "save" "check"}}
@type="primary"
@text={{if this.purchaseOrder.id "Save Purchase Order" "Create Purchase Order"}}
@onClick={{this.save}}
@wrapperClass="mr-2"
/>
{{#if this.purchaseOrder.id}}
<Button @type="default" @icon="file-invoice" @helpText="View purchase order details" @onClick={{this.onViewDetails}} @wrapperClass="mr-2" />
{{/if}}
<Button @type="default" @icon="times" @helpText={{if this.purchaseOrder.id "Cancel edit purchase order" "Cancel new purchase order"}} @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="Status">
<div class="fleetbase-model-select fleetbase-power-select ember-model-select">
<PowerSelect
@options={{this.statusOptions}}
@selected={{this.purchaseOrder.status}}
@onChange={{fn (mut this.purchaseOrder.status)}}
@placeholder="Select purchase order status"
@triggerClass="form-select form-input"
as |status|
>
{{smart-humanize status}}
</PowerSelect>
</div>
</InputGroup>
<InputGroup @name="Purchase order description">
<Textarea @value={{this.purchaseOrder.description}} aria-label="Description" class="w-full form-input" placeholder="Description" rows={{5}} />
</InputGroup>
<InputGroup @name="Purchase order comments">
<Textarea @value={{this.purchaseOrder.comments}} aria-label="Comments" class="w-full form-input" placeholder="Comments" rows={{5}} />
</InputGroup>
<InputGroup @name="Delivery date" @type="date" @value={{this.purchaseOrder.deliveredAt}} />
</div>
</Overlay::Body>
</Overlay>
151 changes: 150 additions & 1 deletion addon/components/purchase-order-form-panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,152 @@
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 PurchaseOrderFormPanelComponent extends Component {}
export default class PurchaseOrderFormPanelComponent extends Component {
/**
* @service store
*/
@service store;

/**
* @service fetch
*/
@service fetch;

/**
* @service currentUser
*/
@service currentUser;

/**
* @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;

/**
* All possible purchaseOrder status options.
*
* @var {String}
*/
@tracked statusOptions = ['pending', 'active', 'prospective', 'archived'];

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

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

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

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

contextComponentCallback(this, 'onBeforeSave', purchaseOrder);

try {
return purchaseOrder
.save()
.then((purchaseOrder) => {
this.notifications.success(`Sales order (${purchaseOrder.id}) saved successfully.`);
contextComponentCallback(this, 'onAfterSave', purchaseOrder);
})
.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;
}
}

/**
* Uploads a new photo for the driver.
*
* @param {File} file
* @memberof PurchaseOrderFormPanelComponent
*/

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

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

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

/**
* Uploads a file to the server for the purchaseOrder.
*
* @param {File} file
*/
}
31 changes: 30 additions & 1 deletion addon/components/purchase-order-panel.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
{{yield}}
<Overlay
@onLoad={{this.setOverlayContext}}
@position="right"
@noBackdrop={{true}}
@fullHeight={{true}}
@isResizable={{or this.isResizable @isResizable}}
@width={{or this.width @width "600px"}}
>
<Overlay::Header @title="Purchase Order Details" @status={{this.purchaseOrder.public_id}} @hideStatusDot={{true}} @createdAt={{this.purchaseOrder.createdAt}}>
<Button @type="default" @icon="pen" @helpText="Edit sales order" @onClick={{this.onEdit}} @wrapperClass="mr-2" />
<Button @type="default" @icon="times" @helpText={{if this.purchaseOrder.id "Cancel edit sales order" "Cancel new sales order"}} @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 purchaseOrder=this.purchaseOrder tabOptions=this.tab options=this.tab.componentParams}}
</div>
</Overlay::Body>
</Overlay>
Loading

0 comments on commit ab06ef5

Please sign in to comment.