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
Fix widget position update bug
Turtuvshindc2b4e1aee9c
diff --git a/console/app/components/dashboard.hbs b/console/app/components/dashboard.hbsindex 5c241bb1..802ed556 100644--- a/console/app/components/dashboard.hbs+++ b/console/app/components/dashboard.hbs@@ -88,7 +88,7 @@@isOpen={{this.dashboard.isAddingWidget}}@onLoad={{this.setWidgetSelectorPanelContext}}@dashboard={{this.dashboard.currentDashboard}}- @onClose={{fn this.onChangeEdit false}}+ @onClose={{fn this.onAddingWidget false}}/></EmberWormhole>{{/if}}diff --git a/console/app/components/dashboard.js b/console/app/components/dashboard.jsindex 2633fec7..7bb0a2c8 100644--- a/console/app/components/dashboard.js+++ b/console/app/components/dashboard.js@@ -78,7 +78,7 @@ export default class DashboardComponent extends Component {this.dashboard.onChangeEdit(state);}- onAddingWidget(state = true) {+ @action onAddingWidget(state = true) {this.dashboard.onAddingWidget(state);}}diff --git a/console/app/components/dashboard/create.js b/console/app/components/dashboard/create.jsindex 40c71bb6..b0326af6 100644--- a/console/app/components/dashboard/create.js+++ b/console/app/components/dashboard/create.js@@ -22,6 +22,14 @@ export default class DashboardCreateComponent extends Component {'dashboard: ',this.args.dashboard.widgets.map((widget) => widget.serialize()));+ const widgetEvent = event.detail[0];+ const changedWidget = this.args.dashboard.widgets.find((widget) => widget.id === widgetEvent.id);++ if (changedWidget) {+ const { id, x, y, w, h } = widgetEvent;+ changedWidget.grid_options = { x, y, w, h };+ changedWidget.updatePosition({ id, x, y, h, w });+ }}@action removeWidget(widget) {diff --git a/console/app/components/dashboard/widget-panel.js b/console/app/components/dashboard/widget-panel.jsindex 3b04558a..2a5b68a7 100644--- a/console/app/components/dashboard/widget-panel.js+++ b/console/app/components/dashboard/widget-panel.js@@ -9,7 +9,7 @@ export default class DashboardWidgetPanelComponent extends Component {@tracked dashboard;@tracked isOpen = true;@service notifications;-+/*** Constructs the component and applies initial state.*/diff --git a/console/app/models/dashboard-widget.js b/console/app/models/dashboard-widget.jsindex 9214a2a5..6f02552a 100644--- a/console/app/models/dashboard-widget.js+++ b/console/app/models/dashboard-widget.js@@ -1,6 +1,7 @@import Model, { attr, belongsTo } from '@ember-data/model';import { computed } from '@ember/object';import { format, formatDistanceToNow } from 'date-fns';+import { getOwner } from '@ember/application';export default class DashboardWidgetModel extends Model {/** @ids */@@ -44,4 +45,10 @@ export default class DashboardWidgetModel extends Model {@computed('created_at') get createdAtShort() {return format(this.created_at, 'PP');}++ updatePosition() {+ this.save().then((response) => {+ console.log('Widget updated successfully.', response);+ });+ }}diff --git a/console/app/models/dashboard.js b/console/app/models/dashboard.jsindex c7a54d10..2defac09 100644--- a/console/app/models/dashboard.js+++ b/console/app/models/dashboard.js@@ -86,17 +86,4 @@ export default class DashboardModel extends Model {});}}-- updateWidget(widget) {- const owner = getOwner(this);- const store = owner.lookup('service:store');-- const widgetRecord = store.findRecord('dashboard-widget', widget.id);- if (widgetRecord) {- widgetRecord.set('grid_options', widget.grid_options);- widgetRecord.save().then((post) => {- console.log('Post updated successfully.');- });- }- }}