From 00e7779f711a528b00a6ca4f1afd7eb3bb2e655f Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Thu, 23 Apr 2020 13:27:21 +0300 Subject: [PATCH] Minor UI fixes --- .../dashboard/dashboard.component.ts | 2 +- .../date-range-navigator.component.ts | 6 ++-- .../home/models/dashboard-component.models.ts | 3 +- .../json-form/json-form.component.ts | 28 +++++++++++++------ 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts index 6531b3f84f..fdc6569d29 100644 --- a/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts +++ b/ui-ngx/src/app/modules/home/components/dashboard/dashboard.component.ts @@ -492,8 +492,8 @@ export class DashboardComponent extends PageComponent implements IDashboardCompo const parentHeight = this.gridster.el.offsetHeight; if (this.isMobileSize && this.mobileAutofillHeight && parentHeight) { this.updateMobileOpts(parentHeight); - this.notifyGridsterOptionsChanged(); } + this.notifyGridsterOptionsChanged(); } private updateLayoutOpts() { diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts b/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts index b0b86418f1..a0893305e3 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/date-range-navigator/date-range-navigator.component.ts @@ -84,9 +84,6 @@ export class DateRangeNavigatorWidgetComponent extends PageComponent implements } ngOnInit(): void { - this.dashboardTimewindowChangedSubscription = this.ctx.dashboard.dashboardTimewindowChanged.subscribe(() => { - this.widgetContextTimewindowSync(); - }); this.settings = this.ctx.settings; this.settings.useSessionStorage = isDefined(this.settings.useSessionStorage) ? this.settings.useSessionStorage : true; let selection; @@ -110,6 +107,9 @@ export class DateRangeNavigatorWidgetComponent extends PageComponent implements } this.selectedStepSize = this.datesMap[this.settings.stepSize || 'day'].ts; this.widgetContextTimewindowSync(); + this.dashboardTimewindowChangedSubscription = this.ctx.dashboard.dashboardTimewindowChanged.subscribe(() => { + this.widgetContextTimewindowSync(); + }); } ngOnDestroy(): void { diff --git a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts index 5b6fee71c1..768b7fcc52 100644 --- a/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts +++ b/ui-ngx/src/app/modules/home/models/dashboard-component.models.ts @@ -474,7 +474,8 @@ export class DashboardWidget implements GridsterItem, IDashboardWidget { if (mobileHeight) { res = mobileHeight; } else { - res = this.widget.sizeY * 24 / this.dashboard.gridsterOpts.minCols; + const sizeY = this.widgetLayout ? this.widgetLayout.sizeY : this.widget.sizeY; + res = sizeY * 24 / this.dashboard.gridsterOpts.minCols; } } else { if (this.widgetLayout) { diff --git a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts index d7704a2e55..ecd249af60 100644 --- a/ui-ngx/src/app/shared/components/json-form/json-form.component.ts +++ b/ui-ngx/src/app/shared/components/json-form/json-form.component.ts @@ -15,7 +15,6 @@ /// import { - ChangeDetectionStrategy, Component, ElementRef, forwardRef, @@ -106,6 +105,8 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato private propagateChange = null; private propagateChangePending = false; + private writingValue = false; + private updateViewPending = false; constructor(public elementRef: ElementRef, private translate: TranslateService, @@ -143,6 +144,7 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato } writeValue(data: JsonFormComponentData): void { + this.writingValue = true; this.data = data; this.schema = this.data && this.data.schema ? deepClone(this.data.schema) : { type: 'object' @@ -154,19 +156,29 @@ export class JsonFormComponent implements OnInit, ControlValueAccessor, Validato this.model = inspector.sanitize(this.schema, this.model).data; this.updateAndRender(); this.isModelValid = this.validateModel(); - if (!this.isModelValid) { + this.writingValue = false; + if (!this.isModelValid || this.updateViewPending) { this.updateView(); } } updateView() { - if (this.data) { - this.data.model = this.model; - if (this.propagateChange) { - this.propagateChange(this.data); - } else { - this.propagateChangePending = true; + if (!this.writingValue) { + this.updateViewPending = false; + if (this.data) { + this.data.model = this.model; + if (this.propagateChange) { + try { + this.propagateChange(this.data); + } catch (e) { + this.propagateChangePending = true; + } + } else { + this.propagateChangePending = true; + } } + } else { + this.updateViewPending = true; } }