Browse Source

UI: Optimize call calculate new layout resize

pull/7868/head
Vladyslav_Prykhodko 3 years ago
parent
commit
85557231a8
  1. 21
      ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

21
ui-ngx/src/app/modules/home/components/dashboard-page/dashboard-page.component.ts

@ -691,23 +691,28 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
public toggleLayouts() {
this.isRightLayoutOpened = !this.isRightLayoutOpened;
this.mobileService.onDashboardRightLayoutChanged(this.isRightLayoutOpened);
this.updateLayoutSizes();
}
public openRightLayout() {
this.isRightLayoutOpened = true;
this.mobileService.onDashboardRightLayoutChanged(this.isRightLayoutOpened);
this.updateLayoutSizes();
}
private updateLayoutSizes() {
let changeMainLayoutSize = false;
let changeRightLayoutSize = false;
if (this.dashboardCtx.state) {
this.updateMainLayoutSize();
this.updateRightLayoutSize();
changeMainLayoutSize = this.updateMainLayoutSize();
changeRightLayoutSize = this.updateRightLayoutSize();
}
if (changeMainLayoutSize || changeRightLayoutSize) {
this.cd.markForCheck();
}
}
private updateMainLayoutSize() {
private updateMainLayoutSize(): boolean {
const prevMainLayoutWidth = this.mainLayoutSize.width;
const prevMainLayoutHeight = this.mainLayoutSize.height;
if (this.isEditingWidget && this.editingLayoutCtx.id === 'main') {
this.mainLayoutSize.width = '100%';
} else {
@ -718,9 +723,12 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} else {
this.mainLayoutSize.height = '0px';
}
return prevMainLayoutWidth !== this.mainLayoutSize.width || prevMainLayoutHeight !== this.mainLayoutSize.height;
}
private updateRightLayoutSize() {
private updateRightLayoutSize(): boolean {
const prevRightLayoutWidth = this.rightLayoutSize.width;
const prevRightLayoutHeight = this.rightLayoutSize.height;
if (this.isEditingWidget && this.editingLayoutCtx.id === 'right') {
this.rightLayoutSize.width = '100%';
} else {
@ -731,6 +739,7 @@ export class DashboardPageComponent extends PageComponent implements IDashboardC
} else {
this.rightLayoutSize.height = '0px';
}
return prevRightLayoutWidth !== this.rightLayoutSize.width || prevRightLayoutHeight !== this.rightLayoutSize.height;
}
private calculateWidth(layout: DashboardLayoutId): string {

Loading…
Cancel
Save