@fleetbase/fleetops-engine 0.4.15 → 0.4.17

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.
Files changed (220) hide show
  1. package/.php-cs-fixer.php +2 -0
  2. package/addon/components/activity-event-selector.hbs +35 -0
  3. package/addon/components/activity-event-selector.js +85 -0
  4. package/addon/components/activity-form-panel.hbs +23 -0
  5. package/addon/components/activity-form-panel.js +90 -0
  6. package/addon/components/activity-logic-builder.hbs +80 -0
  7. package/addon/components/activity-logic-builder.js +260 -0
  8. package/addon/components/contact-form-panel.hbs +1 -1
  9. package/addon/components/contact-panel.hbs +1 -1
  10. package/addon/components/custom-entity-form-panel.hbs +43 -0
  11. package/addon/components/custom-entity-form-panel.js +129 -0
  12. package/addon/components/custom-field-form-panel/options-input.hbs +12 -0
  13. package/addon/components/custom-field-form-panel/options-input.js +139 -0
  14. package/addon/components/custom-field-form-panel.hbs +77 -0
  15. package/addon/components/custom-field-form-panel.js +144 -0
  16. package/addon/components/custom-field.hbs +63 -41
  17. package/addon/components/custom-field.js +123 -25
  18. package/addon/components/driver-form-panel.hbs +1 -1
  19. package/addon/components/driver-panel.hbs +1 -1
  20. package/addon/components/edit-order-route-panel.hbs +1 -1
  21. package/addon/components/fleet-form-panel.hbs +1 -1
  22. package/addon/components/fleet-panel.hbs +1 -1
  23. package/addon/components/fuel-report-form-panel.hbs +1 -1
  24. package/addon/components/fuel-report-panel.hbs +1 -1
  25. package/addon/components/issue-form-panel.hbs +1 -1
  26. package/addon/components/issue-panel.hbs +1 -1
  27. package/addon/components/joint-graph.hbs +1 -0
  28. package/addon/components/joint-graph.js +103 -0
  29. package/addon/components/layout/fleet-ops-sidebar.hbs +3 -3
  30. package/addon/components/layout/fleet-ops-sidebar.js +1 -0
  31. package/addon/components/live-map.js +71 -28
  32. package/addon/components/modals/new-custom-field-group.hbs +5 -0
  33. package/addon/components/modals/new-order-config.hbs +3 -3
  34. package/addon/components/modals/order-new-activity.hbs +1 -1
  35. package/addon/components/order-config-manager/activity-flow.hbs +11 -0
  36. package/addon/components/order-config-manager/activity-flow.js +964 -0
  37. package/addon/components/order-config-manager/custom-fields.hbs +50 -0
  38. package/addon/components/order-config-manager/custom-fields.js +276 -0
  39. package/addon/components/order-config-manager/details.hbs +23 -0
  40. package/addon/components/order-config-manager/details.js +97 -0
  41. package/addon/components/order-config-manager/entities.hbs +54 -0
  42. package/addon/components/order-config-manager/entities.js +227 -0
  43. package/addon/components/order-config-manager-overlay.hbs +26 -0
  44. package/addon/components/order-config-manager-overlay.js +60 -0
  45. package/addon/components/order-config-manager.hbs +15 -0
  46. package/addon/components/order-config-manager.js +285 -0
  47. package/addon/components/order-flow.hbs +1 -0
  48. package/addon/components/order-flow.js +3 -0
  49. package/addon/components/place-form-panel.hbs +1 -1
  50. package/addon/components/place-panel.hbs +1 -1
  51. package/addon/components/vehicle-form-panel.hbs +1 -1
  52. package/addon/components/vehicle-panel.hbs +1 -1
  53. package/addon/components/vendor-form-panel.hbs +1 -1
  54. package/addon/components/vendor-panel.hbs +1 -1
  55. package/addon/controllers/application.js +5 -1
  56. package/addon/controllers/operations/order-config.js +42 -0
  57. package/addon/controllers/operations/orders/index/new.js +125 -21
  58. package/addon/controllers/operations/orders/index/view.js +87 -4
  59. package/addon/controllers/operations/orders/index.js +2 -2
  60. package/addon/engine.js +10 -1
  61. package/addon/initializers/load-jointjs.js +16 -0
  62. package/addon/routes/application.js +1 -1
  63. package/addon/routes/operations/order-config.js +28 -0
  64. package/addon/routes/operations/orders/index/new.js +2 -3
  65. package/addon/routes/operations/orders/index/view.js +1 -1
  66. package/addon/routes.js +1 -0
  67. package/addon/services/context-panel.js +65 -3
  68. package/addon/styles/fleetops-engine.css +268 -0
  69. package/addon/templates/application.hbs +1 -1
  70. package/addon/templates/operations/order-config.hbs +55 -0
  71. package/addon/templates/operations/orders/index/new.hbs +98 -339
  72. package/addon/templates/operations/orders/index/view.hbs +36 -96
  73. package/addon/templates/operations/orders/index.hbs +0 -1
  74. package/addon/utils/apply-context-component-arguments.js +4 -2
  75. package/addon/utils/create-custom-entity.js +22 -0
  76. package/addon/utils/create-flow-activity.js +31 -0
  77. package/addon/utils/get-custom-field-type-map.js +34 -0
  78. package/app/components/activity-event-selector.js +1 -0
  79. package/app/components/activity-form-panel.js +1 -0
  80. package/app/components/activity-logic-builder.js +1 -0
  81. package/app/components/custom-entity-form-panel.js +1 -0
  82. package/app/components/custom-field-form-panel/options-input.js +1 -0
  83. package/app/components/custom-field-form-panel.js +1 -0
  84. package/app/components/joint-graph.js +1 -0
  85. package/app/components/modals/new-custom-field-group.js +1 -0
  86. package/app/components/order-config-manager/activity-flow.js +1 -0
  87. package/app/components/order-config-manager/custom-fields.js +1 -0
  88. package/app/components/order-config-manager/details.js +1 -0
  89. package/app/components/order-config-manager/entities.js +1 -0
  90. package/app/components/order-config-manager-overlay.js +1 -0
  91. package/app/components/order-config-manager.js +1 -0
  92. package/app/components/order-flow.js +1 -0
  93. package/app/controllers/operations/order-config.js +1 -0
  94. package/app/routes/operations/order-config.js +1 -0
  95. package/app/templates/operations/order-config.js +1 -0
  96. package/app/utils/create-custom-entity.js +1 -0
  97. package/app/utils/create-flow-activity.js +1 -0
  98. package/app/utils/get-custom-field-type-map.js +1 -0
  99. package/composer.json +4 -3
  100. package/config/environment.js +1 -0
  101. package/extension.json +1 -1
  102. package/index.js +20 -0
  103. package/package.json +7 -5
  104. package/server/migrations/2023_04_27_053456_create_contacts_table.php +1 -2
  105. package/server/migrations/2023_04_27_053456_create_drivers_table.php +1 -2
  106. package/server/migrations/2023_04_27_053456_create_entities_table.php +1 -2
  107. package/server/migrations/2023_04_27_053456_create_fleet_drivers_table.php +1 -2
  108. package/server/migrations/2023_04_27_053456_create_fleets_table.php +1 -2
  109. package/server/migrations/2023_04_27_053456_create_fuel_reports_table.php +1 -2
  110. package/server/migrations/2023_04_27_053456_create_integrated_vendors_table.php +1 -2
  111. package/server/migrations/2023_04_27_053456_create_issues_table.php +1 -2
  112. package/server/migrations/2023_04_27_053456_create_orders_table.php +1 -2
  113. package/server/migrations/2023_04_27_053456_create_payloads_table.php +1 -2
  114. package/server/migrations/2023_04_27_053456_create_places_table.php +1 -2
  115. package/server/migrations/2023_04_27_053456_create_positions_table.php +1 -2
  116. package/server/migrations/2023_04_27_053456_create_proofs_table.php +1 -2
  117. package/server/migrations/2023_04_27_053456_create_purchase_rates_table.php +1 -2
  118. package/server/migrations/2023_04_27_053456_create_routes_table.php +1 -2
  119. package/server/migrations/2023_04_27_053456_create_service_areas_table.php +1 -2
  120. package/server/migrations/2023_04_27_053456_create_service_quote_items_table.php +1 -2
  121. package/server/migrations/2023_04_27_053456_create_service_quotes_table.php +1 -2
  122. package/server/migrations/2023_04_27_053456_create_service_rate_fees_table.php +1 -2
  123. package/server/migrations/2023_04_27_053456_create_service_rate_parcel_fees_table.php +1 -2
  124. package/server/migrations/2023_04_27_053456_create_service_rates_table.php +1 -2
  125. package/server/migrations/2023_04_27_053456_create_tracking_numbers_table.php +1 -2
  126. package/server/migrations/2023_04_27_053456_create_tracking_statuses_table.php +1 -2
  127. package/server/migrations/2023_04_27_053456_create_vehicles_table.php +1 -2
  128. package/server/migrations/2023_04_27_053456_create_vendors_table.php +1 -2
  129. package/server/migrations/2023_04_27_053456_create_waypoints_table.php +1 -2
  130. package/server/migrations/2023_04_27_053456_create_zones_table.php +1 -2
  131. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_companies_table.php +1 -2
  132. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_contacts_table.php +1 -2
  133. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_drivers_table.php +1 -2
  134. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_entities_table.php +1 -2
  135. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleet_drivers_table.php +1 -2
  136. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fleets_table.php +1 -2
  137. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_fuel_reports_table.php +1 -2
  138. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_integrated_vendors_table.php +1 -2
  139. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_issues_table.php +1 -2
  140. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_orders_table.php +1 -2
  141. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_payloads_table.php +1 -2
  142. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_places_table.php +1 -2
  143. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_positions_table.php +1 -2
  144. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_proofs_table.php +1 -2
  145. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_purchase_rates_table.php +1 -2
  146. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_routes_table.php +1 -2
  147. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_areas_table.php +1 -2
  148. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quote_items_table.php +1 -2
  149. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_quotes_table.php +1 -2
  150. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_fees_table.php +1 -2
  151. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rate_parcel_fees_table.php +1 -2
  152. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_service_rates_table.php +1 -2
  153. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_numbers_table.php +1 -2
  154. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_tracking_statuses_table.php +1 -2
  155. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vehicles_table.php +1 -2
  156. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_vendors_table.php +1 -2
  157. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_waypoints_table.php +1 -2
  158. package/server/migrations/2023_04_27_053459_add_foreign_keys_to_zones_table.php +1 -2
  159. package/server/migrations/2023_09_14_074512_update_vehicles_table.php +1 -2
  160. package/server/migrations/2023_09_14_074619_create_vehicle_devices_table.php +35 -36
  161. package/server/migrations/2023_09_26_071205_add_online_column_to_vehicles_table.php +1 -2
  162. package/server/migrations/2023_09_26_083957_create_fleet_vehicles_table.php +1 -2
  163. package/server/migrations/2023_09_27_023757_add_column_to_fleets_table.php +1 -2
  164. package/server/migrations/2023_10_05_074811_update_vehicle.php +1 -2
  165. package/server/migrations/2023_10_25_093014_create_vehicle_device_events_table.php +1 -2
  166. package/server/migrations/2023_11_03_072503_refactor_issues_table_columns.php +1 -2
  167. package/server/migrations/2023_11_06_040645_refactor_fuel_reports_table.php +1 -2
  168. package/server/migrations/2023_11_09_041807_add_status_column_to_fuel_reports_table.php +1 -2
  169. package/server/migrations/2023_11_15_062814_add_comments_column_and_resolved_at_column_to_vehicle_device_events_table.php +1 -2
  170. package/server/migrations/2023_11_17_053001_add_category_uuid_to_entities_table.php +1 -2
  171. package/server/migrations/2023_11_28_074244_add_supplier_uuid_column_to_entities_table.php +1 -2
  172. package/server/migrations/2023_12_14_100209_add_meta_column_on_driver_table copy.php +1 -2
  173. package/server/migrations/2024_02_18_100209_add_avatar_url_columns_table.php +3 -4
  174. package/server/migrations/2024_02_27_093648_create_order_configs_table.php +43 -0
  175. package/server/migrations/2024_03_07_075508_add_order_config_uuid_column_to_orders_table.php +28 -0
  176. package/server/seeders/OrderConfigSeeder.php +151 -0
  177. package/server/src/Casts/OrderConfigEntities.php +53 -0
  178. package/server/src/Console/Commands/FixLegacyOrderConfigs.php +66 -0
  179. package/server/src/Events/DriverLocationChanged.php +1 -1
  180. package/server/src/Events/DriverSimulatedLocationChanged.php +1 -1
  181. package/server/src/Expansions/UserExpansion.php +4 -4
  182. package/server/src/Flow/Activity.php +232 -6
  183. package/server/src/Flow/Condition.php +84 -0
  184. package/server/src/Flow/Event.php +88 -0
  185. package/server/src/Flow/Flow.php +50 -0
  186. package/server/src/Flow/FlowResource.php +143 -0
  187. package/server/src/Flow/Logic.php +57 -1
  188. package/server/src/Http/Controllers/Api/v1/DriverController.php +2 -2
  189. package/server/src/Http/Controllers/Api/v1/IssueController.php +132 -0
  190. package/server/src/Http/Controllers/Api/v1/OrderController.php +130 -57
  191. package/server/src/Http/Controllers/Api/v1/OrganizationController.php +27 -0
  192. package/server/src/Http/Controllers/Api/v1/PlaceController.php +2 -3
  193. package/server/src/Http/Controllers/Controller.php +9 -0
  194. package/server/src/Http/Controllers/FleetOpsController.php +7 -0
  195. package/server/src/Http/Controllers/Internal/v1/OrderConfigController.php +5 -259
  196. package/server/src/Http/Controllers/Internal/v1/OrderController.php +56 -35
  197. package/server/src/Http/Controllers/Internal/v1/SettingController.php +20 -0
  198. package/server/src/Http/Filter/OrderConfigFilter.php +13 -0
  199. package/server/src/Http/Requests/CreateIssueRequest.php +19 -0
  200. package/server/src/Http/Requests/UpdateIssueRequest.php +7 -0
  201. package/server/src/Http/Resources/v1/Order.php +3 -0
  202. package/server/src/Http/Resources/v1/Payload.php +1 -1
  203. package/server/src/Listeners/HandleOrderCanceled.php +8 -4
  204. package/server/src/Listeners/HandleOrderDispatched.php +14 -12
  205. package/server/src/Models/Order.php +527 -31
  206. package/server/src/Models/OrderConfig.php +419 -0
  207. package/server/src/Models/Payload.php +8 -7
  208. package/server/src/Notifications/OrderAssigned.php +1 -1
  209. package/server/src/Notifications/OrderCanceled.php +1 -1
  210. package/server/src/Notifications/OrderDispatchFailed.php +1 -1
  211. package/server/src/Notifications/OrderDispatched.php +1 -1
  212. package/server/src/Notifications/OrderPing.php +1 -1
  213. package/server/src/Providers/FleetOpsServiceProvider.php +3 -1
  214. package/server/src/Providers/NotificationServiceProvider.php +2 -1
  215. package/server/src/Support/Utils.php +17 -0
  216. package/server/src/Traits/HasTrackingNumber.php +9 -9
  217. package/server/src/routes.php +19 -11
  218. package/translations/en-us.yaml +137 -0
  219. package/server/src/Flow/Config.php +0 -7
  220. package/server/src/Support/Flow.php +0 -653
@@ -0,0 +1,227 @@
1
+ import Component from '@glimmer/component';
2
+ import { tracked } from '@glimmer/tracking';
3
+ import { inject as service } from '@ember/service';
4
+ import { action } from '@ember/object';
5
+ import { isArray } from '@ember/array';
6
+ import { later } from '@ember/runloop';
7
+ import { task } from 'ember-concurrency-decorators';
8
+ import getWithDefault from '@fleetbase/ember-core/utils/get-with-default';
9
+ import ObjectProxy from '@ember/object/proxy';
10
+ import createCustomEntity from '../../utils/create-custom-entity';
11
+ import contextComponentCallback from '../../utils/context-component-callback';
12
+
13
+ /**
14
+ * Component class for managing order configuration entities.
15
+ * This component allows for creating, editing, deleting, and managing custom entities
16
+ * associated with an order configuration.
17
+ *
18
+ * @extends Component
19
+ */
20
+ export default class OrderConfigManagerEntitiesComponent extends Component {
21
+ /**
22
+ * Context panel service for managing UI contexts.
23
+ * @service
24
+ */
25
+ @service contextPanel;
26
+
27
+ /**
28
+ * Modals manager service for handling modal dialogs.
29
+ * @service
30
+ */
31
+ @service modalsManager;
32
+
33
+ /**
34
+ * Internationalization service for handling translations.
35
+ * @service
36
+ */
37
+ @service intl;
38
+
39
+ /**
40
+ * Tracked property for the current configuration.
41
+ * @tracked
42
+ */
43
+ @tracked config;
44
+
45
+ /**
46
+ * Tracked array of custom entities associated with the configuration.
47
+ * @tracked
48
+ */
49
+ @tracked customEntities = [];
50
+
51
+ /**
52
+ * Constructor for OrderConfigManagerEntitiesComponent.
53
+ * Initializes the component with the provided configuration and loads the associated entities.
54
+ * @param {Object} owner - The owner of the component.
55
+ * @param {Object} args - The arguments passed to the component.
56
+ */
57
+ constructor(owner, { config, configManagerContext }) {
58
+ super(...arguments);
59
+ this.config = config;
60
+ this.customEntities = this.getEntitiesFromConfig(config);
61
+ this.initializeContext();
62
+
63
+ configManagerContext.on('onConfigChanged', (newConfig) => {
64
+ this.changeConfig(newConfig);
65
+ });
66
+ }
67
+
68
+ /**
69
+ * Action method to create a new custom entity and open it for editing.
70
+ * @action
71
+ */
72
+ @action createNewCustomEntity() {
73
+ const customEntity = createCustomEntity();
74
+ return this.editCustomEntity(customEntity);
75
+ }
76
+
77
+ /**
78
+ * Action method to edit a given custom entity.
79
+ * @param {Object} customEntity - The custom entity to edit.
80
+ * @param {number} index - The index of the entity in the entities array.
81
+ * @action
82
+ */
83
+ @action editCustomEntity(customEntity, index) {
84
+ contextComponentCallback(this, 'onContextChanged', customEntity);
85
+ this.contextPanel.focus(customEntity, 'editing', {
86
+ args: {
87
+ config: this.config,
88
+ onPressCancel: () => {
89
+ this.contextPanel.clear();
90
+ contextComponentCallback(this, 'onContextChanged', null);
91
+ },
92
+ onSave: (customEntity) => {
93
+ if (index > -1) {
94
+ this.customEntities = this.customEntities.map((_, i) => {
95
+ if (i === index) {
96
+ return customEntity;
97
+ }
98
+
99
+ return _;
100
+ });
101
+ } else {
102
+ this.customEntities = [customEntity, ...this.customEntities];
103
+ }
104
+ this.contextPanel.clear();
105
+ this.save.perform();
106
+ contextComponentCallback(this, 'onContextChanged', null);
107
+ },
108
+ },
109
+ });
110
+ }
111
+
112
+ /**
113
+ * Action method to delete a given custom entity.
114
+ * @param {Object} customEntity - The custom entity to delete.
115
+ * @param {number} index - The index of the entity in the entities array.
116
+ * @action
117
+ */
118
+ @action deleteCustomEntity(customEntity, index) {
119
+ this.modalsManager.confirm({
120
+ title: this.intl.t('fleet-ops.component.order-config-manager.entities.delete-custom-entity-title'),
121
+ body: this.intl.t('fleet-ops.component.order-config-manager.entities.delete-custom-entity-body'),
122
+ acceptButtonText: this.intl.t('fleet-ops.component.order-config-manager.entities.confirm-delete'),
123
+ confirm: (modal) => {
124
+ this.customEntities = this.customEntities.filter((_, i) => i !== index);
125
+ this.save.perform();
126
+ modal.done();
127
+ },
128
+ });
129
+ }
130
+
131
+ /**
132
+ * A task method to save the current state of entities to the configuration.
133
+ * It serializes the entities and updates the configuration.
134
+ * @task
135
+ */
136
+ @task *save() {
137
+ this.config.set('entities', this.serializeEntities());
138
+ yield this.config.save().then((config) => {
139
+ this.config = config;
140
+ this.customEntities = this.getEntitiesFromConfig(config);
141
+ });
142
+ }
143
+
144
+ /**
145
+ * If any context is provided then initialize the state.
146
+ *
147
+ * @memberof OrderConfigManagerCustomFieldsComponent
148
+ */
149
+ initializeContext() {
150
+ later(
151
+ this,
152
+ () => {
153
+ const { context, contextModel } = this.args;
154
+ if (typeof context === 'string' && contextModel === 'custom-entity') {
155
+ const contextCustomEntity = this.customEntities.find((entity) => entity.get('id') === context);
156
+ if (contextCustomEntity) {
157
+ this.editCustomEntity(contextCustomEntity);
158
+ }
159
+ }
160
+ },
161
+ 300
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Handle change of config.
167
+ *
168
+ * @param {OrderConfigModel} newConfig
169
+ * @memberof OrderConfigManagerEntitiesComponent
170
+ */
171
+ changeConfig(newConfig) {
172
+ this.config = newConfig;
173
+ this.customEntities = this.getEntitiesFromConfig(newConfig);
174
+ }
175
+
176
+ /**
177
+ * Deserializes an array of custom entities, preparing them for use in the component.
178
+ * @param {Array} customEntities - The array of serialized custom entities.
179
+ * @returns {Array} The array of deserialized custom entities.
180
+ */
181
+ deserializeEntities(customEntities) {
182
+ return customEntities.map(this.fixInternalModel).map((customEntity) => {
183
+ if (customEntity instanceof ObjectProxy) {
184
+ return customEntity;
185
+ }
186
+
187
+ return createCustomEntity(customEntity.name, customEntity.type, customEntity.description, { ...customEntity });
188
+ });
189
+ }
190
+
191
+ /**
192
+ * Fixes the internal model of a custom entity for consistency.
193
+ * @param {Object} customEntity - The custom entity to fix.
194
+ * @returns {Object} The custom entity with a fixed internal model.
195
+ */
196
+ fixInternalModel(customEntity) {
197
+ const _internalModel = {
198
+ modelName: 'custom-entity',
199
+ };
200
+ if (customEntity instanceof ObjectProxy) {
201
+ customEntity.set('_internalModel', _internalModel);
202
+ return customEntity;
203
+ }
204
+
205
+ customEntity._internalModel = _internalModel;
206
+ return customEntity;
207
+ }
208
+
209
+ /**
210
+ * Serializes the current custom entities for saving to the configuration.
211
+ * @returns {Array} The serialized custom entities.
212
+ */
213
+ serializeEntities() {
214
+ const customEntities = [...this.customEntities];
215
+ return customEntities.map((customEntity) => customEntity.content);
216
+ }
217
+
218
+ /**
219
+ * Retrieves and deserializes entities from the given configuration.
220
+ * @param {Object} config - The configuration object containing the entities.
221
+ * @returns {Array} The deserialized entities.
222
+ */
223
+ getEntitiesFromConfig(config) {
224
+ const entities = getWithDefault(config, 'entities', []);
225
+ return this.deserializeEntities(isArray(entities) ? entities : []);
226
+ }
227
+ }
@@ -0,0 +1,26 @@
1
+ <OrderConfigManager as |Action Context|>
2
+ <Overlay @onLoad={{this.setOverlayContext}} @onOpen={{this.onOpen}} @onClose={{this.onClose}} @onToggle={{this.onToggle}} @position="right" @noBackdrop={{true}} @fullHeight={{true}} @isResizeble={{true}} @width="645px">
3
+ <Overlay::Header @title={{t "fleet-ops.component.order-config-manager.title"}} @onPressCancel={{this.onPressCancel}}>
4
+ <Action.NewOrderConfigButton />
5
+ </Overlay::Header>
6
+
7
+ <Overlay::Body class="p-0i" @wrapperClass="py-5">
8
+ <div class="section-header-actions w-full overflow-x-scroll lg:overflow-x-auto">
9
+ <div class="ui-tabs mt-4">
10
+ <nav>
11
+ {{#each Context.tabs as |tab|}}
12
+ <a href="javascript:;" class="ui-tab {{if (eq tab.slug Context.currentTab.slug) 'active'}}" {{on "click" (fn Context.onTabChanged tab.slug)}}>
13
+ <FaIcon @icon={{tab.icon}} class="mr-1" />
14
+ <span>{{tab.title}}</span>
15
+ </a>
16
+ {{/each}}
17
+ </nav>
18
+ </div>
19
+ </div>
20
+ <div class="tab-content tab-{{Context.currentTab.slug}}">
21
+ <Context.Content />
22
+ </div>
23
+ <Spacer @height="300px" />
24
+ </Overlay::Body>
25
+ </Overlay>
26
+ </OrderConfigManager>
@@ -0,0 +1,60 @@
1
+ import Component from '@glimmer/component';
2
+ import { action } from '@ember/object';
3
+ import contextComponentCallback from '../utils/context-component-callback';
4
+
5
+ export default class OrderConfigManagerOverlayComponent extends Component {
6
+ /**
7
+ * Sets the overlay context.
8
+ *
9
+ * @action
10
+ * @param {OverlayContextObject} overlayContext
11
+ */
12
+ @action setOverlayContext(overlayContext) {
13
+ this.context = overlayContext;
14
+ contextComponentCallback(this, 'onLoad', ...arguments);
15
+ }
16
+
17
+ /**
18
+ * Handles the cancel action.
19
+ *
20
+ * @method
21
+ * @action
22
+ * @returns {Boolean} Indicates whether the cancel action was overridden.
23
+ */
24
+ @action onPressCancel() {
25
+ return contextComponentCallback(this, 'onPressCancel');
26
+ }
27
+
28
+ /**
29
+ * Handles the open action.
30
+ *
31
+ * @method
32
+ * @action
33
+ * @returns {Boolean} Indicates whether the cancel action was overridden.
34
+ */
35
+ @action onOpen() {
36
+ return contextComponentCallback(this, 'onOpen');
37
+ }
38
+
39
+ /**
40
+ * Handles the close action.
41
+ *
42
+ * @method
43
+ * @action
44
+ * @returns {Boolean} Indicates whether the cancel action was overridden.
45
+ */
46
+ @action onClose() {
47
+ return contextComponentCallback(this, 'onClose');
48
+ }
49
+
50
+ /**
51
+ * Handles the toggle action.
52
+ *
53
+ * @method
54
+ * @action
55
+ * @returns {Boolean} Indicates whether the cancel action was overridden.
56
+ */
57
+ @action onToggle() {
58
+ return contextComponentCallback(this, 'onToggle');
59
+ }
60
+ }
@@ -0,0 +1,15 @@
1
+ {{yield
2
+ (hash
3
+ NewOrderConfigButton=(component "button" type="primary" icon="plus" text=(t "fleet-ops.component.order-config-manager.new-order-config") onClick=this.createNewOrderConfig)
4
+ )
5
+ (hash
6
+ configs=this.configs
7
+ currentConfig=this.currentConfig
8
+ selectConfig=this.selectConfig
9
+ tabs=this.tabs
10
+ currentTab=this.tab
11
+ content=(component this.tab.component configManagerContext=this.configManagerContext config=this.currentConfig context=this.context contextModel=this.contextModel tabOptions=this.tab options=this.tab.componentParams onConfigDeleting=this.onConfigDeleting onConfigDeleted=this.onConfigDeleted onConfigUpdated=this.onConfigUpdated onContextChanged=this.onContextChanged)
12
+ onTabChanged=this.onTabChanged
13
+ onClickCreateOrderConfig=this.createNewOrderConfig
14
+ )
15
+ }}
@@ -0,0 +1,285 @@
1
+ import Component from '@glimmer/component';
2
+ import EmberObject from '@ember/object';
3
+ import Evented from '@ember/object/evented';
4
+ import { tracked } from '@glimmer/tracking';
5
+ import { inject as service } from '@ember/service';
6
+ import { action } from '@ember/object';
7
+ import { isArray } from '@ember/array';
8
+ import { task } from 'ember-concurrency-decorators';
9
+ import isModel from '@fleetbase/ember-core/utils/is-model';
10
+ import getModelName from '@fleetbase/ember-core/utils/get-model-name';
11
+ import contextComponentCallback from '../utils/context-component-callback';
12
+ import applyContextComponentArguments from '../utils/apply-context-component-arguments';
13
+ import OrderConfigManagerDetailsComponent from './order-config-manager/details';
14
+ import OrderConfigManagerCustomFieldsComponent from './order-config-manager/custom-fields';
15
+ import OrderConfigManagerActivityFlowComponent from './order-config-manager/activity-flow';
16
+ import OrderConfigManagerEntitiesComponent from './order-config-manager/entities';
17
+
18
+ const configManagerContext = EmberObject.extend(Evented);
19
+ export default class OrderConfigManagerComponent extends Component {
20
+ @service universe;
21
+ @service notifications;
22
+ @service modalsManager;
23
+ @service store;
24
+ @service intl;
25
+ @tracked configs = [];
26
+ @tracked currentConfig;
27
+ @tracked tab;
28
+ @tracked configManagerContext;
29
+ @tracked context;
30
+ @tracked contextModel;
31
+
32
+ /**
33
+ * Returns the array of tabs available for the panel.
34
+ *
35
+ * @type {Array}
36
+ */
37
+ get tabs() {
38
+ const registeredTabs = this.universe.getMenuItemsFromRegistry('component:order-config-manager');
39
+ const defaultTabs = [
40
+ this.universe._createMenuItem('Details', null, { icon: 'circle-info', component: OrderConfigManagerDetailsComponent }),
41
+ this.universe._createMenuItem('Custom Fields', null, { icon: 'rectangle-list', component: OrderConfigManagerCustomFieldsComponent }),
42
+ this.universe._createMenuItem('Activity Flow', null, { icon: 'diagram-project', component: OrderConfigManagerActivityFlowComponent }),
43
+ this.universe._createMenuItem('Entities', null, { icon: 'boxes-packing', component: OrderConfigManagerEntitiesComponent }),
44
+ ];
45
+
46
+ if (isArray(registeredTabs)) {
47
+ return [...defaultTabs, ...registeredTabs];
48
+ }
49
+
50
+ return defaultTabs;
51
+ }
52
+
53
+ /**
54
+ * Constructs the component and applies initial state.
55
+ */
56
+ constructor(owner, { tab, context, contextModel }) {
57
+ super(...arguments);
58
+ applyContextComponentArguments(this);
59
+
60
+ this.context = context;
61
+ this.contextModel = contextModel;
62
+ this.configManagerContext = configManagerContext.create();
63
+ this.tab = this.getTabUsingSlug(tab);
64
+ this.loadOrderConfigs.perform();
65
+ }
66
+
67
+ /**
68
+ * Loads all available order configs asynchronously.
69
+ *
70
+ * @returns {void}
71
+ * @memberof OrderConfigManagerComponent
72
+ * @method loadOrderConfigs
73
+ * @instance
74
+ * @task
75
+ * @generator
76
+ */
77
+ @task *loadOrderConfigs(options = {}) {
78
+ this.configs = yield this.store.findAll('order-config');
79
+
80
+ let currentConfig;
81
+ let initialOrderConfig = this.args.orderConfig;
82
+ if (isArray(this.configs) && this.configs.length > 0) {
83
+ if (initialOrderConfig) {
84
+ currentConfig = this.configs.find((config) => {
85
+ if (isModel(initialOrderConfig)) {
86
+ return config.id === initialOrderConfig.id;
87
+ }
88
+
89
+ if (typeof initialOrderConfig === 'string') {
90
+ return config.id === initialOrderConfig;
91
+ }
92
+ });
93
+ }
94
+
95
+ if (!currentConfig) {
96
+ currentConfig = this.configs[0];
97
+ }
98
+
99
+ this.selectConfig(currentConfig);
100
+ }
101
+
102
+ if (typeof options.onAfter === 'function') {
103
+ options.onAfter(this.configs, currentConfig);
104
+ }
105
+ }
106
+
107
+ /**
108
+ * Handle anonymous context change.
109
+ *
110
+ * @memberof OrderConfigManagerComponent
111
+ */
112
+ @action onContextChanged(context) {
113
+ const isValidContext = context && isModel(context);
114
+ if (context === null || !isValidContext) {
115
+ this.context = undefined;
116
+ this.contextModel = undefined;
117
+ contextComponentCallback(this, 'onContextChanged', this.context, this.contextModel);
118
+ return;
119
+ }
120
+
121
+ this.context = context.get('id');
122
+ this.contextModel = getModelName(context);
123
+ contextComponentCallback(this, 'onContextChanged', this.context, this.contextModel);
124
+ }
125
+
126
+ /**
127
+ * Creates a new order configuration and displays a modal for further interaction.
128
+ *
129
+ * This action initializes a new 'order-config' record with default values and
130
+ * displays a modal to the user for creating a new order configuration. The modal
131
+ * is configured with various properties including titles, button icons, and a callback
132
+ * for the confirm action. The confirm action includes validation and saving of the
133
+ * new order configuration, along with success and warning notifications.
134
+ */
135
+ @action createNewOrderConfig() {
136
+ const orderConfig = this.store.createRecord('order-config', {
137
+ tags: [],
138
+ });
139
+
140
+ this.modalsManager.show('modals/new-order-config', {
141
+ title: this.intl.t('fleet-ops.component.order-config-manager.create-new-title'),
142
+ acceptButtonIcon: 'check',
143
+ acceptButtonIconPrefix: 'fas',
144
+ declineButtonIcon: 'times',
145
+ declineButtonIconPrefix: 'fas',
146
+ orderConfig,
147
+ addTag: (tag) => {
148
+ orderConfig.addTag(tag);
149
+ },
150
+ removeTag: (index) => {
151
+ orderConfig.removeTag(index);
152
+ },
153
+ confirm: (modal) => {
154
+ if (!orderConfig.name) {
155
+ return this.notifications.warning(this.intl.t('fleet-ops.component.order-config-manager.create-warning-message'));
156
+ }
157
+
158
+ modal.startLoading();
159
+ return orderConfig.save().then((newOrderConfig) => {
160
+ this.notifications.success(this.intl.t('fleet-ops.component.order-config-manager.create-success-message'));
161
+ this.loadOrderConfigs.perform({
162
+ onAfter: () => {
163
+ this.selectConfig(newOrderConfig);
164
+ },
165
+ });
166
+ });
167
+ },
168
+ });
169
+ }
170
+
171
+ /**
172
+ * Selects a specific order configuration.
173
+ *
174
+ * This action sets the 'currentConfig' property of the component to the
175
+ * specified configuration object.
176
+ *
177
+ * @param {Object} config - The order configuration object to be selected.
178
+ */
179
+ @action selectConfig(config) {
180
+ this.currentConfig = config;
181
+ this.configManagerContext.set('currentConfig', config);
182
+ this.configManagerContext.trigger('onConfigChanged', config);
183
+ contextComponentCallback(this, 'onConfigChanged', ...arguments);
184
+ }
185
+
186
+ /**
187
+ * Handles the deletion process of an order configuration.
188
+ *
189
+ * This action is called when an order configuration is in the process of being deleted.
190
+ * It deselects the current configuration and performs additional operations defined
191
+ * in 'contextComponentCallback'.
192
+ */
193
+ @action onConfigDeleting() {
194
+ this.selectConfig(null);
195
+ this.configManagerContext.trigger('onConfigDeleting');
196
+ contextComponentCallback(this, 'onConfigDeleting', ...arguments);
197
+ }
198
+
199
+ /**
200
+ * Executes actions after an order configuration has been deleted.
201
+ *
202
+ * Once a configuration is deleted, this action reloads the order configurations and
203
+ * executes additional operations defined in 'contextComponentCallback'.
204
+ */
205
+ @action onConfigDeleted() {
206
+ this.loadOrderConfigs.perform();
207
+ this.configManagerContext.trigger('onConfigDeleted');
208
+ contextComponentCallback(this, 'onConfigDeleted', ...arguments);
209
+ }
210
+
211
+ /**
212
+ * Performs operations after an order configuration has been updated.
213
+ *
214
+ * This action is triggered when an order configuration update occurs.
215
+ * It primarily executes additional operations defined in 'contextComponentCallback'.
216
+ */
217
+ @action onConfigUpdated() {
218
+ this.configManagerContext.trigger('onConfigUpdated');
219
+ contextComponentCallback(this, 'onConfigUpdated', ...arguments);
220
+ }
221
+
222
+ /**
223
+ * Sets the overlay context.
224
+ *
225
+ * @action
226
+ * @param {OverlayContextObject} overlayContext
227
+ */
228
+ @action setOverlayContext(overlayContext) {
229
+ this.context = overlayContext;
230
+ this.configManagerContext.trigger('onLoad');
231
+ contextComponentCallback(this, 'onLoad', ...arguments);
232
+ }
233
+
234
+ /**
235
+ * Handles changing the active tab.
236
+ *
237
+ * @method
238
+ * @param {String} tab - The new tab to switch to.
239
+ * @action
240
+ */
241
+ @action onTabChanged(tab) {
242
+ this.tab = this.getTabUsingSlug(tab);
243
+ this.configManagerContext.trigger('onTabChanged');
244
+ contextComponentCallback(this, 'onTabChanged', tab);
245
+ }
246
+
247
+ /**
248
+ * Handles edit action for the place.
249
+ *
250
+ * @method
251
+ * @action
252
+ */
253
+ @action onEdit() {
254
+ const isActionOverrided = contextComponentCallback(this, 'onEdit');
255
+
256
+ if (!isActionOverrided) {
257
+ this.contextPanel.clear();
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Handles the cancel action.
263
+ *
264
+ * @method
265
+ * @action
266
+ * @returns {Boolean} Indicates whether the cancel action was overridden.
267
+ */
268
+ @action onPressCancel() {
269
+ return contextComponentCallback(this, 'onPressCancel');
270
+ }
271
+
272
+ /**
273
+ * Finds and returns a tab based on its slug.
274
+ *
275
+ * @param {String} tabSlug - The slug of the tab.
276
+ * @returns {Object|null} The found tab or null.
277
+ */
278
+ getTabUsingSlug(tabSlug) {
279
+ if (tabSlug) {
280
+ return this.tabs.find(({ slug }) => slug === tabSlug);
281
+ }
282
+
283
+ return this.tabs[0];
284
+ }
285
+ }
@@ -0,0 +1 @@
1
+ {{yield}}
@@ -0,0 +1,3 @@
1
+ import Component from '@glimmer/component';
2
+
3
+ export default class OrderFlowComponent extends Component {}
@@ -6,7 +6,7 @@
6
6
  </div>
7
7
  </Overlay::Header>
8
8
 
9
- <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4" @increaseInnerBodyHeightBy={{1000}}>
9
+ <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4">
10
10
  <div class="flex-1 space-y-4">
11
11
  <div class="grid grid-cols-3 gap-1 text-xs dark:text-gray-100">
12
12
  <InputGroup @name={{t "fleet-ops.common.name"}} @wrapperClass="col-span-2">
@@ -3,7 +3,7 @@
3
3
  <Button @type="default" @icon="pen" @helpText={{t "fleet-ops.component.place-panel.edit-place"}} @onClick={{this.onEdit}} @wrapperClass="mr-2" />
4
4
  <Button @type="default" @icon="times" @helpText={{if this.place.id (t "fleet-ops.component.place-panel.cancel-edit-place")(t "fleet-ops.component.place-panel.cancel-new-place") }} @onClick={{this.onPressCancel}} />
5
5
  </Overlay::Header>
6
- <Overlay::Body class="no-padding" @increaseInnerBodyHeightBy={{1000}}>
6
+ <Overlay::Body class="no-padding">
7
7
  <div class="section-header-actions w-full overflow-x-scroll lg:overflow-x-auto">
8
8
  <div class="ui-tabs mt-4">
9
9
  <nav>
@@ -59,7 +59,7 @@
59
59
  </div>
60
60
  </Overlay::Header>
61
61
 
62
- <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4" @increaseInnerBodyHeightBy={{1000}}>
62
+ <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4">
63
63
  <div class="flex-1 space-y-4">
64
64
  <ContentPanel @title="Details" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
65
65
  <div class="grid grid-cols-1 gap-4 lg:grid-cols-2 lg:gap-2">
@@ -58,7 +58,7 @@
58
58
  </div>
59
59
  </div>
60
60
  </Overlay::Header>
61
- <Overlay::Body class="no-padding" @increaseInnerBodyHeightBy={{1000}}>
61
+ <Overlay::Body class="no-padding">
62
62
  <div class="section-header-actions w-full overflow-x-scroll lg:overflow-x-auto">
63
63
  <div class="ui-tabs mt-4">
64
64
  <nav>
@@ -71,7 +71,7 @@
71
71
  </div>
72
72
  </Overlay::Header>
73
73
 
74
- <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4" @increaseInnerBodyHeightBy={{1000}}>
74
+ <Overlay::Body @wrapperClass="new-service-rate-overlay-body px-4 space-y-4 pt-4">
75
75
  {{#if this.isEditing}}
76
76
  <VendorFormPanel::EditForm
77
77
  @vendor={{this.vendor}}
@@ -55,7 +55,7 @@
55
55
  </div>
56
56
  </div>
57
57
  </Overlay::Header>
58
- <Overlay::Body class="no-padding" @increaseInnerBodyHeightBy={{1000}}>
58
+ <Overlay::Body class="no-padding">
59
59
  <div class="section-header-actions w-full overflow-x-scroll lg:overflow-x-auto">
60
60
  <div class="ui-tabs mt-4">
61
61
  <nav>