Skip to content

Commit

Permalink
Merge branch 'main' into chore/#985-fe-contract-reference
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-mwesener authored Jun 28, 2024
2 parents 939f35d + f7c1298 commit e80b7dd
Show file tree
Hide file tree
Showing 29 changed files with 327 additions and 65 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #1037 extended autocomplete api by contractAgreementId
- #985 Added function to save Contracts based on notification contractAgreementIds into the database
- #985 Added function to filter notifications for contractAgreementIds
- #786 Added authorization as admin for submodel api & registry api

### Added
- #832 added policymanagement list view, creator and editor
Expand All @@ -25,6 +26,7 @@ _**For better traceability add the corresponding GitHub issue number in each cha
- #915 Added section to documentation: EDC-BPN configuration
- #1037 Added link from contracts view to the corresponding filtered part table view
- #985 Added reference to part/notification under contract
- #786 Added icons on part table to let admin reload registry / sync assets via IRS

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="1000"
[style.cursor]="'not-allowed'"
(mouseenter)="shouldMarkAsTouched.next(true)"
>
<app-button
onkeydown="clickedSave()"
Expand All @@ -59,6 +60,7 @@
data-testid="app-notification-new-request"
[title]="editMode ? 'requestNotification.editNotificationHeader' : 'requestNotification.createNotificationHeader'"
[editMode]="editMode"
[allTouched]="shouldMarkAsTouched"
[notification]="selectedNotification"
(formGroupChanged)="notificationFormGroupChange($event)">
</app-notification-new-request>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export class NotificationEditComponent implements OnDestroy {
public tableAsBuiltSortList: TableHeaderSort[];
private paramSubscription: Subscription;
isSaveButtonDisabled: boolean;
shouldMarkAsTouched = new BehaviorSubject<boolean>(false);

constructor(
private readonly ownPartsFacade: PartsFacade,
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/app/modules/page/parts/core/parts.facade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,18 @@ export class PartsFacade {
return this.partsState.partsAsPlanned$;
}

public reloadRegistry() {
return this.partsService.reloadRegistry();
}

public syncPartsAsBuilt(assetIds: string[]) {
return this.partsService.syncPartsAsBuilt(assetIds);
}

public syncPartsAsPlanned(assetIds: string[]) {
return this.partsService.syncPartsAsPlanned(assetIds);
}

public setPartsAsBuilt(page = 0, pageSize = 50, sorting: TableHeaderSort[] = [], assetAsBuiltFilter?: AssetAsBuiltFilter, isOrSearch?: boolean): void {
this.partsAsBuiltSubscription?.unsubscribe();
this.partsAsBuiltSubscription = this.partsService.getPartsAsBuilt(page, pageSize, sorting, assetAsBuiltFilter, isOrSearch).subscribe({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/
export enum PartReloadOperation {
RELOAD_REGISTRY = 'RELOAD_REGISTRY',
SYNC_PARTS_AS_BUILT = 'SYNC_PARTS_AS_BUILT',
SYNC_PARTS_AS_PLANNED = 'SYNC_PARTS_AS_PLANNED'
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<app-parts-table class="parts-asBuilt-table"
[paginationData]="parts.data"
(publishIconClickedEvent)="openPublisherSideNav()"
(partReloadClickedEvent)="triggerPartReload($event)"
(createQualityNotificationClickedEvent)="navigateToNotificationCreationView($event)"
[labelId]="titleId"
[selectedPartsInfoLabel]="'page.selectedParts.info'"
Expand Down Expand Up @@ -86,6 +87,7 @@
[paginationData]="parts.data | formatPaginationSemanticDataModelToCamelCase"
[labelId]="titleId"
(publishIconClickedEvent)="openPublisherSideNav()"
(partReloadClickedEvent)="triggerPartReload($event)"
[selectedPartsInfoLabel]="'page.selectedParts.info'"
[selectedPartsActionLabel]="'page.selectedParts.action'"
[deselectTrigger]="deselectPartTrigger$ | async"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { PartsFacade } from '@page/parts/core/parts.facade';
import { resetMultiSelectionAutoCompleteComponent } from '@page/parts/core/parts.helper';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { Owner } from '@page/parts/model/owner.enum';
import { PartReloadOperation } from '@page/parts/model/partReloadOperation.enum';
import { AssetAsBuiltFilter, AssetAsPlannedFilter, Part } from '@page/parts/model/parts.model';
import { BomLifecycleSize } from '@shared/components/bom-lifecycle-activator/bom-lifecycle-activator.model';
import { TableType } from '@shared/components/multi-select-autocomplete/table-type.model';
Expand Down Expand Up @@ -213,6 +214,53 @@ export class PartsComponent implements OnInit, OnDestroy, AfterViewInit {
}
}

triggerPartReload(operation: PartReloadOperation) {
switch (operation) {
case PartReloadOperation.RELOAD_REGISTRY:
this.reloadRegistry();
break;
case PartReloadOperation.SYNC_PARTS_AS_BUILT:
this.syncPartsAsBuilt(this.currentSelectedItems$.value.map(part => part.id));
break;
case PartReloadOperation.SYNC_PARTS_AS_PLANNED:
this.syncPartsAsPlanned(this.currentSelectedAsPlannedItems$.value.map(part => part.id));
break;
}
}

private reloadRegistry() {
this.partsFacade.reloadRegistry().subscribe({
next: data => {
this.toastService.success('registryReload.success');
},
error: error => {
this.toastService.error(error?.getMessage());
},
});
}

private syncPartsAsBuilt(assetIds: string[]) {
this.partsFacade.syncPartsAsBuilt(assetIds).subscribe({
next: data => {
this.toastService.success('partSynchronization.success');
},
error: error => {
this.toastService.error(error?.getMessage());
},
});
}

private syncPartsAsPlanned(assetIds: string[]) {
this.partsFacade.syncPartsAsPlanned(assetIds).subscribe({
next: data => {
this.toastService.success('partSynchronization.success');
},
error: error => {
this.toastService.error(error?.getMessage());
},
});
}

private resetFilterAndShowToast(resetOwner?: boolean) {
let filterIsSet = resetMultiSelectionAutoCompleteComponent(this.partsTableComponents, false);
if (resetOwner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
}

.message--text__right {
@apply bg-createdLight text-createdDark;
@apply bg-closedLight text-closedDark;
float: right;
}

Expand All @@ -102,7 +102,7 @@
right: -7px;
height: 25px;
border-right: 20px solid;
@apply border-createdLight;
@apply border-closedLight;
border-bottom-left-radius: 16px 14px;
transform: translate(0, -2px);
}
Expand All @@ -121,7 +121,7 @@
}

.message--text__left {
@apply bg-receivedLight text-receivedDark;
@apply bg-createdLight text-createdDark;
float: left;
}

Expand All @@ -133,7 +133,7 @@
left: -7px;
height: 25px;
border-left: 20px solid;
@apply border-receivedLight;
@apply border-createdLight;
border-bottom-right-radius: 16px 14px;
transform: translate(0, -2px);
}
Expand Down Expand Up @@ -180,31 +180,31 @@
}

&--CANCELED {
@apply bg-closedDark text-closedLight before:bg-closedLight;
@apply bg-canceledLight text-canceledDark before:bg-canceledDark;
}

&--CLOSED {
@apply bg-closedDark text-closedLight before:bg-closedLight;
@apply bg-closedLight text-closedDark before:bg-closedDark;
}

&--CREATED {
@apply bg-createdLight text-createdDark before:bg-createdDark;
}

&--SENT {
@apply bg-pendingLight text-pendingDark before:bg-pendingDark;
@apply bg-receivedLight text-receivedDark before:bg-receivedDark;
}

&--ACCEPTED {
@apply bg-declinedLight text-declinedDark before:bg-declinedDark;
@apply bg-confirmedLight text-confirmedDark before:bg-confirmedDark;
}

&--ACKNOWLEDGED {
@apply bg-pendingLight text-pendingDark before:bg-pendingDark;
}

&--DECLINED {
@apply bg-confirmedLight text-confirmedDark before:bg-confirmedDark;
@apply bg-declinedLight text-declinedDark before:bg-declinedDark;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,39 @@


<div class="action-button-tile"
matTooltip="{{(isAllowedToPublish() ? (atLeastOneSelected() ? 'routing.illegalAssetStateToPublish' :'requestNotification.modifyNotAllowed') : 'routing.unauthorized') | i18n}}"
matTooltip="{{(isAdmin() ? (atLeastOneSelected() ? 'routing.illegalAssetStateToPublish' :'requestNotification.modifyNotAllowed') : 'routing.unauthorized') | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="500"
[matTooltipDisabled]="isAllowedToPublish() && atLeastOneSelected() && !isIllegalSelectionToPublish()">
[matTooltipDisabled]="isAdmin() && atLeastOneSelected() && !isIllegalSelectionToPublish()">
<app-button
iconName="published_with_changes"
class="action-button-tile"
matTooltip="{{'actions.publishAssets'| i18n}}"
[matTooltipShowDelay]="500"
matTooltipPosition="above"
[isDisabled]="!isAllowedToPublish() || !atLeastOneSelected() || isIllegalSelectionToPublish()"
[isDisabled]="!isAdmin() || !atLeastOneSelected() || isIllegalSelectionToPublish()"
(click)="publishIconClicked()"
(keydown)="handleKeyDownPublishIconClicked($event)"
></app-button>
</div>

<div class="action-button-tile"
matTooltip="{{(isAdmin() ? (atLeastOneSelected() ? 'routing.syncSelectedParts' :'routing.refreshAllParts') : 'routing.unauthorized') | i18n}}"
matTooltipClass="table--header--tooltip"
matTooltipPosition="above"
[class.mdc-tooltip--multiline]="true"
[matTooltipShowDelay]="500">
<app-button
iconName="published_with_changes"
class="action-button-tile"
[isDisabled]="!isAdmin()"
(click)="partReloadIconClicked()"
(keydown)="handleKeyDownPartReloadIconClicked($event)"
></app-button>
</div>

</div>
<div class="selected-text-container">
<p *ngIf="selectedPartsInfoLabel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import { Sort } from '@angular/material/sort';
import { Pagination } from '@core/model/pagination.model';
import { PartsFacade } from '@page/parts/core/parts.facade';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { PartReloadOperation } from '@page/parts/model/partReloadOperation.enum';
import { PartsTableComponent } from '@shared/components/parts-table/parts-table.component';
import { NotificationType } from '@shared/model/notification.model';
import { FormatPartSemanticDataModelToCamelCasePipe } from '@shared/pipes/format-part-semantic-data-model-to-camelcase.pipe';
Expand Down Expand Up @@ -297,5 +299,38 @@ describe('PartsTableComponent', () => {
expect(componentInstance.selection.selected).toEqual([]);
});

it('should emit reload registry event on part reload button click when no part selected', async () => {
const { fixture } = await renderPartsTableComponent(1, TableType.AS_BUILT_OWN);
const { componentInstance } = fixture;

const emitPartReloadSpy = spyOn(componentInstance.partReloadClickedEvent, 'emit');
componentInstance.partReloadIconClicked();

expect(emitPartReloadSpy).toHaveBeenCalledWith(PartReloadOperation.RELOAD_REGISTRY);
});

it('should emit sync parts as built event on part reload button click when part selected', async () => {
const { fixture } = await renderPartsTableComponent(1, TableType.AS_BUILT_OWN);
const { componentInstance } = fixture;
componentInstance.mainAspectType = MainAspectType.AS_BUILT;
const emitPartReloadSpy = spyOn(componentInstance.partReloadClickedEvent, 'emit');

componentInstance.selection.select({ id: 1 });
componentInstance.partReloadIconClicked();

expect(emitPartReloadSpy).toHaveBeenCalledWith(PartReloadOperation.SYNC_PARTS_AS_BUILT);
});

it('should emit sync parts as planned event on part reload button click when part selected', async () => {
const { fixture } = await renderPartsTableComponent(1, TableType.AS_PLANNED_OWN);
const { componentInstance } = fixture;
componentInstance.mainAspectType = MainAspectType.AS_PLANNED;
const emitPartReloadSpy = spyOn(componentInstance.partReloadClickedEvent, 'emit');

componentInstance.selection.select({ id: 1 });
componentInstance.partReloadIconClicked();

expect(emitPartReloadSpy).toHaveBeenCalledWith(PartReloadOperation.SYNC_PARTS_AS_PLANNED);
});
});

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { UserService } from '@core/user/user.service';
import { MainAspectType } from '@page/parts/model/mainAspectType.enum';
import { Owner } from '@page/parts/model/owner.enum';
import { ImportState, Part } from '@page/parts/model/parts.model';
import { PartReloadOperation } from '@page/parts/model/partReloadOperation.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 { PartsTableConfigUtils } from '@shared/components/parts-table/parts-table-config.utils';
Expand Down Expand Up @@ -72,6 +73,7 @@ export class PartsTableComponent implements OnInit {
@ViewChildren(MultiSelectAutocompleteComponent) multiSelectAutocompleteComponents: QueryList<MultiSelectAutocompleteComponent>;

@Output() publishIconClickedEvent = new EventEmitter<void>();
@Output() partReloadClickedEvent = new EventEmitter<PartReloadOperation>();
@Input() labelId: string;
@Input() noShadow = false;
@Input() showHover = true;
Expand Down Expand Up @@ -184,7 +186,7 @@ export class PartsTableComponent implements OnInit {
this.createQualityNotificationClickedEvent.emit(this.notificationType);
}

public isAllowedToPublish(): boolean {
public isAdmin(): boolean {
return this.roleService.hasAccess([ 'admin' ]);
}

Expand All @@ -200,10 +202,31 @@ export class PartsTableComponent implements OnInit {
}
}

public publishIconClicked(): void {
handleKeyDownPartReloadIconClicked(event: KeyboardEvent): void {
if (event.key === 'Enter') {
this.partReloadIconClicked();
}
}

public publishIconClicked() {
this.publishIconClickedEvent.emit();
}

public partReloadIconClicked() {
if (!this.atLeastOneSelected()) {
this.partReloadClickedEvent.emit(PartReloadOperation.RELOAD_REGISTRY);
} else {
switch (this.mainAspectType) {
case MainAspectType.AS_BUILT:
this.partReloadClickedEvent.emit(PartReloadOperation.SYNC_PARTS_AS_BUILT);
break;
case MainAspectType.AS_PLANNED:
this.partReloadClickedEvent.emit(PartReloadOperation.SYNC_PARTS_AS_PLANNED);
break;
}
}
}

public readonly dataSource = new MatTableDataSource<unknown>();
public readonly selection = new SelectionModel<unknown>(true, []);

Expand Down
Loading

0 comments on commit e80b7dd

Please sign in to comment.