Skip to content

Commit

Permalink
Created models
Browse files Browse the repository at this point in the history
  • Loading branch information
TemuulenBM committed Nov 27, 2023
1 parent 82da83e commit cd47a15
Show file tree
Hide file tree
Showing 16 changed files with 1,490 additions and 39 deletions.
42 changes: 20 additions & 22 deletions addon/components/warehouse-form-panel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,27 @@
<InputGroup @name="Phone">
<PhoneInput @value={{this.warehouse.phone}} @autocomplete="nope" @onInput={{this.phone}} class="form-input w-full" />
</InputGroup>
{{!-- <InputGroup @name="Structural" @wrapperClass="col-span-1">
<Checkbox @checked={{this.warehouse.meta.structural}} @onChange={{this.toggleStructural}} />
<InputGroup @name="Description" @helpText="Additional description text of entity." @wrapperClass="col-span-2 mb-2">
<Textarea @value={{this.warehouse.meta.description}} type="text" class="w-full form-input" placeholder="Description" />
</InputGroup>
<InputGroup @name="External" @wrapperClass="col-span-1">
<Checkbox @checked={{this.warehouse.meta.external}} @onChange={{this.toggleExternal}} />
</InputGroup> --}}
<div><Layout::Section::Header @title="Create" />
<Layout::Section::Body class="overflow-y-scroll h-full">
<div class="container mx-auto h-screen" {{increase-height-by 800}}>
<div class="mx-auto">
<InputGroup @name="Add Sections" @autocomplete="nope" @value={{this.warehouse.warehouse_sections}} @placeholder="Amount of sections" />
{{#if this.warehouse.warehouse_sections}}
<InputGroup @name="Add Aisles" @autocomplete="nope" @value={{this.warehouse.warehouse_aisles}} @placeholder="Amount of aisles" />
{{#if this.warehouse.warehouse_aisles}}
<InputGroup @name="Add Racks" @autocomplete="nope" @value={{this.warehouse.warehouse_racks}} @placeholder="Amount of racks" />
{{#if this.warehouse.warehouse_racks}}
<InputGroup @name="Add Bins" @autocomplete="nope" @value={{this.warehouse.warehouse_bins}} @placeholder="Amount of bins" />
{{/if}}
{{/if}}
{{/if}}
</div>
</div>
</Layout::Section::Body>
<InputGroup @name="Structural" @value={{this.warehouse.meta.structural}} @wrapperClass="col-span-2">
<Checkbox @value={{this.warehouse.meta.structural}} @onChange={{fn this.updateMetaProperty "structural"}} />
</InputGroup>
<InputGroup @name="External" @value={{this.warehouse.meta.external}} @wrapperClass="col-span-2">
<Checkbox @value={{this.warehouse.meta.external}} @onChange={{fn this.updateMetaProperty "external"}} />
</InputGroup>
<div class="flex items-center justify-center">Create Batch</div>
<div>
<InputGroup @name="Add Sections" @autocomplete="nope" @value={{this.warehouse.section}} @placeholder="Amount of sections" />
{{#if this.warehouse.section}}
<InputGroup @name="Add Aisles" @autocomplete="nope" @value={{this.warehouse.aisle}} @placeholder="Amount of aisles" />
{{#if this.warehouse.aisle}}
<InputGroup @name="Add Racks" @autocomplete="nope" @value={{this.warehouse.rack}} @placeholder="Amount of racks" />
{{#if this.warehouse.rack}}
<InputGroup @name="Add Bins" @autocomplete="nope" @value={{this.warehouse.bin}} @placeholder="Amount of bins" />
{{/if}}
{{/if}}
{{/if}}
</div>
</ContentPanel>
</div>
Expand Down
8 changes: 8 additions & 0 deletions addon/components/warehouse-form-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,12 @@ export default class WarehouseFormPanelComponent extends Component {

this.warehouse.setProperties({ location });
}

@action updateMetaProperty(property, value) {
if (isBlank(this.warehouse.meta)) {
this.warehouse.meta = {};
}

this.warehouse.meta[property] = value;
}
}
4 changes: 2 additions & 2 deletions addon/controllers/warehouses/index/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class WarehousesIndexNewController extends Controller {
*
* @var {EntityModel}
*/
@tracked warehouse = this.store.createRecord('warehouse', { type: 'pallet-warehouse' });
@tracked warehouse = this.store.createRecord('warehouse', { type: 'pallet-warehouse', status: 'active', meta: {} });

/**
* Set the overlay component context object.
Expand Down Expand Up @@ -83,6 +83,6 @@ export default class WarehousesIndexNewController extends Controller {
* @memberof WarehousesIndexNewController
*/
resetForm() {
this.warehouse = this.store.createRecord('warehouse', { type: 'pallet-warehouse', status: 'active' });
this.warehouse = this.store.createRecord('warehouse', { type: 'pallet-warehouse', status: 'active', meta: {} });
}
}
41 changes: 41 additions & 0 deletions addon/models/warehouse-aisle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { computed } from '@ember/object';
import { attr, belongsTo } from '@ember-data/model';
import { format as formatDate, isValid as isValidDate } from 'date-fns';

export default class WarehouseAisle extends Model {
/** @ids */
@attr('string') uuid;
@attr('string') public_id;
@attr('string') company_uuid;
@attr('string') created_by_uuid;
@attr('string') section_uuid;

/** @relationships */
@belongsTo('company', { async: true }) company;
@belongsTo('user', { async: true }) createdBy;
@belongsTo('pallet-warehouse-section', { async: true }) section;

/** @attributes */
@attr('string') aisle_number;
@attr('polygon') area;
@attr('raw') meta;

/** @date */
@attr('date') created_at;
@attr('date') updated_at;

/** @computed */
@computed('updated_at') get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'PPP p');
}
}
42 changes: 42 additions & 0 deletions addon/models/warehouse-bin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { computed } from '@ember/object';
import { attr, belongsTo } from '@ember-data/model';
import { format as formatDate, isValid as isValidDate } from 'date-fns';

export default class WarehouseBin extends Model {
/** @ids */
@attr('string') uuid;
@attr('string') public_id;
@attr('string') company_uuid;
@attr('string') created_by_uuid;
@attr('string') rack_uuid;

/** @relationships */
@belongsTo('company', { async: true }) company;
@belongsTo('user', { async: true }) createdBy;
@belongsTo('pallet-warehouse-rack', { async: true }) rack;

/** @attributes */
@attr('string') bin_number;
@attr('string') size;
@attr('string') max_weight;
@attr('raw') meta;

/** @date */
@attr('date') created_at;
@attr('date') updated_at;

/** @computed */
@computed('updated_at') get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'PPP p');
}
}
44 changes: 44 additions & 0 deletions addon/models/warehouse-dock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { computed } from '@ember/object';
import { attr, belongsTo } from '@ember-data/model';
import { format as formatDate, isValid as isValidDate } from 'date-fns';

export default class WarehouseDock extends Model {
/** @ids */
@attr('string') uuid;
@attr('string') public_id;
@attr('string') company_uuid;
@attr('string') created_by_uuid;
@attr('string') warehouse_uuid;

/** @relationships */
@belongsTo('company', { async: true }) company;
@belongsTo('user', { async: true }) createdBy;
@belongsTo('place', { async: true }) warehouse;

/** @attributes */
@attr('string') dock_number;
@attr('string') direction;
@attr('string') capacity;
@attr('string') status;
@attr('string') type;
@attr('raw') meta;

/** @date */
@attr('date') created_at;
@attr('date') updated_at;

/** @computed */
@computed('updated_at') get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'PPP p');
}
}
41 changes: 41 additions & 0 deletions addon/models/warehouse-rack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { computed } from '@ember/object';
import { attr, belongsTo } from '@ember-data/model';
import { format as formatDate, isValid as isValidDate } from 'date-fns';

export default class WarehouseRack extends Model {
/** @ids */
@attr('string') uuid;
@attr('string') public_id;
@attr('string') company_uuid;
@attr('string') created_by_uuid;
@attr('string') aisle_uuid;

/** @relationships */
@belongsTo('company', { async: true }) company;
@belongsTo('user', { async: true }) createdBy;
@belongsTo('pallet-warehouse-aisle', { async: true }) aisle;

/** @attributes */
@attr('string') rack_number;
@attr('string') capacity;
@attr('raw') meta;

/** @date */
@attr('date') created_at;
@attr('date') updated_at;

/** @computed */
@computed('updated_at') get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'PPP p');
}
}
45 changes: 45 additions & 0 deletions addon/models/warehouse-section.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { computed } from '@ember/object';
import { attr, belongsTo } from '@ember-data/model';
import { format as formatDate, isValid as isValidDate, formatDistanceToNow } from 'date-fns';

export default class WarehouseSectionModel extends Model {
/** @ids */
@attr('string') uuid;
@attr('string') public_id;
@attr('string') company_uuid;
@attr('string') created_by_uuid;
@attr('string') warehouse_uuid;

/** @relationships */
@belongsTo('company', { async: true }) company;
@belongsTo('user', { async: true }) createdBy;
@belongsTo('warehouse', { async: true }) warehouse;

/** @attributes */
@attr('string') name;
@attr('string') description;
@attr('polygon') area;
@attr('raw') meta;

/** @date */
@attr('date') created_at;
@attr('date') updated_at;

/** @boolean */
@attr('boolean') isDeleted;

/** @computed */
@computed('updated_at') get updatedAgo() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDistanceToNow(this.updated_at);
}

@computed('updated_at') get updatedAt() {
if (!isValidDate(this.updated_at)) {
return null;
}
return formatDate(this.updated_at, 'PPP p');
}
}
3 changes: 2 additions & 1 deletion addon/routes/warehouses/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default class WarehousesIndexRoute extends Route {
};

model(params) {
return this.store.query('warehouse', params);
// return this.store.query('warehouse', { ...params, with: ['warehouse-section', 'warehouse-rack', 'warehouse-bin', 'warehouse-dock', 'warehouse-aisle', 'batch']});
return this.store.query('warehouse', params)
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
"publish:github": "npm config set '@fleetbase:registry' https://npm.pkg.github.com/ && npm publish"
},
"dependencies": {
"@fleetbase/ember-core": "link:../ember-core",
"@fleetbase/ember-core": "^0.1.8",
"@fleetbase/ember-ui": "^0.2.5",
"@fleetbase/fleetops-data": "link:../fleetops-data",
"@fleetbase/fleetops": "link:../fleetops",
"@fortawesome/ember-fontawesome": "^0.4.1",
"@fortawesome/fontawesome-svg-core": "^6.4.0",
"@fortawesome/free-solid-svg-icons": "^6.4.0",
Expand Down
Loading

0 comments on commit cd47a15

Please sign in to comment.