@fleetbase/storefront-engine 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +9 -0
- package/README.md +32 -0
- package/addon/adapters/addon-category.js +1 -0
- package/addon/adapters/customer.js +1 -0
- package/addon/adapters/gateway.js +1 -0
- package/addon/adapters/network.js +1 -0
- package/addon/adapters/notification-channel.js +1 -0
- package/addon/adapters/product-addon-category.js +1 -0
- package/addon/adapters/product-addon.js +1 -0
- package/addon/adapters/product-hour.js +1 -0
- package/addon/adapters/product-store-location.js +1 -0
- package/addon/adapters/product-variant-option.js +1 -0
- package/addon/adapters/product-variant.js +1 -0
- package/addon/adapters/product.js +1 -0
- package/addon/adapters/store-hour.js +1 -0
- package/addon/adapters/store-location.js +1 -0
- package/addon/adapters/store.js +1 -0
- package/addon/adapters/storefront.js +5 -0
- package/addon/components/file-record.hbs +22 -0
- package/addon/components/file-record.js +43 -0
- package/addon/components/modals/add-store-hours.hbs +8 -0
- package/addon/components/modals/add-stores-to-network.hbs +5 -0
- package/addon/components/modals/assign-driver.hbs +25 -0
- package/addon/components/modals/create-first-store.hbs +21 -0
- package/addon/components/modals/create-gateway.hbs +35 -0
- package/addon/components/modals/create-network-category.hbs +50 -0
- package/addon/components/modals/create-network.hbs +20 -0
- package/addon/components/modals/create-new-variant.hbs +15 -0
- package/addon/components/modals/create-notification-channel.hbs +45 -0
- package/addon/components/modals/create-product-category.hbs +30 -0
- package/addon/components/modals/create-store.hbs +9 -0
- package/addon/components/modals/edit-network.hbs +1 -0
- package/addon/components/modals/import-products.hbs +97 -0
- package/addon/components/modals/incoming-order.hbs +242 -0
- package/addon/components/modals/manage-addons.hbs +50 -0
- package/addon/components/modals/manage-addons.js +86 -0
- package/addon/components/modals/order-ready-assign-driver.hbs +36 -0
- package/addon/components/modals/select-addon-category.hbs +5 -0
- package/addon/components/modals/share-network.hbs +35 -0
- package/addon/components/modals/store-location-form.hbs +30 -0
- package/addon/components/order-card.hbs +1 -0
- package/addon/components/order-card.js +3 -0
- package/addon/components/schedule-manager.hbs +22 -0
- package/addon/components/schedule-manager.js +73 -0
- package/addon/components/settings-container.hbs +7 -0
- package/addon/components/store-selector.hbs +21 -0
- package/addon/components/store-selector.js +20 -0
- package/addon/components/widget/customers.hbs +44 -0
- package/addon/components/widget/customers.js +53 -0
- package/addon/components/widget/orders.hbs +111 -0
- package/addon/components/widget/orders.js +248 -0
- package/addon/components/widget/storefront-metrics.hbs +54 -0
- package/addon/components/widget/storefront-metrics.js +61 -0
- package/addon/controllers/application.js +33 -0
- package/addon/controllers/customers/index.js +267 -0
- package/addon/controllers/home.js +3 -0
- package/addon/controllers/networks/index/network/customers.js +3 -0
- package/addon/controllers/networks/index/network/index.js +147 -0
- package/addon/controllers/networks/index/network/orders.js +3 -0
- package/addon/controllers/networks/index/network/stores.js +370 -0
- package/addon/controllers/networks/index/network.js +29 -0
- package/addon/controllers/networks/index.js +138 -0
- package/addon/controllers/orders/index.js +331 -0
- package/addon/controllers/products/index/category/edit.js +62 -0
- package/addon/controllers/products/index/category/new.js +287 -0
- package/addon/controllers/products/index/category.js +163 -0
- package/addon/controllers/products/index/index/edit.js +1 -0
- package/addon/controllers/products/index/index.js +136 -0
- package/addon/controllers/products/index.js +203 -0
- package/addon/controllers/settings/api.js +3 -0
- package/addon/controllers/settings/gateways.js +110 -0
- package/addon/controllers/settings/index.js +102 -0
- package/addon/controllers/settings/locations.js +186 -0
- package/addon/controllers/settings/notifications.js +102 -0
- package/addon/engine.js +19 -0
- package/addon/helpers/get-tip-amount.js +5 -0
- package/addon/models/addon-category.js +6 -0
- package/addon/models/gateway.js +46 -0
- package/addon/models/network.js +166 -0
- package/addon/models/notification-channel.js +47 -0
- package/addon/models/product-addon-category.js +41 -0
- package/addon/models/product-addon.js +41 -0
- package/addon/models/product-hour.js +72 -0
- package/addon/models/product-store-location.js +41 -0
- package/addon/models/product-variant-option.js +39 -0
- package/addon/models/product-variant.js +44 -0
- package/addon/models/product.js +208 -0
- package/addon/models/store-hour.js +72 -0
- package/addon/models/store-location.js +93 -0
- package/addon/models/store.js +100 -0
- package/addon/routes/application.js +47 -0
- package/addon/routes/customers/index/edit.js +3 -0
- package/addon/routes/customers/index.js +25 -0
- package/addon/routes/home.js +3 -0
- package/addon/routes/networks/index/network/customers.js +3 -0
- package/addon/routes/networks/index/network/index.js +15 -0
- package/addon/routes/networks/index/network/orders.js +3 -0
- package/addon/routes/networks/index/network/stores.js +28 -0
- package/addon/routes/networks/index/network.js +10 -0
- package/addon/routes/networks/index.js +19 -0
- package/addon/routes/orders/index/edit.js +3 -0
- package/addon/routes/orders/index/new.js +3 -0
- package/addon/routes/orders/index/view.js +3 -0
- package/addon/routes/orders/index.js +29 -0
- package/addon/routes/products/index/category/edit.js +15 -0
- package/addon/routes/products/index/category/new.js +7 -0
- package/addon/routes/products/index/category.js +54 -0
- package/addon/routes/products/index/index/edit.js +1 -0
- package/addon/routes/products/index/index.js +22 -0
- package/addon/routes/products/index.js +21 -0
- package/addon/routes/settings/api.js +10 -0
- package/addon/routes/settings/gateways.js +11 -0
- package/addon/routes/settings/index.js +16 -0
- package/addon/routes/settings/locations.js +14 -0
- package/addon/routes/settings/notifications.js +11 -0
- package/addon/routes.js +48 -0
- package/addon/serializers/addon-category.js +15 -0
- package/addon/serializers/network.js +19 -0
- package/addon/serializers/notification-channel.js +15 -0
- package/addon/serializers/product-addon-category.js +15 -0
- package/addon/serializers/product-variant.js +15 -0
- package/addon/serializers/product.js +20 -0
- package/addon/serializers/store-location.js +17 -0
- package/addon/serializers/store.js +19 -0
- package/addon/services/storefront.js +208 -0
- package/addon/templates/application.hbs +16 -0
- package/addon/templates/customers/index/edit.hbs +2 -0
- package/addon/templates/customers/index.hbs +22 -0
- package/addon/templates/home.hbs +7 -0
- package/addon/templates/networks/index/network/customers.hbs +2 -0
- package/addon/templates/networks/index/network/index.hbs +254 -0
- package/addon/templates/networks/index/network/orders.hbs +2 -0
- package/addon/templates/networks/index/network/stores.hbs +164 -0
- package/addon/templates/networks/index/network.hbs +38 -0
- package/addon/templates/networks/index.hbs +60 -0
- package/addon/templates/orders/index/edit.hbs +2 -0
- package/addon/templates/orders/index/new.hbs +2 -0
- package/addon/templates/orders/index/view.hbs +2 -0
- package/addon/templates/orders/index.hbs +22 -0
- package/addon/templates/products/index/category/edit.hbs +1 -0
- package/addon/templates/products/index/category/new.hbs +248 -0
- package/addon/templates/products/index/category.hbs +41 -0
- package/addon/templates/products/index/index/edit.hbs +1 -0
- package/addon/templates/products/index/index.hbs +40 -0
- package/addon/templates/products/index.hbs +22 -0
- package/addon/templates/settings/api.hbs +18 -0
- package/addon/templates/settings/gateways.hbs +48 -0
- package/addon/templates/settings/index.hbs +229 -0
- package/addon/templates/settings/locations.hbs +39 -0
- package/addon/templates/settings/notifications.hbs +35 -0
- package/addon/templates/settings.hbs +30 -0
- package/addon/utils/get-gateway-schemas.js +34 -0
- package/addon/utils/get-notification-schemas.js +18 -0
- package/app/adapters/addon-category.js +1 -0
- package/app/adapters/gateway.js +1 -0
- package/app/adapters/network.js +1 -0
- package/app/adapters/notification-channel.js +1 -0
- package/app/adapters/product-addon-category.js +1 -0
- package/app/adapters/product-addon.js +1 -0
- package/app/adapters/product-hour.js +1 -0
- package/app/adapters/product-store-location.js +1 -0
- package/app/adapters/product-variant-option.js +1 -0
- package/app/adapters/product-variant.js +1 -0
- package/app/adapters/product.js +1 -0
- package/app/adapters/store-hour.js +1 -0
- package/app/adapters/store-location.js +1 -0
- package/app/adapters/store.js +1 -0
- package/app/adapters/storefront.js +1 -0
- package/app/components/file-record.js +1 -0
- package/app/components/modals/add-store-hours.js +1 -0
- package/app/components/modals/add-stores-to-network.js +1 -0
- package/app/components/modals/assign-driver.js +1 -0
- package/app/components/modals/create-first-store.js +1 -0
- package/app/components/modals/create-gateway.js +1 -0
- package/app/components/modals/create-network-category.js +1 -0
- package/app/components/modals/create-network.js +1 -0
- package/app/components/modals/create-new-variant.js +1 -0
- package/app/components/modals/create-notification-channel.js +1 -0
- package/app/components/modals/create-product-category.js +1 -0
- package/app/components/modals/create-store.js +1 -0
- package/app/components/modals/edit-network.js +1 -0
- package/app/components/modals/import-products.js +1 -0
- package/app/components/modals/incoming-order.js +1 -0
- package/app/components/modals/manage-addons.js +1 -0
- package/app/components/modals/order-ready-assign-driver.js +1 -0
- package/app/components/modals/select-addon-category.js +1 -0
- package/app/components/modals/share-network.js +1 -0
- package/app/components/modals/store-location-form.js +1 -0
- package/app/components/order-card.js +1 -0
- package/app/components/schedule-manager.js +1 -0
- package/app/components/settings-container.js +1 -0
- package/app/components/store-selector.js +1 -0
- package/app/components/widget/customers.js +1 -0
- package/app/components/widget/orders.js +1 -0
- package/app/components/widget/storefront-metrics.js +1 -0
- package/app/controllers/application.js +1 -0
- package/app/controllers/customers/index.js +1 -0
- package/app/controllers/home.js +1 -0
- package/app/controllers/networks/index/network/customers.js +1 -0
- package/app/controllers/networks/index/network/index.js +1 -0
- package/app/controllers/networks/index/network/orders.js +1 -0
- package/app/controllers/networks/index/network/stores.js +1 -0
- package/app/controllers/networks/index/network.js +1 -0
- package/app/controllers/networks/index.js +1 -0
- package/app/controllers/orders/index.js +1 -0
- package/app/controllers/products/index/category/edit.js +1 -0
- package/app/controllers/products/index/category/new.js +1 -0
- package/app/controllers/products/index/category.js +1 -0
- package/app/controllers/products/index/index/edit.js +1 -0
- package/app/controllers/products/index/index.js +1 -0
- package/app/controllers/products/index.js +1 -0
- package/app/controllers/settings/api.js +1 -0
- package/app/controllers/settings/gateways.js +1 -0
- package/app/controllers/settings/index.js +1 -0
- package/app/controllers/settings/locations.js +1 -0
- package/app/controllers/settings/notifications.js +1 -0
- package/app/helpers/get-tip-amount.js +1 -0
- package/app/models/addon-category.js +1 -0
- package/app/models/gateway.js +1 -0
- package/app/models/network.js +1 -0
- package/app/models/notification-channel.js +1 -0
- package/app/models/product-addon-category.js +1 -0
- package/app/models/product-addon.js +1 -0
- package/app/models/product-hour.js +1 -0
- package/app/models/product-store-location.js +1 -0
- package/app/models/product-variant-option.js +1 -0
- package/app/models/product-variant.js +1 -0
- package/app/models/product.js +1 -0
- package/app/models/store-hour.js +1 -0
- package/app/models/store-location.js +1 -0
- package/app/models/store.js +1 -0
- package/app/routes/application.js +1 -0
- package/app/routes/customers/index/edit.js +1 -0
- package/app/routes/customers/index.js +1 -0
- package/app/routes/home.js +1 -0
- package/app/routes/networks/index/network/customers.js +1 -0
- package/app/routes/networks/index/network/index.js +1 -0
- package/app/routes/networks/index/network/orders.js +1 -0
- package/app/routes/networks/index/network/stores.js +1 -0
- package/app/routes/networks/index/network.js +1 -0
- package/app/routes/networks/index.js +1 -0
- package/app/routes/orders/index/edit.js +1 -0
- package/app/routes/orders/index/new.js +1 -0
- package/app/routes/orders/index/view.js +1 -0
- package/app/routes/orders/index.js +1 -0
- package/app/routes/products/index/category/edit.js +1 -0
- package/app/routes/products/index/category/new.js +1 -0
- package/app/routes/products/index/category.js +1 -0
- package/app/routes/products/index/index/edit.js +1 -0
- package/app/routes/products/index/index.js +1 -0
- package/app/routes/products/index.js +1 -0
- package/app/routes/settings/api.js +1 -0
- package/app/routes/settings/gateways.js +1 -0
- package/app/routes/settings/index.js +1 -0
- package/app/routes/settings/locations.js +1 -0
- package/app/routes/settings/notifications.js +1 -0
- package/app/serializers/addon-category.js +1 -0
- package/app/serializers/network.js +1 -0
- package/app/serializers/notification-channel.js +1 -0
- package/app/serializers/product-addon-category.js +1 -0
- package/app/serializers/product-variant.js +1 -0
- package/app/serializers/product.js +1 -0
- package/app/serializers/store-location.js +1 -0
- package/app/serializers/store.js +1 -0
- package/app/services/storefront.js +1 -0
- package/app/templates/customers/index/edit.js +1 -0
- package/app/templates/customers/index.js +1 -0
- package/app/templates/home.js +1 -0
- package/app/templates/networks/index/network/customers.js +1 -0
- package/app/templates/networks/index/network/index.js +1 -0
- package/app/templates/networks/index/network/orders.js +1 -0
- package/app/templates/networks/index/network/stores.js +1 -0
- package/app/templates/networks/index/network.js +1 -0
- package/app/templates/networks/index.js +1 -0
- package/app/templates/orders/index/edit.js +1 -0
- package/app/templates/orders/index/new.js +1 -0
- package/app/templates/orders/index/view.js +1 -0
- package/app/templates/orders/index.js +1 -0
- package/app/templates/products/index/category/edit.js +1 -0
- package/app/templates/products/index/category/new.js +1 -0
- package/app/templates/products/index/category.js +1 -0
- package/app/templates/products/index/index/edit.js +1 -0
- package/app/templates/products/index/index.js +1 -0
- package/app/templates/products/index.js +1 -0
- package/app/templates/settings/api.js +1 -0
- package/app/templates/settings/gateways.js +1 -0
- package/app/templates/settings/index.js +1 -0
- package/app/templates/settings/locations.js +1 -0
- package/app/templates/settings/notifications.js +1 -0
- package/app/templates/settings.js +1 -0
- package/app/utils/get-gateway-schemas.js +1 -0
- package/app/utils/get-notification-schemas.js +1 -0
- package/config/environment.js +21 -0
- package/index.js +22 -0
- package/package.json +123 -0
- package/pnpm-lock.yaml +12509 -0
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import Controller, { inject as controller } from '@ember/controller';
|
|
2
|
+
import { inject as service } from '@ember/service';
|
|
3
|
+
import { tracked } from '@glimmer/tracking';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { isBlank } from '@ember/utils';
|
|
6
|
+
import { timeout } from 'ember-concurrency';
|
|
7
|
+
import { task } from 'ember-concurrency-decorators';
|
|
8
|
+
|
|
9
|
+
export default class OrdersIndexController extends Controller {
|
|
10
|
+
/**
|
|
11
|
+
* Inject the `notifications` service
|
|
12
|
+
*
|
|
13
|
+
* @var {Service}
|
|
14
|
+
*/
|
|
15
|
+
@service notifications;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Inject the `modals-manager` service
|
|
19
|
+
*
|
|
20
|
+
* @var {Service}
|
|
21
|
+
*/
|
|
22
|
+
@service modalsManager;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Inject the `crud` service
|
|
26
|
+
*
|
|
27
|
+
* @var {Service}
|
|
28
|
+
*/
|
|
29
|
+
@service crud;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Inject the `fetch` service
|
|
33
|
+
*
|
|
34
|
+
* @var {Service}
|
|
35
|
+
*/
|
|
36
|
+
@service fetch;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Inject the `filters` service
|
|
40
|
+
*
|
|
41
|
+
* @var {Service}
|
|
42
|
+
*/
|
|
43
|
+
@service filters;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Queryable parameters for this controller's model
|
|
47
|
+
*
|
|
48
|
+
* @var {Array}
|
|
49
|
+
*/
|
|
50
|
+
queryParams = [
|
|
51
|
+
'page',
|
|
52
|
+
'limit',
|
|
53
|
+
'sort',
|
|
54
|
+
'query',
|
|
55
|
+
'public_id',
|
|
56
|
+
'internal_id',
|
|
57
|
+
'payload',
|
|
58
|
+
'tracking_number',
|
|
59
|
+
'facilitator',
|
|
60
|
+
'customer',
|
|
61
|
+
'driver',
|
|
62
|
+
'pickup',
|
|
63
|
+
'dropoff',
|
|
64
|
+
'created_by',
|
|
65
|
+
'updated_by',
|
|
66
|
+
'status',
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
@tracked page = 1;
|
|
70
|
+
@tracked limit;
|
|
71
|
+
@tracked query;
|
|
72
|
+
@tracked sort = '-created_at';
|
|
73
|
+
@tracked public_id;
|
|
74
|
+
@tracked internal_id;
|
|
75
|
+
@tracked tracking;
|
|
76
|
+
@tracked facilitator;
|
|
77
|
+
@tracked customer;
|
|
78
|
+
@tracked driver;
|
|
79
|
+
@tracked payload;
|
|
80
|
+
@tracked pickup;
|
|
81
|
+
@tracked dropoff;
|
|
82
|
+
@tracked updated_by;
|
|
83
|
+
@tracked created_by;
|
|
84
|
+
@tracked status;
|
|
85
|
+
|
|
86
|
+
@tracked columns = [
|
|
87
|
+
{
|
|
88
|
+
label: 'ID',
|
|
89
|
+
valuePath: 'public_id',
|
|
90
|
+
width: '150px',
|
|
91
|
+
cellComponent: 'table/cell/link-to',
|
|
92
|
+
route: 'orders.index.view',
|
|
93
|
+
// onLinkClick: this.viewOrder,
|
|
94
|
+
resizable: true,
|
|
95
|
+
sortable: true,
|
|
96
|
+
filterable: true,
|
|
97
|
+
filterComponent: 'filter/string',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'Internal ID',
|
|
101
|
+
valuePath: 'internal_id',
|
|
102
|
+
width: '125px',
|
|
103
|
+
resizable: true,
|
|
104
|
+
sortable: true,
|
|
105
|
+
filterable: true,
|
|
106
|
+
filterComponent: 'filter/string',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: 'Customer',
|
|
110
|
+
valuePath: 'customer.name',
|
|
111
|
+
cellComponent: 'table/cell/base',
|
|
112
|
+
width: '125px',
|
|
113
|
+
resizable: true,
|
|
114
|
+
sortable: true,
|
|
115
|
+
hidden: true,
|
|
116
|
+
filterable: true,
|
|
117
|
+
filterComponent: 'filter/model',
|
|
118
|
+
filterComponentPlaceholder: 'Select order customer',
|
|
119
|
+
filterParam: 'customer',
|
|
120
|
+
model: 'customer',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
label: 'Pickup',
|
|
124
|
+
valuePath: 'pickupName',
|
|
125
|
+
cellComponent: 'table/cell/base',
|
|
126
|
+
width: '160px',
|
|
127
|
+
resizable: true,
|
|
128
|
+
sortable: true,
|
|
129
|
+
filterable: true,
|
|
130
|
+
filterComponent: 'filter/model',
|
|
131
|
+
filterComponentPlaceholder: 'Select order pickup location',
|
|
132
|
+
filterParam: 'pickup',
|
|
133
|
+
model: 'place',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'Dropoff',
|
|
137
|
+
valuePath: 'dropoffName',
|
|
138
|
+
cellComponent: 'table/cell/base',
|
|
139
|
+
width: '160px',
|
|
140
|
+
resizable: true,
|
|
141
|
+
sortable: true,
|
|
142
|
+
filterable: true,
|
|
143
|
+
filterComponent: 'filter/model',
|
|
144
|
+
filterComponentPlaceholder: 'Select order dropoff location',
|
|
145
|
+
filterParam: 'dropoff',
|
|
146
|
+
model: 'place',
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
label: 'Scheduled At',
|
|
150
|
+
valuePath: 'scheduledAt',
|
|
151
|
+
sortParam: 'scheduled_at',
|
|
152
|
+
filterParam: 'scheduled_at',
|
|
153
|
+
width: '150px',
|
|
154
|
+
resizable: true,
|
|
155
|
+
sortable: true,
|
|
156
|
+
filterable: true,
|
|
157
|
+
filterComponent: 'filter/date',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
label: '# Items',
|
|
161
|
+
cellComponent: 'table/cell/base',
|
|
162
|
+
valuePath: 'item_count',
|
|
163
|
+
resizable: true,
|
|
164
|
+
hidden: true,
|
|
165
|
+
width: '50px',
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
label: 'Transaction Total',
|
|
169
|
+
cellComponent: 'table/cell/base',
|
|
170
|
+
valuePath: 'transaction_amount',
|
|
171
|
+
width: '50px',
|
|
172
|
+
resizable: true,
|
|
173
|
+
hidden: true,
|
|
174
|
+
sortable: true,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
label: 'Tracking Number',
|
|
178
|
+
cellComponent: 'table/cell/base',
|
|
179
|
+
valuePath: 'tracking_number.tracking_number',
|
|
180
|
+
width: '170px',
|
|
181
|
+
resizable: true,
|
|
182
|
+
sortable: true,
|
|
183
|
+
filterable: true,
|
|
184
|
+
filterComponent: 'filter/string',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
label: 'Driver Assigned',
|
|
188
|
+
cellComponent: 'table/cell/driver-name',
|
|
189
|
+
valuePath: 'driver_assigned',
|
|
190
|
+
modelPath: 'driver_assigned',
|
|
191
|
+
width: '170px',
|
|
192
|
+
resizable: true,
|
|
193
|
+
sortable: true,
|
|
194
|
+
filterable: true,
|
|
195
|
+
filterComponent: 'filter/model',
|
|
196
|
+
filterComponentPlaceholder: 'Select driver for order',
|
|
197
|
+
filterParam: 'driver',
|
|
198
|
+
model: 'driver',
|
|
199
|
+
query: {
|
|
200
|
+
// no model, serializer, adapter for relations
|
|
201
|
+
without: ['fleets', 'vendor', 'vehicle', 'currentJob'],
|
|
202
|
+
},
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
label: 'Type',
|
|
206
|
+
cellComponent: 'cell/humanize',
|
|
207
|
+
valuePath: 'type',
|
|
208
|
+
width: '100px',
|
|
209
|
+
resizable: true,
|
|
210
|
+
hidden: true,
|
|
211
|
+
sortable: true,
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: 'Status',
|
|
215
|
+
valuePath: 'status',
|
|
216
|
+
cellComponent: 'table/cell/status',
|
|
217
|
+
width: '120px',
|
|
218
|
+
resizable: true,
|
|
219
|
+
sortable: true,
|
|
220
|
+
filterable: true,
|
|
221
|
+
filterComponent: 'filter/multi-option',
|
|
222
|
+
// filterOptions: this.statusOptions,
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
label: 'Created At',
|
|
226
|
+
valuePath: 'createdAt',
|
|
227
|
+
sortParam: 'created_at',
|
|
228
|
+
filterParam: 'created_at',
|
|
229
|
+
width: '140px',
|
|
230
|
+
resizable: true,
|
|
231
|
+
sortable: true,
|
|
232
|
+
filterable: true,
|
|
233
|
+
filterComponent: 'filter/date',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
label: 'Updated At',
|
|
237
|
+
valuePath: 'updatedAt',
|
|
238
|
+
sortParam: 'updated_at',
|
|
239
|
+
filterParam: 'updated_at',
|
|
240
|
+
width: '125px',
|
|
241
|
+
resizable: true,
|
|
242
|
+
sortable: true,
|
|
243
|
+
hidden: true,
|
|
244
|
+
filterable: true,
|
|
245
|
+
filterComponent: 'filter/date',
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
label: 'Created By',
|
|
249
|
+
valuePath: 'created_by_name',
|
|
250
|
+
width: '125px',
|
|
251
|
+
resizable: true,
|
|
252
|
+
hidden: true,
|
|
253
|
+
filterable: true,
|
|
254
|
+
filterComponent: 'filter/model',
|
|
255
|
+
filterComponentPlaceholder: 'Select user',
|
|
256
|
+
filterParam: 'created_by',
|
|
257
|
+
model: 'user',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
label: 'Updated By',
|
|
261
|
+
valuePath: 'updated_by_name',
|
|
262
|
+
width: '125px',
|
|
263
|
+
resizable: true,
|
|
264
|
+
hidden: true,
|
|
265
|
+
filterable: true,
|
|
266
|
+
filterComponent: 'filter/model',
|
|
267
|
+
filterComponentPlaceholder: 'Select user',
|
|
268
|
+
filterParam: 'updated_by',
|
|
269
|
+
model: 'user',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
label: '',
|
|
273
|
+
cellComponent: 'table/cell/dropdown',
|
|
274
|
+
ddButtonText: false,
|
|
275
|
+
ddButtonIcon: 'ellipsis-h',
|
|
276
|
+
ddButtonIconPrefix: 'fas',
|
|
277
|
+
ddMenuLabel: 'Order Actions',
|
|
278
|
+
cellClassNames: 'overflow-visible',
|
|
279
|
+
wrapperClass: 'flex items-center justify-end mx-2',
|
|
280
|
+
width: '12%',
|
|
281
|
+
actions: [
|
|
282
|
+
{
|
|
283
|
+
label: 'View Order',
|
|
284
|
+
icon: 'eye',
|
|
285
|
+
fn: this.viewOrder,
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
label: 'Cancel Order',
|
|
289
|
+
icon: 'ban',
|
|
290
|
+
fn: this.cancelOrder,
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
separator: true,
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
label: 'Delete Order',
|
|
297
|
+
icon: 'trash',
|
|
298
|
+
fn: this.deleteOrder,
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
sortable: false,
|
|
302
|
+
filterable: false,
|
|
303
|
+
resizable: false,
|
|
304
|
+
searchable: false,
|
|
305
|
+
},
|
|
306
|
+
];
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* The search task.
|
|
310
|
+
*
|
|
311
|
+
* @void
|
|
312
|
+
*/
|
|
313
|
+
@task({ restartable: true }) *search({ target: { value } }) {
|
|
314
|
+
// if no query don't search
|
|
315
|
+
if (isBlank(value)) {
|
|
316
|
+
this.query = null;
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// timeout for typing
|
|
321
|
+
yield timeout(250);
|
|
322
|
+
|
|
323
|
+
// reset page for results
|
|
324
|
+
if (this.page > 1) {
|
|
325
|
+
this.page = 1;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// update the query param
|
|
329
|
+
this.query = value;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import ProductsIndexCategoryNewController from './new';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { alias } from '@ember/object/computed';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { isArray } from '@ember/array';
|
|
6
|
+
|
|
7
|
+
export default class ProductsIndexCategoryEditController extends ProductsIndexCategoryNewController {
|
|
8
|
+
@alias('model') product;
|
|
9
|
+
@tracked overlayActionButtonTitle = 'Save Changes';
|
|
10
|
+
@tracked overlayActionButtonIcon = 'save';
|
|
11
|
+
@tracked overlayExitButtonTitle = 'Done';
|
|
12
|
+
|
|
13
|
+
get overlayTitle() {
|
|
14
|
+
return `Edit ${this.product.name}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@action saveProduct() {
|
|
18
|
+
this.isSaving = true;
|
|
19
|
+
|
|
20
|
+
this.product
|
|
21
|
+
.serializeMeta()
|
|
22
|
+
.save()
|
|
23
|
+
.then(() => {
|
|
24
|
+
this.isSaving = false;
|
|
25
|
+
this.notifications.success('Changes saved!');
|
|
26
|
+
})
|
|
27
|
+
.catch((error) => {
|
|
28
|
+
this.isSaving = false;
|
|
29
|
+
this.notifications.serverError(error);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@action transitionBack({ closeOverlay }) {
|
|
34
|
+
if (this.isSaving) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (this.product.hasDirtyAttributes) {
|
|
39
|
+
// details have been added warn user it will lost
|
|
40
|
+
return this.modalsManager.confirm({
|
|
41
|
+
title: 'Product is not saved!',
|
|
42
|
+
body: 'You will loose all unsaved changes, are you sure you wish to cancel?',
|
|
43
|
+
confirm: (modal) => {
|
|
44
|
+
modal.done();
|
|
45
|
+
return this.exit(closeOverlay);
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return this.exit(closeOverlay);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@action exit(closeOverlay) {
|
|
54
|
+
return closeOverlay(() => {
|
|
55
|
+
window.history.back();
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@action removeFile(file) {
|
|
60
|
+
this.product.files.removeObject(file);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import Controller, { inject as controller } from '@ember/controller';
|
|
2
|
+
import { tracked } from '@glimmer/tracking';
|
|
3
|
+
import { isArray } from '@ember/array';
|
|
4
|
+
import { action } from '@ember/object';
|
|
5
|
+
import { alias } from '@ember/object/computed';
|
|
6
|
+
import { isEmpty } from '@ember/utils';
|
|
7
|
+
import { underscore } from '@ember/string';
|
|
8
|
+
import { inject as service } from '@ember/service';
|
|
9
|
+
|
|
10
|
+
export default class ProductsIndexCategoryNewController extends Controller {
|
|
11
|
+
@controller('products.index.category') productsIndexCategoryController;
|
|
12
|
+
@service notifications;
|
|
13
|
+
@service modalsManager;
|
|
14
|
+
@service currentUser;
|
|
15
|
+
@service store;
|
|
16
|
+
@service storefront;
|
|
17
|
+
@service fetch;
|
|
18
|
+
@service loader;
|
|
19
|
+
@service crud;
|
|
20
|
+
@alias('storefront.activeStore') activeStore;
|
|
21
|
+
@tracked product = this.store.createRecord('product', { store_uuid: this.activeStore.id, currency: this.activeStore.currency, tags: [], meta_array: [] });
|
|
22
|
+
@tracked uploadQueue = [];
|
|
23
|
+
@tracked uploadedFiles = [];
|
|
24
|
+
@tracked primaryFile = null;
|
|
25
|
+
@tracked isSaving = false;
|
|
26
|
+
|
|
27
|
+
/** overlay options */
|
|
28
|
+
@tracked overlayTitle = 'New Product';
|
|
29
|
+
@tracked overlayActionButtonTitle = 'Create Product';
|
|
30
|
+
@tracked overlayActionButtonIcon = 'check'; // box-check
|
|
31
|
+
@tracked overlayExitButtonTitle = 'Cancel';
|
|
32
|
+
@tracked metadataButtons = [
|
|
33
|
+
{
|
|
34
|
+
type: 'default',
|
|
35
|
+
text: 'Add Metafield',
|
|
36
|
+
icon: 'plus',
|
|
37
|
+
iconPrefix: 'fas',
|
|
38
|
+
onClick: this.addMetaField,
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
@tracked acceptedFileTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'video/mp4', 'video/quicktime', 'video/x-msvideo', 'video/x-flv', 'video/x-ms-wmv'];
|
|
42
|
+
|
|
43
|
+
@action reset() {
|
|
44
|
+
this.product = this.store.createRecord('product', { store_uuid: this.activeStore.id, currency: this.activeStore.currency });
|
|
45
|
+
this.uploadQueue = [];
|
|
46
|
+
this.uploadedFiles = [];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@action saveProduct() {
|
|
50
|
+
const { category } = this.productsIndexCategoryController;
|
|
51
|
+
const loader = this.loader.showLoader('body', 'Creating new product...');
|
|
52
|
+
this.isSaving = true;
|
|
53
|
+
|
|
54
|
+
if (category) {
|
|
55
|
+
this.product.set('category_uuid', category.id);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
this.product
|
|
59
|
+
.serializeMeta()
|
|
60
|
+
.save()
|
|
61
|
+
.then((product) => {
|
|
62
|
+
this.loader.removeLoader(loader);
|
|
63
|
+
this.isSaving = false;
|
|
64
|
+
this.notifications.success('New product created successfully!');
|
|
65
|
+
|
|
66
|
+
return this.transitionToRoute('products.index.category').then(() => {
|
|
67
|
+
console.log(this.productsIndexCategoryController);
|
|
68
|
+
console.log(this.productsIndexCategoryController.products);
|
|
69
|
+
this.productsIndexCategoryController?.products?.pushObject(product);
|
|
70
|
+
});
|
|
71
|
+
})
|
|
72
|
+
.catch((error) => {
|
|
73
|
+
this.loader.removeLoader(loader);
|
|
74
|
+
this.isSaving = false;
|
|
75
|
+
this.notifications.serverError(error);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@action addTag(tag) {
|
|
80
|
+
if (!isArray(this.product.tags)) {
|
|
81
|
+
this.product.tags = [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
this.product.tags?.pushObject(tag);
|
|
85
|
+
console.log('this.product.tags', this.product.tags);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
@action removeTag(index) {
|
|
89
|
+
this.product.tags?.removeAt(index);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@action queueFile(file) {
|
|
93
|
+
this.uploadQueue.pushObject(file);
|
|
94
|
+
this.fetch.uploadFile.perform(
|
|
95
|
+
file,
|
|
96
|
+
{
|
|
97
|
+
path: `uploads/storefront/${this.activeStore.id}/products`,
|
|
98
|
+
subject_uuid: this.product.id,
|
|
99
|
+
subject_type: `storefront:product`,
|
|
100
|
+
type: `storefront_product`,
|
|
101
|
+
},
|
|
102
|
+
(uploadedFile) => {
|
|
103
|
+
this.product.files.pushObject(uploadedFile);
|
|
104
|
+
|
|
105
|
+
// if no primary image make it
|
|
106
|
+
if (!this.product.primary_image_uuid) {
|
|
107
|
+
this.product.primary_image_uuid = uploadedFile.id;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
this.uploadQueue.removeObject(file);
|
|
111
|
+
},
|
|
112
|
+
() => {
|
|
113
|
+
this.uploadQueue.removeObject(file);
|
|
114
|
+
}
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@action removeFile(file) {
|
|
119
|
+
if (file.queue) {
|
|
120
|
+
file.queue.remove(file);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (file.model) {
|
|
124
|
+
this.uploadedFiles.removeObject(file.model);
|
|
125
|
+
file.model.destroyRecord();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.uploadQueue.removeObject(file);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@action makePrimaryFile(file) {
|
|
132
|
+
if (file.isNotImage) {
|
|
133
|
+
return this.notifications.warning('You can only select an image file to be primary!');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
this.notifications.success(`${file.original_filename} was made the primary image.`);
|
|
137
|
+
this.product.primary_image_uuid = file.id;
|
|
138
|
+
this.product.primary_image_url = file.url;
|
|
139
|
+
this.product.primary_image = file;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@action transitionBack({ closeOverlay }) {
|
|
143
|
+
if (this.product.hasDirtyAttributes) {
|
|
144
|
+
// details have been added warn user it will lost
|
|
145
|
+
return this.modalsManager.confirm({
|
|
146
|
+
title: 'Product is not saved!',
|
|
147
|
+
body: 'Going back will cancel this product creation, if you continue all input fields will be cleared!',
|
|
148
|
+
confirm: (modal) => {
|
|
149
|
+
modal.done();
|
|
150
|
+
return this.exit(closeOverlay);
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return this.exit(closeOverlay);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@action exit(closeOverlay) {
|
|
159
|
+
return closeOverlay(() => {
|
|
160
|
+
return this.transitionToRoute('products.index.category').then(() => {
|
|
161
|
+
this.reset();
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
@action async selectAddonCategory() {
|
|
167
|
+
this.modalsManager.displayLoader();
|
|
168
|
+
|
|
169
|
+
const { product } = this;
|
|
170
|
+
const addonCategories = await this.store.findAll('addon-category');
|
|
171
|
+
|
|
172
|
+
return this.modalsManager.done().then(() => {
|
|
173
|
+
this.modalsManager.show('modals/select-addon-category', {
|
|
174
|
+
title: 'Select addon categories',
|
|
175
|
+
addonCategories,
|
|
176
|
+
product,
|
|
177
|
+
updateProductAddonCategories: (categories) => {
|
|
178
|
+
const productAddonCategories = categories.map((category) => {
|
|
179
|
+
return this.store.createRecord('product-addon-category', {
|
|
180
|
+
product_uuid: product.id,
|
|
181
|
+
category_uuid: category.id,
|
|
182
|
+
name: category.name,
|
|
183
|
+
excluded_addons: [],
|
|
184
|
+
category,
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
product.addon_categories = productAddonCategories;
|
|
189
|
+
},
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@action createProductVariant() {
|
|
195
|
+
const { product } = this;
|
|
196
|
+
const productVariant = this.store.createRecord('product-variant');
|
|
197
|
+
|
|
198
|
+
return this.modalsManager.show('modals/create-new-variant', {
|
|
199
|
+
title: 'Add new product variant',
|
|
200
|
+
productVariant,
|
|
201
|
+
confirm: (modal) => {
|
|
202
|
+
modal.startLoading();
|
|
203
|
+
// add variant to product
|
|
204
|
+
product.variants.pushObject(productVariant);
|
|
205
|
+
modal.done();
|
|
206
|
+
},
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@action editProductVariant(productVariant) {
|
|
211
|
+
return this.modalsManager.show('modals/create-new-variant', {
|
|
212
|
+
title: 'Edit product variant',
|
|
213
|
+
productVariant,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
@action removeProductVariant(productVariant) {
|
|
218
|
+
return this.crud.delete(productVariant, {
|
|
219
|
+
onConfirm: () => {
|
|
220
|
+
this.product.variants.removeObject(productVariant);
|
|
221
|
+
},
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
@action addVariantOption(productVariant) {
|
|
226
|
+
const variantOption = this.store.createRecord('product-variant-option');
|
|
227
|
+
productVariant.options.pushObject(variantOption);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
@action removeVariantOption(productVariant, index) {
|
|
231
|
+
const option = productVariant.options.objectAt(index);
|
|
232
|
+
productVariant.options.removeObject(option);
|
|
233
|
+
|
|
234
|
+
if (option.id) {
|
|
235
|
+
option.destroyRecord();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
@action removeAddonCategory(index) {
|
|
240
|
+
const productAddonCategory = this.product.addon_categories.objectAt(index);
|
|
241
|
+
|
|
242
|
+
this.product.addon_categories.removeObject(productAddonCategory);
|
|
243
|
+
|
|
244
|
+
if (productAddonCategory.id) {
|
|
245
|
+
productAddonCategory.destroyRecord();
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
@action excludeAddon(index, addon) {
|
|
250
|
+
const productAddonCategory = this.product.addon_categories.objectAt(index);
|
|
251
|
+
const id = addon.id;
|
|
252
|
+
|
|
253
|
+
if (!productAddonCategory.excluded_addons) {
|
|
254
|
+
productAddonCategory.excluded_addons = [];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (productAddonCategory.excluded_addons.includes(id)) {
|
|
258
|
+
productAddonCategory.excluded_addons.removeObject(id);
|
|
259
|
+
} else {
|
|
260
|
+
productAddonCategory.excluded_addons.pushObject(id);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
console.log(productAddonCategory);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@action addMetaField() {
|
|
267
|
+
let { meta_array } = this.product;
|
|
268
|
+
|
|
269
|
+
if (!isArray(meta_array)) {
|
|
270
|
+
meta_array = [];
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const label = `Untitled Field`;
|
|
274
|
+
|
|
275
|
+
meta_array.pushObject({
|
|
276
|
+
key: underscore(label),
|
|
277
|
+
label,
|
|
278
|
+
value: null,
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
this.product.meta_array = meta_array;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
@action removeMetaField(index) {
|
|
285
|
+
this.product.meta_array.removeAt(index);
|
|
286
|
+
}
|
|
287
|
+
}
|