From 489bced2defaad4015362047a1dbe0da7e836a0f Mon Sep 17 00:00:00 2001 From: Dmitriymush Date: Tue, 14 Nov 2023 15:33:55 +0200 Subject: [PATCH] UI: dashboard redesing editions after review --- .../dashboard/dashboard-form.component.html | 17 ++++++++--------- .../dashboard/dashboard-form.component.scss | 6 ------ .../pages/dashboard/dashboard-form.component.ts | 8 ++++++-- .../dashboards-table-config.resolver.ts | 5 +++-- .../src/app/shared/models/dashboard.models.ts | 5 ++++- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html index a8ce642865..86acb4a093 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.html @@ -124,16 +124,15 @@ -
- {{ 'dashboard.assigned-customers' | translate }} - - -
-
+ + +
dashboard.mobile-app-settings
- + {{ 'dashboard.mobile-hide' | translate }} diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.scss b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.scss index 0226d68910..66df772d2d 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.scss +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.scss @@ -14,11 +14,5 @@ * limitations under the License. */ :host { - .tb-form-panel.stroked { - gap: 0; - .mat-slide.fixed-title-width { - margin: 16px 0; - } - } } diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts index 88c1dd5b0f..3da09f84c8 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboard-form.component.ts @@ -80,13 +80,12 @@ export class DashboardFormComponent extends EntityComponent { buildForm(entity: Dashboard): UntypedFormGroup { this.updateFields(entity); - return this.fb.group( + const form = this.fb.group( { title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]], image: [entity ? entity.image : null], mobileHide: [entity ? entity.mobileHide : false], mobileOrder: [entity ? entity.mobileOrder : null, [Validators.pattern(/^-?[0-9]+$/)]], - assignedCustomerIds: [[]], configuration: this.fb.group( { description: [entity && entity.configuration ? entity.configuration.description : ''], @@ -94,6 +93,11 @@ export class DashboardFormComponent extends EntityComponent { ) } ); + if (this.isAdd) { + form.addControl('assignedCustomerIds', this.fb.control([])); + } + + return form; } updateForm(entity: Dashboard) { diff --git a/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts index 2ec3cf54d8..9238ac4244 100644 --- a/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/dashboard/dashboards-table-config.resolver.ts @@ -47,6 +47,7 @@ import { import { Dashboard, DashboardInfo, + DashboardSetup, getDashboardAssignedCustomersText, isCurrentPublicDashboardCustomer, isPublicDashboard @@ -103,7 +104,7 @@ export class DashboardsTableConfigResolver implements Resolve this.translate.instant('dashboard.delete-dashboards-text'); this.config.loadEntity = id => this.dashboardService.getDashboard(id.id); - this.config.saveEntity = dashboard => this.saveAndAssignDashboard(dashboard as Dashboard); + this.config.saveEntity = dashboard => this.saveAndAssignDashboard(dashboard as DashboardSetup); this.config.onEntityAction = action => this.onDashboardAction(action); this.config.detailsReadonly = () => (this.config.componentsData.dashboardScope === 'customer_user' || this.config.componentsData.dashboardScope === 'edge_customer_user'); @@ -645,7 +646,7 @@ export class DashboardsTableConfigResolver implements Resolve { + saveAndAssignDashboard(dashboard: DashboardSetup): Observable { const {assignedCustomerIds, ...dashboardToCreate} = dashboard; return this.dashboardService.saveDashboard(dashboardToCreate as Dashboard).pipe( diff --git a/ui-ngx/src/app/shared/models/dashboard.models.ts b/ui-ngx/src/app/shared/models/dashboard.models.ts index e4cf4e35b9..8ccff354a7 100644 --- a/ui-ngx/src/app/shared/models/dashboard.models.ts +++ b/ui-ngx/src/app/shared/models/dashboard.models.ts @@ -126,7 +126,6 @@ export interface DashboardConfiguration { export interface Dashboard extends DashboardInfo { configuration?: DashboardConfiguration; dialogRef?: MatDialogRef; - assignedCustomerIds?: Array; } export interface HomeDashboard extends Dashboard { @@ -138,6 +137,10 @@ export interface HomeDashboardInfo { hideDashboardToolbar: boolean; } +export interface DashboardSetup extends Dashboard { + assignedCustomerIds?: Array; +} + export const isPublicDashboard = (dashboard: DashboardInfo): boolean => { if (dashboard && dashboard.assignedCustomers) { return dashboard.assignedCustomers