-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate shipment type incompatibilities
- Loading branch information
1 parent
b6be8de
commit 13bb2ba
Showing
7 changed files
with
378 additions
and
304 deletions.
There are no files selected for viewing
146 changes: 145 additions & 1 deletion
146
.../shipment-type-incompatibility-dialog/shipment-type-incompatibility-dialog.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,145 @@ | ||
<p>shipment-type-incompatibility-dialog works!</p> | ||
<h3 mat-dialog-title> | ||
Shipment Type Incompatibilities ({{ shipmentTypeIncompatsControl.value?.length }}) | ||
</h3> | ||
<mat-dialog-content> | ||
<form [formGroup]="form" autocomplete="off"> | ||
<section class="shipment-type"> | ||
<header> | ||
<div> | ||
<mat-error class="mb-4" *ngIf="shipmentTypeIncompatsControl.getError('duplicate')"> | ||
Cannot have duplicate incompatibility rules | ||
</mat-error> | ||
</div> | ||
</header> | ||
|
||
<div formArrayName="shipmentTypeIncompatibilities" class="w-100"> | ||
<div | ||
*ngFor=" | ||
let shipmentTypeIncompat of shipmentTypeIncompatsControl.controls; | ||
let shipmentTypeIncompatsIndex = index | ||
" | ||
[formGroupName]="shipmentTypeIncompatsIndex" | ||
class="d-flex flex-row align-items-center w-100 mb-2"> | ||
<!-- types --> | ||
<div class="settings-item item-xl pad-right"> | ||
<mat-form-field class="flex-grow-1 pb-0"> | ||
<mat-label>Shipment types*</mat-label> | ||
<mat-chip-list #shipmentTypeIncompatibilityChipList aria-label="Shipment types"> | ||
<mat-chip | ||
*ngFor="let shipmentType of shipmentTypeIncompat.value?.types" | ||
[selectable]="false" | ||
(removed)=" | ||
removeTypeFromShipmentTypeIncompat(shipmentType, shipmentTypeIncompatsIndex) | ||
"> | ||
{{ shipmentType }} | ||
<mat-icon matChipRemove>cancel</mat-icon> | ||
</mat-chip> | ||
<input | ||
#shipmentTypeIncompatibilityInput | ||
[matAutocomplete]="autoIncompatTypes" | ||
[matChipInputFor]="shipmentTypeIncompatibilityChipList" | ||
[matChipInputSeparatorKeyCodes]="separatorKeysCodes" | ||
(matChipInputTokenEnd)=" | ||
addTypeToShipmentTypeIncompat( | ||
$event.value, | ||
shipmentTypeIncompatsIndex, | ||
$event.input | ||
) | ||
" | ||
(focusout)=" | ||
addTypeToShipmentTypeIncompat( | ||
$event.target.value, | ||
shipmentTypeIncompatsIndex, | ||
$event.target | ||
) | ||
" | ||
(input)="updateFilteredAvailableIncompatShipmentTypes($event.data)" | ||
(keydown)=" | ||
onShipmentTypeIncompatTypeKeyDown($event, shipmentTypeIncompatsIndex) | ||
" /> | ||
</mat-chip-list> | ||
|
||
<mat-autocomplete | ||
class="cost-vehicles-panel" | ||
#autoIncompatTypes="matAutocomplete" | ||
(optionSelected)=" | ||
addTypeToShipmentTypeIncompat( | ||
$event.option.value, | ||
shipmentTypeIncompatsIndex, | ||
shipmentTypeIncompatibilityInput | ||
) | ||
"> | ||
<cdk-virtual-scroll-viewport | ||
style="height: 200px" | ||
[itemSize]="48" | ||
minBufferPx="200" | ||
maxBufferPx="400"> | ||
<mat-option | ||
[style.height.px]="48" | ||
*cdkVirtualFor=" | ||
let shipmentType of (filteredAvailableIncompatShipmentTypes$ | async)[ | ||
shipmentTypeIncompatsIndex | ||
] | ||
" | ||
[value]="shipmentType"> | ||
{{ shipmentType }} | ||
</mat-option> | ||
</cdk-virtual-scroll-viewport> | ||
</mat-autocomplete> | ||
</mat-form-field> | ||
<mat-error | ||
*ngIf=" | ||
shipmentTypeIncompat.getError('required', 'types') || | ||
shipmentTypeIncompat.getError('minlength', 'types') | ||
"> | ||
At least 2 types required | ||
</mat-error> | ||
<div | ||
class="unused-shipment-type-warning" | ||
*ngIf="unusedShipmentIncompatTypes[shipmentTypeIncompatsIndex]"> | ||
Shipment type(s) not used on any shipments: | ||
{{ unusedShipmentIncompatTypes[shipmentTypeIncompatsIndex] }} | ||
</div> | ||
</div> | ||
|
||
<!-- mode --> | ||
<div class="settings-item pad-right"> | ||
<div class="mat-body-strong">Incompatibility mode*</div> | ||
<mat-form-field appearance="outline" class="pb-0"> | ||
<mat-select formControlName="incompatibilityMode"> | ||
<mat-option | ||
*ngFor="let mode of keys(shipmentTypeIncompatModeLabels)" | ||
[value]="parseInt(mode)"> | ||
{{ shipmentTypeIncompatModeLabels[mode] }} | ||
</mat-option> | ||
</mat-select> | ||
</mat-form-field> | ||
<mat-error *ngIf="shipmentTypeIncompat.getError('required', 'incompatibilityMode')"> | ||
Required | ||
</mat-error> | ||
</div> | ||
|
||
<!-- remove --> | ||
<button | ||
type="button" | ||
class="clear-place" | ||
(click)="removeShipmentTypeIncompat(shipmentTypeIncompatsIndex)" | ||
mat-icon-button | ||
title="Remove Shipment Type Incompatibility"> | ||
<mat-icon class="icon--smaller m-0" svgIcon="delete"></mat-icon> | ||
</button> | ||
</div> | ||
</div> | ||
<button type="button" mat-button color="primary" (click)="addShipmentTypeIncompat()"> | ||
Add shipment type incompatibility | ||
</button> | ||
</section> | ||
</form> | ||
</mat-dialog-content> | ||
<mat-divider></mat-divider> | ||
<mat-dialog-actions> | ||
<button mat-stroked-button class="light-stroked-button" color="primary" mat-dialog-close> | ||
Cancel | ||
</button> | ||
<button mat-flat-button color="primary" (click)="onSave()" [disabled]="!form.valid">Save</button> | ||
</mat-dialog-actions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@import '../../../../styles/variables.scss'; | ||
|
||
:host { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
mat-dialog-content { | ||
flex-grow: 1; | ||
max-height: initial; | ||
} | ||
|
||
.unused-shipment-type-warning { | ||
font-size: 0.8em; | ||
color: $orange; | ||
} |
20 changes: 20 additions & 0 deletions
20
...ipment-type-incompatibility-dialog/shipment-type-incompatibility-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.