Browse Source

UI: Added sort breakpoint in layout configuration and fix translation

pull/11430/head
Vladyslav_Prykhodko 2 years ago
parent
commit
367fe1b2e7
  1. 22
      ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts
  2. 5
      ui-ngx/src/app/modules/home/components/dashboard-page/layout/select-dashboard-breakpoint.component.ts
  3. 2
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts
  4. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

22
ui-ngx/src/app/modules/home/components/dashboard-page/layout/manage-dashboard-layouts-dialog.component.ts

@ -208,6 +208,8 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag
.filter((item) => !this.selectedBreakpointIds.includes(item.id)) .filter((item) => !this.selectedBreakpointIds.includes(item.id))
.map(item => item.id); .map(item => item.id);
this.sortLayoutBreakpoints();
this.subscriptions.push( this.subscriptions.push(
this.layoutsFormGroup.get('sliderPercentage').valueChanges this.layoutsFormGroup.get('sliderPercentage').valueChanges
.subscribe( .subscribe(
@ -456,6 +458,7 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag
this.layoutBreakpoints = this.layoutBreakpoints.filter((item) => item.breakpoint !== breakpointId); this.layoutBreakpoints = this.layoutBreakpoints.filter((item) => item.breakpoint !== breakpointId);
this.allowBreakpointIds.push(breakpointId); this.allowBreakpointIds.push(breakpointId);
this.selectedBreakpointIds = this.selectedBreakpointIds.filter((item) => item !== breakpointId); this.selectedBreakpointIds = this.selectedBreakpointIds.filter((item) => item !== breakpointId);
this.sortLayoutBreakpoints();
this.layoutsFormGroup.markAsDirty(); this.layoutsFormGroup.markAsDirty();
} }
} }
@ -495,6 +498,7 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag
this.selectedBreakpointIds.push(newBreakpointId); this.selectedBreakpointIds.push(newBreakpointId);
this.allowBreakpointIds = this.allowBreakpointIds.filter((item) => item !== newBreakpointId); this.allowBreakpointIds = this.allowBreakpointIds.filter((item) => item !== newBreakpointId);
this.addLayoutConfiguration(newBreakpointId); this.addLayoutConfiguration(newBreakpointId);
this.sortLayoutBreakpoints();
} }
private addLayoutConfiguration(breakpointId: BreakpointId) { private addLayoutConfiguration(breakpointId: BreakpointId) {
@ -508,4 +512,22 @@ export class ManageDashboardLayoutsDialogComponent extends DialogComponent<Manag
breakpoint: breakpointId breakpoint: breakpointId
}); });
} }
private sortLayoutBreakpoints() {
this.layoutBreakpoints.sort((a, b) => {
const aMaxWidth = this.dashboardUtils.getBreakpointInfoById(a.breakpoint)?.maxWidth || Infinity;
const bMaxWidth = this.dashboardUtils.getBreakpointInfoById(b.breakpoint)?.maxWidth || Infinity;
return bMaxWidth - aMaxWidth;
});
this.selectedBreakpointIds.sort((a, b) => {
const aMaxWidth = this.dashboardUtils.getBreakpointInfoById(a)?.maxWidth || Infinity;
const bMaxWidth = this.dashboardUtils.getBreakpointInfoById(b)?.maxWidth || Infinity;
return bMaxWidth - aMaxWidth;
});
this.allowBreakpointIds.sort((a, b) => {
const aMaxWidth = this.dashboardUtils.getBreakpointInfoById(a)?.maxWidth || Infinity;
const bMaxWidth = this.dashboardUtils.getBreakpointInfoById(b)?.maxWidth || Infinity;
return bMaxWidth - aMaxWidth;
});
}
} }

5
ui-ngx/src/app/modules/home/components/dashboard-page/layout/select-dashboard-breakpoint.component.ts

@ -43,6 +43,11 @@ export class SelectDashboardBreakpointComponent implements OnInit, OnDestroy {
this.layoutDataChanged$ = this.dashboardCtrl.layouts.main.layoutCtx.layoutDataChanged.subscribe(() => { this.layoutDataChanged$ = this.dashboardCtrl.layouts.main.layoutCtx.layoutDataChanged.subscribe(() => {
if (this.dashboardCtrl.layouts.main.layoutCtx.layoutData) { if (this.dashboardCtrl.layouts.main.layoutCtx.layoutData) {
this.breakpointIds = Object.keys(this.dashboardCtrl.layouts.main.layoutCtx?.layoutData); this.breakpointIds = Object.keys(this.dashboardCtrl.layouts.main.layoutCtx?.layoutData);
this.breakpointIds.sort((a, b) => {
const aMaxWidth = this.dashboardUtils.getBreakpointInfoById(a)?.maxWidth || Infinity;
const bMaxWidth = this.dashboardUtils.getBreakpointInfoById(b)?.maxWidth || Infinity;
return bMaxWidth - aMaxWidth;
});
if (this.breakpointIds.indexOf(this.dashboardCtrl.layouts.main.layoutCtx.breakpoint) > -1) { if (this.breakpointIds.indexOf(this.dashboardCtrl.layouts.main.layoutCtx.breakpoint) > -1) {
this.selectedBreakpoint = this.dashboardCtrl.layouts.main.layoutCtx.breakpoint; this.selectedBreakpoint = this.dashboardCtrl.layouts.main.layoutCtx.breakpoint;
} else { } else {

2
ui-ngx/src/app/modules/home/components/widget/widget-config.component.ts

@ -354,7 +354,7 @@ export class WidgetConfigComponent extends PageComponent implements OnInit, OnDe
{ {
name: this.isDefaultBreakpoint name: this.isDefaultBreakpoint
? this.translate.instant('widget-config.mobile') ? this.translate.instant('widget-config.mobile')
: this.translate.instant('widget-config.list-option'), : this.translate.instant('widget-config.layout-option'),
value: 'mobile' value: 'mobile'
} }
); );

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -5968,7 +5968,7 @@
"color": "Color", "color": "Color",
"tooltip": "Tooltip", "tooltip": "Tooltip",
"units-required": "Unit is required.", "units-required": "Unit is required.",
"list-option": "List option" "layout-option": "Layout option"
}, },
"widget-type": { "widget-type": {
"import": "Import widget type", "import": "Import widget type",

Loading…
Cancel
Save