diff --git a/addon/components/activity-event-selector.js b/addon/components/activity-event-selector.js index 24081374..b6a05fbe 100644 --- a/addon/components/activity-event-selector.js +++ b/addon/components/activity-event-selector.js @@ -1,7 +1,7 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; -import contextComponentCallback from '../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; /** diff --git a/addon/components/activity-form-panel.js b/addon/components/activity-form-panel.js index 58fddffa..55e79225 100644 --- a/addon/components/activity-form-panel.js +++ b/addon/components/activity-form-panel.js @@ -2,8 +2,8 @@ import Component from '@glimmer/component'; import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { underscore, capitalize, w } from '@ember/string'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; /** * Component class for managing activity forms. diff --git a/addon/components/activity-logic-builder.js b/addon/components/activity-logic-builder.js index 155d9da9..e13569f1 100644 --- a/addon/components/activity-logic-builder.js +++ b/addon/components/activity-logic-builder.js @@ -3,7 +3,7 @@ import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { isArray } from '@ember/array'; import { isNone } from '@ember/utils'; -import contextComponentCallback from '../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; export default class ActivityLogicBuilderComponent extends Component { diff --git a/addon/components/admin/navigator-app.hbs b/addon/components/admin/navigator-app.hbs index 6b23d613..ecb06a28 100644 --- a/addon/components/admin/navigator-app.hbs +++ b/addon/components/admin/navigator-app.hbs @@ -1,8 +1,84 @@ - + {{this.url}} {{t "fleet-ops.component.admin.navigator-app.message" htmlSafe=true companyName=@app.name}} + + + + +
+ +
{{t "fleet-ops.component.admin.navigator-app.select-input"}}
+
+
+ {{#if this.isEntityFieldsEditable}} + +
+ + + + + +
+
+ {{#if this.selectedOrderConfig}} +
+ {{#let (get (get this.entityEditingSettings this.selectedOrderConfig.id) "editable_entity_fields") as |editableEntityFields|}} + {{#each this.entityFields as |entityField|}} +
+ +
+ {{/each}} + {{/let}} +
+
+
+ {{/if}} + {{/if}}
\ No newline at end of file diff --git a/addon/components/admin/navigator-app.js b/addon/components/admin/navigator-app.js index 166030ad..a33035ff 100644 --- a/addon/components/admin/navigator-app.js +++ b/addon/components/admin/navigator-app.js @@ -1,27 +1,80 @@ import Component from '@glimmer/component'; -import { inject as service } from '@ember/service'; import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import { action } from '@ember/object'; +import { isArray } from '@ember/array'; +import { task } from 'ember-concurrency-decorators'; export default class NavigatorAppControlsComponent extends Component { @service fetch; @tracked isLoading = false; @tracked url; + @tracked selectedOrderConfig; + @tracked entityFields = ['name', 'description', 'sku', 'height', 'width', 'length', 'weight', 'declared_value', 'sale_price']; + @tracked entityEditingSettings = {}; + @tracked isEntityFieldsEditable = false; constructor() { super(...arguments); - this.getAppLinkUrl(); + this.getAppLinkUrl.perform(); + this.getEntityEditableSettings.perform(); + } + + @action enableEditableEntityFields(isEntityFieldsEditable) { + this.isEntityFieldsEditable = isEntityFieldsEditable; + } + + @action onConfigChanged(orderConfig) { + this.selectedOrderConfig = orderConfig; + } + + @action toggleFieldEditable(fieldName, isEditable) { + const editableFields = this.entityEditingSettings[this.selectedOrderConfig.id]?.editable_entity_fields; + if (isArray(editableFields)) { + if (isEditable) { + editableFields.pushObject(fieldName); + } else { + editableFields.removeObject(fieldName); + } + } else { + this.entityEditingSettings = { + ...this.entityEditingSettings, + [this.selectedOrderConfig.id]: { + editable_entity_fields: [], + }, + }; + return this.toggleFieldEditable(...arguments); + } + + this.updateEditableEntityFieldsForOrderConfig(editableFields); + } + + updateEditableEntityFieldsForOrderConfig(editableFields = [], orderConfig = null) { + orderConfig = orderConfig === null ? this.selectedOrderConfig : orderConfig; + this.entityEditingSettings = { + ...this.entityEditingSettings, + [orderConfig.id]: { + editable_entity_fields: editableFields, + }, + }; } - getAppLinkUrl() { - this.isLoading = true; + @task *getAppLinkUrl() { + const response = yield this.fetch.get('fleet-ops/navigator/get-link-app'); + const { linkUrl } = response; + if (linkUrl) { + this.url = linkUrl; + } + } + + @task *getEntityEditableSettings() { + const { entityEditingSettings, isEntityFieldsEditable } = yield this.fetch.get('fleet-ops/settings/entity-editing-settings'); + this.entityEditingSettings = entityEditingSettings; + this.isEntityFieldsEditable = isEntityFieldsEditable; + } - return this.fetch - .get('fleet-ops/navigator/get-link-app') - .then(({ linkUrl }) => { - this.url = linkUrl; - }) - .finally(() => { - this.isLoading = false; - }); + @task *saveEntityEditingSettings() { + const { entityEditingSettings, isEntityFieldsEditable } = this; + yield this.fetch.post('fleet-ops/settings/entity-editing-settings', { entityEditingSettings, isEntityFieldsEditable }); } } diff --git a/addon/components/contact-form-panel.js b/addon/components/contact-form-panel.js index fcbff1aa..f2874d64 100644 --- a/addon/components/contact-form-panel.js +++ b/addon/components/contact-form-panel.js @@ -2,8 +2,8 @@ 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'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class ContactFormPanelComponent extends Component { /** diff --git a/addon/components/contact-panel.js b/addon/components/contact-panel.js index 3b5a1dd1..1d8d0bc7 100644 --- a/addon/components/contact-panel.js +++ b/addon/components/contact-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import ContactPanelDetailComponent from './contact-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class ContactPanelComponent extends Component { /** diff --git a/addon/components/custom-field-form-panel.js b/addon/components/custom-field-form-panel.js index dde93f2a..c3ec5819 100644 --- a/addon/components/custom-field-form-panel.js +++ b/addon/components/custom-field-form-panel.js @@ -5,8 +5,8 @@ import { action } from '@ember/object'; import { dasherize, camelize } from '@ember/string'; import { task } from 'ember-concurrency-decorators'; import isObject from '@fleetbase/ember-core/utils/is-object'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import getCustomFieldTypeMap from '../utils/get-custom-field-type-map'; /** diff --git a/addon/components/driver-form-panel.js b/addon/components/driver-form-panel.js index bfe535d6..6ac0178a 100644 --- a/addon/components/driver-form-panel.js +++ b/addon/components/driver-form-panel.js @@ -3,8 +3,8 @@ import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import Point from '@fleetbase/fleetops-data/utils/geojson/point'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class DriverFormPanelComponent extends Component { /** diff --git a/addon/components/driver-panel.js b/addon/components/driver-panel.js index b167b95b..6bba5901 100644 --- a/addon/components/driver-panel.js +++ b/addon/components/driver-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import DriverPanelDetailComponent from './driver-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class DriverPanelComponent extends Component { /** diff --git a/addon/components/edit-order-route-panel.js b/addon/components/edit-order-route-panel.js index 43f5de95..7d09a0d4 100644 --- a/addon/components/edit-order-route-panel.js +++ b/addon/components/edit-order-route-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import { task } from 'ember-concurrency-decorators'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import getRoutingHost from '@fleetbase/ember-core/utils/get-routing-host'; import Point from '@fleetbase/fleetops-data/utils/geojson/point'; import findClosestWaypoint from '@fleetbase/ember-core/utils/find-closest-waypoint'; diff --git a/addon/components/fleet-form-panel.js b/addon/components/fleet-form-panel.js index 4fe91ab6..e197c575 100644 --- a/addon/components/fleet-form-panel.js +++ b/addon/components/fleet-form-panel.js @@ -3,8 +3,8 @@ import { tracked } from '@glimmer/tracking'; import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { underscore } from '@ember/string'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class FleetFormPanelComponent extends Component { /** diff --git a/addon/components/fleet-panel.js b/addon/components/fleet-panel.js index 35e70c2a..d5e861d3 100644 --- a/addon/components/fleet-panel.js +++ b/addon/components/fleet-panel.js @@ -6,8 +6,8 @@ import { isArray } from '@ember/array'; import FleetPanelDetailComponent from './fleet-panel/details'; import FleetPanelDriverListingComponent from './fleet-panel/driver-listing'; import FleetPanelVehicleListingComponent from './fleet-panel/vehicle-listing'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class FleetPanelComponent extends Component { /** diff --git a/addon/components/fleet-panel/driver-listing.js b/addon/components/fleet-panel/driver-listing.js index 02c58505..b949993f 100644 --- a/addon/components/fleet-panel/driver-listing.js +++ b/addon/components/fleet-panel/driver-listing.js @@ -5,7 +5,7 @@ import { isBlank } from '@ember/utils'; import { action, set } from '@ember/object'; import { timeout } from 'ember-concurrency'; import { task } from 'ember-concurrency-decorators'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; export default class FleetPanelDriverListingComponent extends Component { /** diff --git a/addon/components/fleet-panel/vehicle-listing.js b/addon/components/fleet-panel/vehicle-listing.js index e1f18a77..e3a4a7c2 100644 --- a/addon/components/fleet-panel/vehicle-listing.js +++ b/addon/components/fleet-panel/vehicle-listing.js @@ -5,7 +5,7 @@ import { isBlank } from '@ember/utils'; import { action, set } from '@ember/object'; import { timeout } from 'ember-concurrency'; import { task } from 'ember-concurrency-decorators'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; export default class FleetPanelVehicleListingComponent extends Component { /** diff --git a/addon/components/fuel-report-form-panel.js b/addon/components/fuel-report-form-panel.js index 4771c65f..9bc8ba05 100644 --- a/addon/components/fuel-report-form-panel.js +++ b/addon/components/fuel-report-form-panel.js @@ -2,8 +2,8 @@ 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'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class FuelReportFormPanelComponent extends Component { /** diff --git a/addon/components/fuel-report-panel.js b/addon/components/fuel-report-panel.js index 0391b0be..8fa6ab90 100644 --- a/addon/components/fuel-report-panel.js +++ b/addon/components/fuel-report-panel.js @@ -4,8 +4,8 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { isArray } from '@ember/array'; import FuelReportPanelDetailsComponent from './fuel-report-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class FuelReportPanelComponent extends Component { /** diff --git a/addon/components/issue-form-panel.js b/addon/components/issue-form-panel.js index bf4dd647..ec46f594 100644 --- a/addon/components/issue-form-panel.js +++ b/addon/components/issue-form-panel.js @@ -4,8 +4,8 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { isArray } from '@ember/array'; import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import getIssueTypes from '../utils/get-issue-types'; import getIssueCategories from '../utils/get-issue-categories'; diff --git a/addon/components/issue-panel.js b/addon/components/issue-panel.js index c56dac44..389565d8 100644 --- a/addon/components/issue-panel.js +++ b/addon/components/issue-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import IssuePanelDetailComponent from './issue-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class IssuePanelComponent extends Component { /** * Service for fetching data. diff --git a/addon/components/live-map-drawer.js b/addon/components/live-map-drawer.js index cb6b1108..4d3ed39d 100644 --- a/addon/components/live-map-drawer.js +++ b/addon/components/live-map-drawer.js @@ -3,8 +3,8 @@ import { tracked } from '@glimmer/tracking'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import LiveMapDrawerVehicleListingComponent from './live-map-drawer/vehicle-listing'; import LiveMapDrawerDriverListingComponent from './live-map-drawer/driver-listing'; import LiveMapDrawerPlaceListingComponent from './live-map-drawer/place-listing'; diff --git a/addon/components/order-config-manager-overlay.js b/addon/components/order-config-manager-overlay.js index fea7a52a..35f3d266 100644 --- a/addon/components/order-config-manager-overlay.js +++ b/addon/components/order-config-manager-overlay.js @@ -1,6 +1,6 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; -import contextComponentCallback from '../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; export default class OrderConfigManagerOverlayComponent extends Component { /** diff --git a/addon/components/order-config-manager.js b/addon/components/order-config-manager.js index 2122a73a..ff296164 100644 --- a/addon/components/order-config-manager.js +++ b/addon/components/order-config-manager.js @@ -9,8 +9,8 @@ import { dasherize } from '@ember/string'; import { task } from 'ember-concurrency-decorators'; import isModel from '@fleetbase/ember-core/utils/is-model'; import getModelName from '@fleetbase/ember-core/utils/get-model-name'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import OrderConfigManagerDetailsComponent from './order-config-manager/details'; import OrderConfigManagerCustomFieldsComponent from './order-config-manager/custom-fields'; import OrderConfigManagerActivityFlowComponent from './order-config-manager/activity-flow'; diff --git a/addon/components/order-config-manager/activity-flow.js b/addon/components/order-config-manager/activity-flow.js index c013ec52..467e6bdb 100644 --- a/addon/components/order-config-manager/activity-flow.js +++ b/addon/components/order-config-manager/activity-flow.js @@ -9,7 +9,7 @@ import { later } from '@ember/runloop'; import { task } from 'ember-concurrency-decorators'; import generateUUID from '@fleetbase/ember-core/utils/generate-uuid'; import createFlowActivity from '../../utils/create-flow-activity'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; /** * Manages the activity flow for order configuration, allowing users to create, edit, and view a sequence of activities. diff --git a/addon/components/order-config-manager/custom-fields.js b/addon/components/order-config-manager/custom-fields.js index d5e63ef8..49fa2046 100644 --- a/addon/components/order-config-manager/custom-fields.js +++ b/addon/components/order-config-manager/custom-fields.js @@ -6,7 +6,7 @@ import { isArray } from '@ember/array'; import { later } from '@ember/runloop'; import { task } from 'ember-concurrency-decorators'; import isObject from '@fleetbase/ember-core/utils/is-object'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; /** * Component class for managing custom fields within an order configuration. diff --git a/addon/components/order-config-manager/entities.js b/addon/components/order-config-manager/entities.js index b38952f2..349ca1b7 100644 --- a/addon/components/order-config-manager/entities.js +++ b/addon/components/order-config-manager/entities.js @@ -8,7 +8,7 @@ import { task } from 'ember-concurrency-decorators'; import getWithDefault from '@fleetbase/ember-core/utils/get-with-default'; import ObjectProxy from '@ember/object/proxy'; import createCustomEntity from '../../utils/create-custom-entity'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; /** * Component class for managing order configuration entities. diff --git a/addon/components/place-form-panel.js b/addon/components/place-form-panel.js index 0d0ad59b..b18e5dcc 100644 --- a/addon/components/place-form-panel.js +++ b/addon/components/place-form-panel.js @@ -4,8 +4,8 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { isBlank } from '@ember/utils'; import Point from '@fleetbase/fleetops-data/utils/geojson/point'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class PlaceFormPanelComponent extends Component { /** diff --git a/addon/components/place-panel.js b/addon/components/place-panel.js index 9d6f6d9c..712d3a3c 100644 --- a/addon/components/place-panel.js +++ b/addon/components/place-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import PlacePanelDetailComponent from './place-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class PlacePanelComponent extends Component { /** diff --git a/addon/components/vehicle-form-panel.js b/addon/components/vehicle-form-panel.js index 8a8a57ab..2c033c39 100644 --- a/addon/components/vehicle-form-panel.js +++ b/addon/components/vehicle-form-panel.js @@ -2,8 +2,8 @@ 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'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import Point from '@fleetbase/fleetops-data/utils/geojson/point'; export default class VehicleFormPanelComponent extends Component { diff --git a/addon/components/vehicle-panel.js b/addon/components/vehicle-panel.js index d55aa038..a5871e5e 100644 --- a/addon/components/vehicle-panel.js +++ b/addon/components/vehicle-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import VehiclePanelDetailComponent from './vehicle-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; /** * Represents the vehicle panel component, handling vehicle information display and editing. diff --git a/addon/components/vendor-form-panel.js b/addon/components/vendor-form-panel.js index 8216d87b..9c6dcaae 100644 --- a/addon/components/vendor-form-panel.js +++ b/addon/components/vendor-form-panel.js @@ -2,8 +2,8 @@ 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'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; import getVendorTypeOptions from '../utils/get-vendor-type-options'; import getVendorStatusOptions from '../utils/get-vendor-status-options'; diff --git a/addon/components/vendor-form-panel/create-form.js b/addon/components/vendor-form-panel/create-form.js index 91eb973a..7608bcd5 100644 --- a/addon/components/vendor-form-panel/create-form.js +++ b/addon/components/vendor-form-panel/create-form.js @@ -4,7 +4,7 @@ import { inject as service } from '@ember/service'; import { action } from '@ember/object'; import { isArray } from '@ember/array'; import apiUrl from '@fleetbase/ember-core/utils/api-url'; -import contextComponentCallback from '../../utils/context-component-callback'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; export default class VendorFormPanelCreateFormComponent extends Component { /** diff --git a/addon/components/vendor-panel.js b/addon/components/vendor-panel.js index 074d73a5..a9f6cc76 100644 --- a/addon/components/vendor-panel.js +++ b/addon/components/vendor-panel.js @@ -4,8 +4,8 @@ import { action } from '@ember/object'; import { inject as service } from '@ember/service'; import { isArray } from '@ember/array'; import VendorPanelDetailComponent from './vendor-panel/details'; -import contextComponentCallback from '../utils/context-component-callback'; -import applyContextComponentArguments from '../utils/apply-context-component-arguments'; +import contextComponentCallback from '@fleetbase/ember-core/utils/context-component-callback'; +import applyContextComponentArguments from '@fleetbase/ember-core/utils/apply-context-component-arguments'; export default class VendorPanelComponent extends Component { /** diff --git a/addon/utils/apply-context-component-arguments.js b/addon/utils/apply-context-component-arguments.js deleted file mode 100644 index 3b741459..00000000 --- a/addon/utils/apply-context-component-arguments.js +++ /dev/null @@ -1,33 +0,0 @@ -import getModelName from '@fleetbase/ember-core/utils/get-model-name'; -import isModel from '@fleetbase/ember-core/utils/is-model'; -import { camelize } from '@ember/string'; - -/** - * Applies context and dynamic arguments to a given component. - * - * @param {Component} component - The component to which context and arguments will be applied. - */ -export default function applyContextComponentArguments(component) { - const { context, dynamicArgs = {} } = component.args; - - // Apply context model if available - if (context && isModel(context)) { - const contextModelName = camelize(getModelName(context)); - if (contextModelName) { - component[contextModelName] = context; - } - } - - // Execute any apply callback present in dynamic arguments - const { applyCallback } = dynamicArgs; - if (typeof applyCallback === 'function') { - applyCallback(component); - } - - // Apply other dynamic arguments to the component - for (const [key, value] of Object.entries(dynamicArgs)) { - if (key !== 'applyCallback') { - component[key] = value; - } - } -} diff --git a/addon/utils/context-component-callback.js b/addon/utils/context-component-callback.js deleted file mode 100644 index a31c2a30..00000000 --- a/addon/utils/context-component-callback.js +++ /dev/null @@ -1,16 +0,0 @@ -export default function contextComponentCallback(component, name, ...params) { - let callbackInvoked = false; - - if (typeof component.args[name] === 'function') { - component.args[name](...params); - callbackInvoked = true; - } - - // now do for context options - if (typeof component.args.options === 'object' && typeof component.args.options[name] === 'function') { - component.args.options[name](...params); - callbackInvoked = true; - } - - return callbackInvoked; -} diff --git a/app/utils/apply-context-component-arguments.js b/app/utils/apply-context-component-arguments.js deleted file mode 100644 index 3068aa4c..00000000 --- a/app/utils/apply-context-component-arguments.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@fleetbase/fleetops-engine/utils/apply-context-component-arguments'; diff --git a/app/utils/context-component-callback.js b/app/utils/context-component-callback.js deleted file mode 100644 index a7063472..00000000 --- a/app/utils/context-component-callback.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from '@fleetbase/fleetops-engine/utils/context-component-callback'; diff --git a/composer.json b/composer.json index 4b5950cb..6eeb5155 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/fleetops-api", - "version": "0.4.19", + "version": "0.4.20", "description": "Fleet & Transport Management Extension for Fleetbase", "keywords": [ "fleetbase-extension", @@ -22,7 +22,7 @@ ], "require": { "php": "^8.0", - "fleetbase/core-api": "^1.4.12", + "fleetbase/core-api": "^1.4.14", "barryvdh/laravel-dompdf": "^2.0", "brick/geo": "0.7.2", "cknow/laravel-money": "^7.1", diff --git a/extension.json b/extension.json index c174b5f8..80cfe332 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Fleet-Ops", - "version": "0.4.19", + "version": "0.4.20", "description": "Fleet & Transport Management Extension for Fleetbase", "repository": "https://github.com/fleetbase/fleetops", "license": "MIT", diff --git a/package.json b/package.json index c8f4b252..cbdbcbd3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/fleetops-engine", - "version": "0.4.19", + "version": "0.4.20", "description": "Fleet & Transport Management Extension for Fleetbase", "fleetbase": { "route": "fleet-ops" @@ -42,7 +42,7 @@ }, "dependencies": { "@babel/core": "^7.23.2", - "@fleetbase/ember-core": "^0.2.6", + "@fleetbase/ember-core": "^0.2.8", "@fleetbase/ember-ui": "^0.2.11", "@fleetbase/fleetops-data": "^0.1.14", "@fleetbase/leaflet-routing-machine": "^3.2.16", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fe3e70af..d21b9ba2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,8 +5,8 @@ dependencies: specifier: ^7.23.2 version: 7.23.2 '@fleetbase/ember-core': - specifier: ^0.2.6 - version: 0.2.6(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0) + specifier: ^0.2.8 + version: 0.2.8(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0) '@fleetbase/ember-ui': specifier: ^0.2.11 version: 0.2.11(@ember/test-helpers@3.2.0)(@glimmer/component@1.1.2)(@glimmer/tracking@1.1.2)(ember-source@5.4.0)(postcss@8.4.35)(rollup@4.12.0)(tracked-built-ins@3.3.0)(webpack@5.89.0) @@ -2449,8 +2449,8 @@ packages: - supports-color dev: false - /@fleetbase/ember-core@0.2.6(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0): - resolution: {integrity: sha512-EHO47NM6XH/1bC6TL7cEbJQ//RCrdFb1+TsCIHvhPtP7KSGyam2gexiiNlwTm4fgVizxyvDCbCpGDMEs8ltZnA==} + /@fleetbase/ember-core@0.2.8(@ember/test-helpers@3.2.0)(ember-source@5.4.0)(webpack@5.89.0): + resolution: {integrity: sha512-9GGwjkp038UuMX4IHjw4NUqSinCOQWMisFG6XhQT8iyGlcOfSXJX8CxMyNutKpdwQ21VPbRoylVw0q4CmwjaNw==} engines: {node: '>= 18'} dependencies: '@babel/core': 7.23.2 diff --git a/server/src/Http/Controllers/Api/v1/DriverController.php b/server/src/Http/Controllers/Api/v1/DriverController.php index 1d652625..5fc51b84 100644 --- a/server/src/Http/Controllers/Api/v1/DriverController.php +++ b/server/src/Http/Controllers/Api/v1/DriverController.php @@ -11,7 +11,6 @@ use Fleetbase\FleetOps\Jobs\SimulateDrivingRoute; use Fleetbase\FleetOps\Models\Driver; use Fleetbase\FleetOps\Models\Order; -use Fleetbase\FleetOps\Support\Flow; use Fleetbase\FleetOps\Support\OSRM; use Fleetbase\FleetOps\Support\Utils; use Fleetbase\Http\Controllers\Controller; diff --git a/server/src/Http/Controllers/Api/v1/OrderController.php b/server/src/Http/Controllers/Api/v1/OrderController.php index b40a53a1..e31cb754 100644 --- a/server/src/Http/Controllers/Api/v1/OrderController.php +++ b/server/src/Http/Controllers/Api/v1/OrderController.php @@ -25,6 +25,7 @@ use Fleetbase\Http\Controllers\Controller; use Fleetbase\Models\Company; use Fleetbase\Models\File; +use Fleetbase\Models\Setting; use Fleetbase\Support\Auth; use Illuminate\Http\Request; use Illuminate\Support\Carbon; @@ -433,8 +434,6 @@ public function update($id, UpdateOrderRequest $request) public function query(Request $request) { $results = Order::queryWithRequest($request, function (&$query, $request) { - $query->where('company_uuid', session('company')); - if ($request->has('payload')) { $query->whereHas('payload', function ($q) use ($request) { $q->where('public_id', $request->input('payload')); @@ -1364,4 +1363,36 @@ public function capturePhoto(Request $request, string $id, ?string $subjectId = return new ProofResource($proof); } + + public function getEntityEditableFields(string $id, Request $request) + { + try { + $order = Order::findRecordOrFail($id); + } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $exception) { + return response()->json( + [ + 'error' => 'Order resource not found.', + ], + 404 + ); + } + + // Define settings as array + $entityEditingSettings = []; + + // get the order config id + $orderConfigId = data_get($order, 'order_config_uuid'); + + // Get entity editing settings + $savedEntityEditingSettings = Setting::where('key', 'fleet-ops.entity-editing-settings')->value('value'); + + if ($orderConfigId && $savedEntityEditingSettings) { + $resolvedEntityEditingSettings = data_get($savedEntityEditingSettings, $orderConfigId, []); + if ($resolvedEntityEditingSettings) { + $entityEditingSettings = data_get($resolvedEntityEditingSettings, 'editable_entity_fields', []); + } + } + + return response()->json($entityEditingSettings); + } } diff --git a/server/src/Http/Controllers/Internal/v1/SettingController.php b/server/src/Http/Controllers/Internal/v1/SettingController.php index 8b65e430..ca7096d4 100644 --- a/server/src/Http/Controllers/Internal/v1/SettingController.php +++ b/server/src/Http/Controllers/Internal/v1/SettingController.php @@ -47,4 +47,24 @@ public function saveVisibilitySettings(Request $request) return response()->json(['visibilitySettings' => $visibilitySettings]); } + + public function saveEntityEditingSettings(Request $request) + { + $entityEditingSettings = $request->input('entityEditingSettings', []); + $isEntityFieldsEditable = $request->boolean('isEntityFieldsEditable'); + + // Save entity editing settings + Setting::configure('fleet-ops.entity-editing-settings', $entityEditingSettings); + Setting::configure('fleet-ops.entity-fields-editable', $isEntityFieldsEditable); + + return response()->json(['entityEditingSettings' => $entityEditingSettings, 'isEntityFieldsEditable' => $isEntityFieldsEditable]); + } + + public function getEntityEditingSettings() + { + $entityEditingSettings = Setting::where('key', 'fleet-ops.entity-editing-settings')->value('value'); + $isEntityFieldsEditable = Setting::where('key', 'fleet-ops.entity-fields-editable')->value('value'); + + return response()->json(['entityEditingSettings' => $entityEditingSettings, 'isEntityFieldsEditable' => $isEntityFieldsEditable]); + } } diff --git a/server/src/Http/Filter/ContactFilter.php b/server/src/Http/Filter/ContactFilter.php index 917c76f1..dc9d522d 100644 --- a/server/src/Http/Filter/ContactFilter.php +++ b/server/src/Http/Filter/ContactFilter.php @@ -22,6 +22,11 @@ function ($query) { ); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->search($searchQuery); diff --git a/server/src/Http/Filter/DriverFilter.php b/server/src/Http/Filter/DriverFilter.php index 4b84e92b..15276775 100644 --- a/server/src/Http/Filter/DriverFilter.php +++ b/server/src/Http/Filter/DriverFilter.php @@ -23,6 +23,11 @@ function ($query) { ); } + public function queryForPublic() + { + $this->queryForInternal(); + } + public function query(?string $searchQuery) { $this->builder->where(function ($query) use ($searchQuery) { diff --git a/server/src/Http/Filter/EntityFilter.php b/server/src/Http/Filter/EntityFilter.php new file mode 100644 index 00000000..d7e40e44 --- /dev/null +++ b/server/src/Http/Filter/EntityFilter.php @@ -0,0 +1,18 @@ +builder->where('company_uuid', $this->session->get('company')); + } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } +} diff --git a/server/src/Http/Filter/FleetFilter.php b/server/src/Http/Filter/FleetFilter.php index b1d892f8..27380c74 100644 --- a/server/src/Http/Filter/FleetFilter.php +++ b/server/src/Http/Filter/FleetFilter.php @@ -12,6 +12,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company'))->with(['serviceArea', 'zone']); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->where(function ($query) use ($searchQuery) { diff --git a/server/src/Http/Filter/FuelReportFilter.php b/server/src/Http/Filter/FuelReportFilter.php index a83bc2e2..4db384e0 100644 --- a/server/src/Http/Filter/FuelReportFilter.php +++ b/server/src/Http/Filter/FuelReportFilter.php @@ -13,6 +13,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->search($searchQuery); diff --git a/server/src/Http/Filter/IssueFilter.php b/server/src/Http/Filter/IssueFilter.php index 51bd1631..6a36b2e7 100644 --- a/server/src/Http/Filter/IssueFilter.php +++ b/server/src/Http/Filter/IssueFilter.php @@ -13,6 +13,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->search($searchQuery); diff --git a/server/src/Http/Filter/OrderConfigFilter.php b/server/src/Http/Filter/OrderConfigFilter.php index 51530697..a9a72a83 100644 --- a/server/src/Http/Filter/OrderConfigFilter.php +++ b/server/src/Http/Filter/OrderConfigFilter.php @@ -10,4 +10,9 @@ public function queryForInternal() { $this->builder->where('company_uuid', $this->session->get('company')); } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } } diff --git a/server/src/Http/Filter/OrderFilter.php b/server/src/Http/Filter/OrderFilter.php index b7ad81b3..0f714a8b 100644 --- a/server/src/Http/Filter/OrderFilter.php +++ b/server/src/Http/Filter/OrderFilter.php @@ -36,6 +36,11 @@ function ($q) { ); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company'))->whereHas('trackingNumber')->whereHas('payload'); + } + public function unassigned(bool $unassigned) { if ($unassigned) { diff --git a/server/src/Http/Filter/PayloadFilter.php b/server/src/Http/Filter/PayloadFilter.php new file mode 100644 index 00000000..bc75cf23 --- /dev/null +++ b/server/src/Http/Filter/PayloadFilter.php @@ -0,0 +1,18 @@ +builder->where('company_uuid', $this->session->get('company')); + } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } +} diff --git a/server/src/Http/Filter/PlaceFilter.php b/server/src/Http/Filter/PlaceFilter.php index b2818f1a..295bca21 100644 --- a/server/src/Http/Filter/PlaceFilter.php +++ b/server/src/Http/Filter/PlaceFilter.php @@ -15,6 +15,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->search($searchQuery); diff --git a/server/src/Http/Filter/PurchaseRateFilter.php b/server/src/Http/Filter/PurchaseRateFilter.php new file mode 100644 index 00000000..2af13059 --- /dev/null +++ b/server/src/Http/Filter/PurchaseRateFilter.php @@ -0,0 +1,18 @@ +builder->where('company_uuid', $this->session->get('company')); + } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } +} diff --git a/server/src/Http/Filter/ServiceAreaFilter.php b/server/src/Http/Filter/ServiceAreaFilter.php index 1ab4e7e9..cf3b1a7a 100644 --- a/server/src/Http/Filter/ServiceAreaFilter.php +++ b/server/src/Http/Filter/ServiceAreaFilter.php @@ -10,4 +10,9 @@ public function queryForInternal() { $this->builder->where('company_uuid', $this->session->get('company')); } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } } diff --git a/server/src/Http/Filter/ServiceQuoteFilter.php b/server/src/Http/Filter/ServiceQuoteFilter.php index 2dae6925..95e63058 100644 --- a/server/src/Http/Filter/ServiceQuoteFilter.php +++ b/server/src/Http/Filter/ServiceQuoteFilter.php @@ -10,4 +10,9 @@ public function queryForInternal() { $this->builder->where('company_uuid', $this->session->get('company')); } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } } diff --git a/server/src/Http/Filter/ServiceRateFilter.php b/server/src/Http/Filter/ServiceRateFilter.php index 76791ab0..75dbb0d1 100644 --- a/server/src/Http/Filter/ServiceRateFilter.php +++ b/server/src/Http/Filter/ServiceRateFilter.php @@ -11,6 +11,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function serviceArea(?string $serviceArea) { $this->builder->whereHas( diff --git a/server/src/Http/Filter/TrackingNumberFilter.php b/server/src/Http/Filter/TrackingNumberFilter.php new file mode 100644 index 00000000..a769e2cd --- /dev/null +++ b/server/src/Http/Filter/TrackingNumberFilter.php @@ -0,0 +1,18 @@ +builder->where('company_uuid', $this->session->get('company')); + } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } +} diff --git a/server/src/Http/Filter/TrackingStatusFilter.php b/server/src/Http/Filter/TrackingStatusFilter.php index aef863f3..794c5fea 100644 --- a/server/src/Http/Filter/TrackingStatusFilter.php +++ b/server/src/Http/Filter/TrackingStatusFilter.php @@ -11,6 +11,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function trackingNumber(string $trackingNumber) { $this->builder->whereHas('trackingNumber', function ($query) use ($trackingNumber) { diff --git a/server/src/Http/Filter/VehicleFilter.php b/server/src/Http/Filter/VehicleFilter.php index e9a09c94..08ab2b11 100644 --- a/server/src/Http/Filter/VehicleFilter.php +++ b/server/src/Http/Filter/VehicleFilter.php @@ -12,6 +12,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $query) { $this->builder->search($query); diff --git a/server/src/Http/Filter/VendorFilter.php b/server/src/Http/Filter/VendorFilter.php index b57102cd..2c9c7b5e 100644 --- a/server/src/Http/Filter/VendorFilter.php +++ b/server/src/Http/Filter/VendorFilter.php @@ -12,6 +12,11 @@ public function queryForInternal() $this->builder->where('company_uuid', $this->session->get('company')); } + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } + public function query(?string $searchQuery) { $this->builder->search($searchQuery); diff --git a/server/src/Http/Filter/ZoneFilter.php b/server/src/Http/Filter/ZoneFilter.php index efdf2aaa..3b947d6a 100644 --- a/server/src/Http/Filter/ZoneFilter.php +++ b/server/src/Http/Filter/ZoneFilter.php @@ -10,4 +10,9 @@ public function queryForInternal() { $this->builder->where('company_uuid', $this->session->get('company')); } + + public function queryForPublic() + { + $this->builder->where('company_uuid', $this->session->get('company')); + } } diff --git a/server/src/Http/Resources/v1/Order.php b/server/src/Http/Resources/v1/Order.php index ee635bde..6282c820 100644 --- a/server/src/Http/Resources/v1/Order.php +++ b/server/src/Http/Resources/v1/Order.php @@ -39,6 +39,7 @@ public function toArray($request) 'service_quote_uuid' => $this->when(Http::isInternalRequest(), $this->service_quote_uuid), 'has_driver_assigned' => $this->when(Http::isInternalRequest(), $this->has_driver_assigned), 'is_scheduled' => $this->when(Http::isInternalRequest(), $this->is_scheduled), + 'order_config_id' => $this->when(Http::isInternalRequest(), $this->order_config_id), 'order_config' => $this->when(Http::isInternalRequest(), $this->whenLoaded('orderConfig', $this->orderConfig), data_get($this->orderConfig, 'public_id')), 'custom_field_values' => $this->when(Http::isInternalRequest(), $this->customFieldValues), 'customer' => $this->setCustomerType(Resolve::resourceForMorph($this->customer_type, $this->customer_uuid)), diff --git a/server/src/Models/Driver.php b/server/src/Models/Driver.php index e27f8b58..a01fcfe5 100644 --- a/server/src/Models/Driver.php +++ b/server/src/Models/Driver.php @@ -157,7 +157,7 @@ class Driver extends Model * * @var array */ - protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet', 'photo_uuid', 'avatar_uuid']; + protected $filterParams = ['vendor', 'facilitator', 'customer', 'fleet', 'photo_uuid', 'avatar_uuid', 'avatar_value']; /** * Get the activity log options for the model. diff --git a/server/src/Providers/FleetOpsServiceProvider.php b/server/src/Providers/FleetOpsServiceProvider.php index 81c00b7e..1a25776d 100644 --- a/server/src/Providers/FleetOpsServiceProvider.php +++ b/server/src/Providers/FleetOpsServiceProvider.php @@ -80,9 +80,9 @@ public function boot() $this->registerObservers(); $this->registerCommands(); $this->scheduleCommands(function ($schedule) { - $schedule->command('fleetops:dispatch-orders')->everyMinute(); - $schedule->command('fleetops:dispatch-adhoc')->everyMinute(); - $schedule->command('fleetops:update-estimations')->everyFifteenMinutes(); + $schedule->command('fleetops:dispatch-orders')->everyMinute()->withoutOverlapping()->storeOutputInDb(); + $schedule->command('fleetops:dispatch-adhoc')->everyMinute()->withoutOverlapping()->storeOutputInDb(); + $schedule->command('fleetops:update-estimations')->everyFiveMinutes()->withoutOverlapping(); }); $this->registerNotifications(); $this->registerExpansionsFrom(__DIR__ . '/../Expansions'); diff --git a/server/src/Support/Utils.php b/server/src/Support/Utils.php index bf4f49b2..fc03b6f5 100644 --- a/server/src/Support/Utils.php +++ b/server/src/Support/Utils.php @@ -633,13 +633,26 @@ public static function getDrivingDistanceAndTime($origin, $destination): Distanc ] ); } else { - $point = static::getPointFromMixed($origin); - $origin = static::createObject( - [ - 'latitude' => $point->getLat(), - 'longitude' => $point->getLng(), - ] - ); + try { + $point = static::getPointFromMixed($origin); + $origin = static::createObject( + [ + 'latitude' => $point->getLat(), + 'longitude' => $point->getLng(), + ] + ); + } catch (\Throwable $e) { + if (app()->bound('sentry')) { + app('sentry')->captureException($e); + } + // create dummy $origin + $origin = static::createObject( + [ + 'latitude' => 0, + 'longitude' => 0, + ] + ); + } } if ($destination instanceof \Fleetbase\FleetOps\Models\Place) { @@ -650,13 +663,26 @@ public static function getDrivingDistanceAndTime($origin, $destination): Distanc ] ); } else { - $point = static::getPointFromMixed($destination); - $destination = static::createObject( - [ - 'latitude' => $point->getLat(), - 'longitude' => $point->getLng(), - ] - ); + try { + $point = static::getPointFromMixed($destination); + $destination = static::createObject( + [ + 'latitude' => $point->getLat(), + 'longitude' => $point->getLng(), + ] + ); + } catch (\Throwable $e) { + if (app()->bound('sentry')) { + app('sentry')->captureException($e); + } + // create dummy $destination + $destination = static::createObject( + [ + 'latitude' => 0, + 'longitude' => 0, + ] + ); + } } $cacheKey = $origin->latitude . ':' . $origin->longitude . ':' . $destination->latitude . ':' . $destination->longitude; diff --git a/server/src/routes.php b/server/src/routes.php index f4bb9721..eb350f51 100644 --- a/server/src/routes.php +++ b/server/src/routes.php @@ -84,6 +84,7 @@ function ($router) { $router->post('{id}/capture-photo/{subjectId?}', 'OrderController@capturePhoto'); $router->put('{id}', 'OrderController@update'); $router->delete('{id}', 'OrderController@delete'); + $router->delete('{id}', 'OrderController@getEntityEditableFields'); }); // entities routes $router->group(['prefix' => 'entities'], function () use ($router) { @@ -435,6 +436,8 @@ function ($router) { function ($router) { $router->get('visibility', 'SettingController@getVisibilitySettings'); $router->post('visibility', 'SettingController@saveVisibilitySettings'); + $router->get('entity-editing-settings', 'SettingController@getEntityEditingSettings'); + $router->post('entity-editing-settings', 'SettingController@saveEntityEditingSettings'); } ); $router->group( diff --git a/tests/unit/utils/apply-context-component-arguments-test.js b/tests/unit/utils/apply-context-component-arguments-test.js deleted file mode 100644 index 17998ef4..00000000 --- a/tests/unit/utils/apply-context-component-arguments-test.js +++ /dev/null @@ -1,10 +0,0 @@ -import applyContextComponentArguments from 'dummy/utils/apply-context-component-arguments'; -import { module, test } from 'qunit'; - -module('Unit | Utility | apply-context-component-arguments', function () { - // TODO: Replace this with your real tests. - test('it works', function (assert) { - let result = applyContextComponentArguments(); - assert.ok(result); - }); -}); diff --git a/tests/unit/utils/context-component-callback-test.js b/tests/unit/utils/context-component-callback-test.js deleted file mode 100644 index b0855fb9..00000000 --- a/tests/unit/utils/context-component-callback-test.js +++ /dev/null @@ -1,10 +0,0 @@ -import contextComponentCallback from 'dummy/utils/context-component-callback'; -import { module, test } from 'qunit'; - -module('Unit | Utility | context-component-callback', function () { - // TODO: Replace this with your real tests. - test('it works', function (assert) { - let result = contextComponentCallback(); - assert.ok(result); - }); -}); diff --git a/translations/en-us.yaml b/translations/en-us.yaml index 19f39580..90482314 100644 --- a/translations/en-us.yaml +++ b/translations/en-us.yaml @@ -236,6 +236,9 @@ fleet-ops: title: Navigator App name: Instance Linking URL message: Use this URL to link the official Navigator app to this {companyName} instance. Opening this URL on a mobile device will open the Navigator app and update it's configuration and branding. + settings: Entity Settings + select-input: Allow driver to update entity details + visibility-controls: title: Visibility Controls message: Visibility controls allow you to disable sections of Fleet-Ops. Toggle the checkbox to enable or disable sections to hide in Fleet-ops.