UI: dashboard redesing editions after review

This commit is contained in:
Dmitriymush 2023-11-14 15:33:55 +02:00
parent 7f2bbf2a7d
commit 489bced2de
5 changed files with 21 additions and 20 deletions

View File

@ -124,16 +124,15 @@
<textarea matInput formControlName="description" rows="2"></textarea> <textarea matInput formControlName="description" rows="2"></textarea>
</mat-form-field> </mat-form-field>
</div> </div>
<div fxLayout="column" [fxShow]="isAdd"> <tb-entity-list
<span>{{ 'dashboard.assigned-customers' | translate }}</span> [fxShow]="isAdd"
<tb-entity-list formControlName="assignedCustomerIds"
formControlName="assignedCustomerIds" labelText="{{ 'dashboard.assigned-customers' | translate }}"
[entityType]="entityType.CUSTOMER"> [entityType]="entityType.CUSTOMER">
</tb-entity-list> </tb-entity-list>
</div> <div class="tb-form-panel stroked no-gap">
<div class="tb-form-panel stroked">
<div class="tb-form-panel-title" translate>dashboard.mobile-app-settings</div> <div class="tb-form-panel-title" translate>dashboard.mobile-app-settings</div>
<mat-slide-toggle formControlName="mobileHide" class="mat-slide fixed-title-width"> <mat-slide-toggle formControlName="mobileHide" class="mat-slide margin fixed-title-width">
{{ 'dashboard.mobile-hide' | translate }} {{ 'dashboard.mobile-hide' | translate }}
</mat-slide-toggle> </mat-slide-toggle>
<mat-form-field class="mat-block"> <mat-form-field class="mat-block">

View File

@ -14,11 +14,5 @@
* limitations under the License. * limitations under the License.
*/ */
:host { :host {
.tb-form-panel.stroked {
gap: 0;
.mat-slide.fixed-title-width {
margin: 16px 0;
}
}
} }

View File

@ -80,13 +80,12 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> {
buildForm(entity: Dashboard): UntypedFormGroup { buildForm(entity: Dashboard): UntypedFormGroup {
this.updateFields(entity); this.updateFields(entity);
return this.fb.group( const form = this.fb.group(
{ {
title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]], title: [entity ? entity.title : '', [Validators.required, Validators.maxLength(255)]],
image: [entity ? entity.image : null], image: [entity ? entity.image : null],
mobileHide: [entity ? entity.mobileHide : false], mobileHide: [entity ? entity.mobileHide : false],
mobileOrder: [entity ? entity.mobileOrder : null, [Validators.pattern(/^-?[0-9]+$/)]], mobileOrder: [entity ? entity.mobileOrder : null, [Validators.pattern(/^-?[0-9]+$/)]],
assignedCustomerIds: [[]],
configuration: this.fb.group( configuration: this.fb.group(
{ {
description: [entity && entity.configuration ? entity.configuration.description : ''], description: [entity && entity.configuration ? entity.configuration.description : ''],
@ -94,6 +93,11 @@ export class DashboardFormComponent extends EntityComponent<Dashboard> {
) )
} }
); );
if (this.isAdd) {
form.addControl('assignedCustomerIds', this.fb.control([]));
}
return form;
} }
updateForm(entity: Dashboard) { updateForm(entity: Dashboard) {

View File

@ -47,6 +47,7 @@ import {
import { import {
Dashboard, Dashboard,
DashboardInfo, DashboardInfo,
DashboardSetup,
getDashboardAssignedCustomersText, getDashboardAssignedCustomersText,
isCurrentPublicDashboardCustomer, isCurrentPublicDashboardCustomer,
isPublicDashboard isPublicDashboard
@ -103,7 +104,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
this.config.deleteEntitiesContent = () => this.translate.instant('dashboard.delete-dashboards-text'); this.config.deleteEntitiesContent = () => this.translate.instant('dashboard.delete-dashboards-text');
this.config.loadEntity = id => this.dashboardService.getDashboard(id.id); 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.onEntityAction = action => this.onDashboardAction(action);
this.config.detailsReadonly = () => (this.config.componentsData.dashboardScope === 'customer_user' || this.config.detailsReadonly = () => (this.config.componentsData.dashboardScope === 'customer_user' ||
this.config.componentsData.dashboardScope === 'edge_customer_user'); this.config.componentsData.dashboardScope === 'edge_customer_user');
@ -645,7 +646,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
); );
} }
saveAndAssignDashboard(dashboard: Dashboard): Observable<Dashboard> { saveAndAssignDashboard(dashboard: DashboardSetup): Observable<Dashboard> {
const {assignedCustomerIds, ...dashboardToCreate} = dashboard; const {assignedCustomerIds, ...dashboardToCreate} = dashboard;
return this.dashboardService.saveDashboard(dashboardToCreate as Dashboard).pipe( return this.dashboardService.saveDashboard(dashboardToCreate as Dashboard).pipe(

View File

@ -126,7 +126,6 @@ export interface DashboardConfiguration {
export interface Dashboard extends DashboardInfo { export interface Dashboard extends DashboardInfo {
configuration?: DashboardConfiguration; configuration?: DashboardConfiguration;
dialogRef?: MatDialogRef<any>; dialogRef?: MatDialogRef<any>;
assignedCustomerIds?: Array<string>;
} }
export interface HomeDashboard extends Dashboard { export interface HomeDashboard extends Dashboard {
@ -138,6 +137,10 @@ export interface HomeDashboardInfo {
hideDashboardToolbar: boolean; hideDashboardToolbar: boolean;
} }
export interface DashboardSetup extends Dashboard {
assignedCustomerIds?: Array<string>;
}
export const isPublicDashboard = (dashboard: DashboardInfo): boolean => { export const isPublicDashboard = (dashboard: DashboardInfo): boolean => {
if (dashboard && dashboard.assignedCustomers) { if (dashboard && dashboard.assignedCustomers) {
return dashboard.assignedCustomers return dashboard.assignedCustomers