Skip to content

Commit

Permalink
feature(assetState): #535 deactivate asPlanned Buttons and show corre…
Browse files Browse the repository at this point in the history
…ct tooltip messages
  • Loading branch information
ds-mmaul committed Jan 23, 2024
1 parent 9458b2c commit cc74a2d
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
[tableHeader]='"page.asBuiltParts" | i18n'
(filterActivated)="filterActivated(true, $event )"
[tableType]="TableType.AS_BUILT_CUSTOMER"
[mainAspectType]="bomLifecycle"
></app-parts-table>
</ng-template>
</div>
Expand All @@ -64,6 +65,7 @@
[multiSortList]="tableCustomerAsPlannedSortList"
(filterActivated)="filterActivated(false, $event )"
[tableType]="TableType.AS_PLANNED_CUSTOMER"
[mainAspectType]="bomLifecycle"
></app-parts-table>
</ng-template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
[multiSortList]="tableSupplierAsBuiltSortList"
(filterActivated)="filterActivated(true, $event )"
[tableType]="TableType.AS_BUILT_SUPPLIER"
[mainAspectType]="bomLifecycle"
></app-parts-table>
</ng-template>
</div>
Expand Down Expand Up @@ -75,6 +76,7 @@
[multiSortList]="tableSupplierAsPlannedSortList"
(filterActivated)="filterActivated(false, $event )"
[tableType]="TableType.AS_PLANNED_SUPPLIER"
[mainAspectType]="bomLifecycle"
></app-parts-table>
</ng-template>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
[multiSortList]="tableAsBuiltSortList"
[tableHeader]='"page.asBuiltParts" | i18n'
[tableType]="TableType.AS_BUILT_OWN"
[mainAspectType]="MainAspectType.AS_BUILT"
></app-parts-table>
</ng-template>
</div>
Expand All @@ -115,6 +116,7 @@
[multiSortList]="tableAsPlannedSortList"
[tableHeader]='"page.asPlannedParts" | i18n'
[tableType]="TableType.AS_PLANNED_OWN"
[mainAspectType]="MainAspectType.AS_PLANNED"
></app-parts-table>

</ng-template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@
<p
class="regular-text table&#45;&#45;selected&#45;&#45;label">{{ selectedPartsInfoLabel | i18n : {count: selection?.selected?.length || 0} }}</p>
<div class="table--header--select--button"
matTooltip="{{'routing.unauthorized' | i18n}}"
matTooltip="{{mainAspectType === MainAspectType.AS_PLANNED ? 'routing.notAllowedForAsPlanned' : 'routing.unauthorized' | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
[matTooltipDisabled]="roleService.hasAccess(['user','supervisor'])"
[matTooltipDisabled]="roleService.hasAccess(['user','supervisor']) && mainAspectType === MainAspectType.AS_BUILT"
>
<app-button
*ngIf="selection?.selected?.length && (tableType !== TableType.AS_PLANNED_CUSTOMER && tableType !== TableType.AS_BUILT_CUSTOMER)"
*ngIf="selection?.selected?.length"
(click)="clickSelectAction.emit()"
[variant]="'raised'"
[color]="'accent'"
[isDisabled]="!roleService.hasAccess(['user','supervisor'])"
[isDisabled]="!roleService.hasAccess(['user','supervisor']) || mainAspectType === MainAspectType.AS_PLANNED"
>
<div class="flex justify-between items-center text-dark p-0.5">
<mat-icon class="mr-2">announcement</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import {SelectionModel} from '@angular/cdk/collections';
import { SelectionModel } from '@angular/cdk/collections';
import {
Component,
ElementRef,
Expand All @@ -29,46 +29,37 @@ import {
ViewChild,
ViewChildren,
} from '@angular/core';
import {FormGroup} from '@angular/forms';
import {MatDialog, MatDialogConfig} from '@angular/material/dialog';
import {MatPaginator, PageEvent} from '@angular/material/paginator';
import {MatSort, Sort} from '@angular/material/sort';
import {MatTableDataSource} from '@angular/material/table';
import {Router} from '@angular/router';
import {EmptyPagination, Pagination} from '@core/model/pagination.model';
import {RoleService} from '@core/user/role.service';
import {TableSettingsService} from '@core/user/table-settings.service';
import {
MultiSelectAutocompleteComponent
} from '@shared/components/multi-select-autocomplete/multi-select-autocomplete.component';
import {TableType} from '@shared/components/multi-select-autocomplete/table-type.model';
import {PartsAsBuiltConfigurationModel} from '@shared/components/parts-table/parts-as-built-configuration.model';
import {
PartsAsBuiltCustomerConfigurationModel
} from '@shared/components/parts-table/parts-as-built-customer-configuration.model';
import {
PartsAsBuiltSupplierConfigurationModel
} from '@shared/components/parts-table/parts-as-built-supplier-configuration.model';
import {PartsAsPlannedConfigurationModel} from '@shared/components/parts-table/parts-as-planned-configuration.model';
import {
PartsAsPlannedCustomerConfigurationModel
} from '@shared/components/parts-table/parts-as-planned-customer-configuration.model';
import {
PartsAsPlannedSupplierConfigurationModel
} from '@shared/components/parts-table/parts-as-planned-supplier-configuration.model';
import {TableViewConfig} from '@shared/components/parts-table/table-view-config.model';
import {TableSettingsComponent} from '@shared/components/table-settings/table-settings.component';
import { FormGroup } from '@angular/forms';
import { MatDialog, MatDialogConfig } from '@angular/material/dialog';
import { MatPaginator, PageEvent } from '@angular/material/paginator';
import { MatSort, Sort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { Router } from '@angular/router';
import { EmptyPagination, Pagination } from '@core/model/pagination.model';
import { RoleService } from '@core/user/role.service';
import { TableSettingsService } from '@core/user/table-settings.service';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { MultiSelectAutocompleteComponent } from '@shared/components/multi-select-autocomplete/multi-select-autocomplete.component';
import { TableType } from '@shared/components/multi-select-autocomplete/table-type.model';
import { PartsAsBuiltConfigurationModel } from '@shared/components/parts-table/parts-as-built-configuration.model';
import { PartsAsBuiltCustomerConfigurationModel } from '@shared/components/parts-table/parts-as-built-customer-configuration.model';
import { PartsAsBuiltSupplierConfigurationModel } from '@shared/components/parts-table/parts-as-built-supplier-configuration.model';
import { PartsAsPlannedConfigurationModel } from '@shared/components/parts-table/parts-as-planned-configuration.model';
import { PartsAsPlannedCustomerConfigurationModel } from '@shared/components/parts-table/parts-as-planned-customer-configuration.model';
import { PartsAsPlannedSupplierConfigurationModel } from '@shared/components/parts-table/parts-as-planned-supplier-configuration.model';
import { TableViewConfig } from '@shared/components/parts-table/table-view-config.model';
import { TableSettingsComponent } from '@shared/components/table-settings/table-settings.component';
import {
CreateHeaderFromColumns,
TableConfig,
TableEventConfig,
TableHeaderSort,
} from '@shared/components/table/table.model';
import {ToastService} from '@shared/components/toasts/toast.service';
import {isDateFilter} from '@shared/helper/filter-helper';
import {addSelectedValues, removeSelectedValues} from '@shared/helper/table-helper';
import {NotificationColumn} from '@shared/model/notification.model';
import {DeeplinkService} from '@shared/service/deeplink.service';
import { ToastService } from '@shared/components/toasts/toast.service';
import { isDateFilter } from '@shared/helper/filter-helper';
import { addSelectedValues, removeSelectedValues } from '@shared/helper/table-helper';
import { NotificationColumn } from '@shared/model/notification.model';
import { DeeplinkService } from '@shared/service/deeplink.service';


@Component({
Expand All @@ -93,6 +84,7 @@ export class PartsTableComponent implements OnInit {
@Input() multiSortList: TableHeaderSort[];

@Input() tableType: TableType;
@Input() mainAspectType: MainAspectType;

public tableConfig: TableConfig;

Expand Down Expand Up @@ -218,7 +210,7 @@ export class PartsTableComponent implements OnInit {
this.filterFormGroup.valueChanges.subscribe((formValues) => {
this.filterActivated.emit(formValues);
});

console.log(this.mainAspectType)
}


Expand Down Expand Up @@ -362,4 +354,5 @@ export class PartsTableComponent implements OnInit {
}

protected readonly TableType = TableType;
protected readonly MainAspectType = MainAspectType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@
</mat-expansion-panel>

<mat-expansion-panel *ngIf="showStartInvestigation"
[disabled]="!(selectedPartDetails$ | async)?.data?.children?.length || roleService.isAdmin()"
matTooltip="{{'routing.unauthorized' | i18n}}"
[disabled]="!(selectedPartDetails$ | async)?.data?.children?.length || roleService.isAdmin() || isAsPlannedPart"
matTooltip="{{ authorizationTooltipMessage | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
[matTooltipDisabled]="!roleService.isAdmin()"
[matTooltipDisabled]="!roleService.isAdmin() && !isAsPlannedPart && (selectedPartDetails$ | async)?.data?.children?.length > 0"
>
<mat-expansion-panel-header>
<mat-panel-title>{{ 'partDetail.investigation.tab.header' | i18n }}</mat-panel-title>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export class PartDetailComponent implements AfterViewInit, OnDestroy {

public readonly displayedColumns: string[];

public isAsPlannedPart: boolean;

public customerOrPartSiteDetailsHeader$: Subscription;
public customerOrPartSiteHeader: string;

Expand All @@ -65,13 +67,19 @@ export class PartDetailComponent implements AfterViewInit, OnDestroy {

private readonly isOpenState: State<boolean> = new State<boolean>(false);

public authorizationTooltipMessage: string;

constructor(private readonly partDetailsFacade: PartDetailsFacade, private readonly router: Router, public roleService: RoleService) {
this.isOpen$ = this.isOpenState.observable;

this.selectedPartDetails$ = this.partDetailsFacade.selectedPart$;
this.shortenPartDetails$ = this.partDetailsFacade.selectedPart$.pipe(
PartsAssembler.mapPartForView(),
tap(({ data }) => this.qualityTypeControl.patchValue(data.qualityType, { emitEvent: false, onlySelf: true })),
tap(({ data }) => {
this.qualityTypeControl.patchValue(data.qualityType, { emitEvent: false, onlySelf: true })
this.isAsPlannedPart = data.semanticDataModel.toString() === 'PartAsPlanned';
console.log(this.isAsPlannedPart);
}),
);

this.manufacturerDetails$ = this.partDetailsFacade.selectedPart$.pipe(PartsAssembler.mapPartForManufacturerView());
Expand All @@ -95,6 +103,15 @@ export class PartDetailComponent implements AfterViewInit, OnDestroy {
label: value,
value: value,
}));

this.selectedPartDetails$.subscribe(part => {
if(part?.data?.children?.length > 0 ) {
this.authorizationTooltipMessage = this.getRestrictionMessageKey(true);
} else {
this.authorizationTooltipMessage = this.getRestrictionMessageKey(false);
}
});

this.displayedColumns = [ 'position', 'productType', 'tractionBatteryCode' ];
}

Expand All @@ -119,6 +136,23 @@ export class PartDetailComponent implements AfterViewInit, OnDestroy {
this.router.navigate([ `parts/relations/${ part.id }` ]).then(_ => window.location.reload());
}

getRestrictionMessageKey(hasChildren: boolean): string {
if(this.isAsPlannedPart) {
return 'routing.notAllowedForAsPlanned';
}

else if(!hasChildren) {
return 'routing.noChildPartsForInvestigation';
}

else if(this.roleService.isAdmin()) {
return 'routing.unauthorized';
} else {
return null;
}

}

protected readonly NotificationAction = NotificationAction;
protected readonly Owner = Owner;
}

0 comments on commit cc74a2d

Please sign in to comment.