Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
upgraded fleetops-data; fixed custom fields and custom field value models; patch notification model
Ronald A. Richardson4a59318feb1f
diff --git a/console/app/models/custom-field-value.js b/console/app/models/custom-field-value.jsnew file mode 100644index 00000000..c253404a--- /dev/null+++ b/console/app/models/custom-field-value.js@@ -0,0 +1,54 @@+import Model, { attr } from '@ember-data/model';+import { computed } from '@ember/object';+import { getOwner } from '@ember/application';+import { format, formatDistanceToNow } from 'date-fns';++function isValidFileObjectJson(str) {+ return typeof str === 'string' && str.startsWith('{') && str.endsWith('}');+}++export default class CustomFieldValueModel extends Model {+ /** @ids */+ @attr('string') company_uuid;+ @attr('string') custom_field_uuid;+ @attr('string') subject_uuid;+ @attr('string') subject_type;++ /** @attributes */+ @attr('string') value;+ @attr('string') value_type;++ /** @dates */+ @attr('date') created_at;+ @attr('date') updated_at;+ @attr('date') deleted_at;++ /** @computed */+ @computed('value') get asFile() {+ const owner = getOwner(this);+ const fetch = owner.lookup(`service:fetch`);+ const value = this.value;+ if (!isValidFileObjectJson(value)) {+ return null;+ }++ const fileModel = fetch.jsonToModel(value, 'file');+ return fileModel;+ }++ @computed('created_at') get createdAgo() {+ return formatDistanceToNow(this.created_at);+ }++ @computed('created_at') get createdAt() {+ return format(this.created_at, 'PPP p');+ }++ @computed('updated_at') get updatedAgo() {+ return formatDistanceToNow(this.updated_at);+ }++ @computed('updated_at') get updatedAt() {+ return format(this.updated_at, 'PPP p');+ }+}diff --git a/console/app/models/custom-field.js b/console/app/models/custom-field.jsindex 26d6b0ba..d39bc130 100644--- a/console/app/models/custom-field.js+++ b/console/app/models/custom-field.js@@ -1,4 +1,4 @@-import Model, { attr, belongsTo, hasMany } from '@ember-data/model';+import Model, { attr } from '@ember-data/model';import { computed } from '@ember/object';import { format, formatDistanceToNow } from 'date-fns';@@ -19,6 +19,7 @@ export default class CustomFieldModel extends Model {@attr('string') default_value;@attr('number') order;@attr('boolean') required;+ @attr('boolean', { defaultValue: true }) editable;@attr('raw') options;@attr('raw') validation_rules;@attr('raw') meta;diff --git a/console/app/models/notification.js b/console/app/models/notification.jsindex d68e4c4d..ca64926d 100644--- a/console/app/models/notification.js+++ b/console/app/models/notification.js@@ -1,6 +1,5 @@import Model, { attr } from '@ember-data/model';import { computed } from '@ember/object';-import { format, formatDistanceToNow } from 'date-fns';export default class NotificationModel extends Model {diff --git a/console/config/environment.js b/console/config/environment.jsindex 2594908f..e3f14e62 100644--- a/console/config/environment.js+++ b/console/config/environment.js@@ -63,6 +63,11 @@ module.exports = function (environment) {keyDelimiter: '/',includeEmberDataSupport: true,},++ 'ember-cli-notifications': {+ autoClear: true,+ clearDuration: 1000 * 3.5,+ },};if (environment === 'development') {diff --git a/console/tests/unit/models/custom-field-value-test.js b/console/tests/unit/models/custom-field-value-test.jsnew file mode 100644index 00000000..a8be2964--- /dev/null+++ b/console/tests/unit/models/custom-field-value-test.js@@ -0,0 +1,14 @@+import { module, test } from 'qunit';++import { setupTest } from '@fleetbase/console/tests/helpers';++module('Unit | Model | custom field value', function (hooks) {+ setupTest(hooks);++ // Replace this with your real tests.+ test('it exists', function (assert) {+ let store = this.owner.lookup('service:store');+ let model = store.createRecord('custom-field-value', {});+ assert.ok(model);+ });+});diff --git a/console/translations/en-us.yaml b/console/translations/en-us.yamlindex 387dba97..dedce22e 100644--- a/console/translations/en-us.yaml+++ b/console/translations/en-us.yaml@@ -60,6 +60,7 @@ common:users: Userschangelog: Changelogok: OK+ select-file: Select Filecomponent:file:dropdown-label: File actionsdiff --git a/packages/fleetops-data b/packages/fleetops-dataindex 9d92927c..b5ba2a31 160000--- a/packages/fleetops-data+++ b/packages/fleetops-data@@ -1 +1 @@-Subproject commit 9d92927c9b8c44d6e52e5025034deb162adaa4c3+Subproject commit b5ba2a311c14907257c4c6bff932eee08b4fca4b