Skip to content

Commit

Permalink
fix(admin-ui): Make order modification note not required
Browse files Browse the repository at this point in the history
Relates to #688
  • Loading branch information
michaelbromley committed Feb 8, 2021
1 parent c678a21 commit 432a51a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,7 @@
<clr-icon shape="trash"></clr-icon>
</button>
</td>
<td
*ngIf="orderLineCustomFields.length"
class="order-line-custom-field align-middle"
>
<td *ngIf="orderLineCustomFields.length" class="order-line-custom-field align-middle">
<ng-container *ngFor="let customField of orderLineCustomFields">
<vdr-custom-field-control
[customField]="customField"
Expand Down Expand Up @@ -193,13 +190,21 @@ <h4 class="mb2">{{ 'order.modifications' | translate }}</h4>
<vdr-product-selector class="mb4" (productSelected)="addItemSelectedVariant = $event">
</vdr-product-selector>
<div *ngIf="addItemSelectedVariant" class="flex mb4">
<img *ngIf="addItemSelectedVariant.productAsset as asset" [src]="asset | assetPreview: 'tiny'" class="mr4" />
<img
*ngIf="addItemSelectedVariant.productAsset as asset"
[src]="asset | assetPreview: 'tiny'"
class="mr4"
/>
<div>
<strong class="mr4">{{ addItemSelectedVariant.productVariantName }}</strong>
<small>{{ addItemSelectedVariant.sku }}</small>
<div>{{ getSelectedItemPrice(addItemSelectedVariant) | localeCurrency: order.currencyCode }}</div>
<div>
{{
getSelectedItemPrice(addItemSelectedVariant)
| localeCurrency: order.currencyCode
}}
</div>
</div>

</div>
<ng-container *ngFor="let customField of orderLineCustomFields">
<vdr-custom-field-control
Expand All @@ -225,10 +230,7 @@ <h4 class="mb2">{{ 'order.modifications' | translate }}</h4>
<clr-accordion-content *clrIfExpanded>
<form [formGroup]="surchargeForm" (submit)="addSurcharge(surchargeForm.value)">
<vdr-form-field [label]="'common.description' | translate" for="description"
><input
id="description"
type="text"
formControlName="description"
><input id="description" type="text" formControlName="description"
/></vdr-form-field>
<vdr-form-field [label]="'order.product-sku' | translate" for="sku"
><input id="sku" type="text" formControlName="sku"
Expand Down Expand Up @@ -262,14 +264,15 @@ <h4 class="mb2">{{ 'order.modifications' | translate }}</h4>
formControlName="taxRate" /></vdr-affixed-input
></vdr-form-field>
<vdr-form-field [label]="'order.tax-description' | translate" for="taxDescription"
><input
id="taxDescription"
type="text"
formControlName="taxDescription"
><input id="taxDescription" type="text" formControlName="taxDescription"
/></vdr-form-field>
<button
class="btn btn-secondary"
[disabled]="surchargeForm.invalid || surchargeForm.pristine || surchargeForm.get('price')?.value === 0"
[disabled]="
surchargeForm.invalid ||
surchargeForm.pristine ||
surchargeForm.get('price')?.value === 0
"
>
{{ 'order.add-surcharge' | translate }}
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,11 @@ export class OrderEditorComponent
canPreviewChanges(): boolean {
const { addItems, adjustOrderLines, surcharges } = this.modifyOrderInput;
return (
(!!addItems?.length ||
!!surcharges?.length ||
!!adjustOrderLines?.length ||
(this.shippingAddressForm.dirty && this.shippingAddressForm.valid) ||
(this.billingAddressForm.dirty && this.billingAddressForm.valid)) &&
this.note !== ''
!!addItems?.length ||
!!surcharges?.length ||
!!adjustOrderLines?.length ||
(this.shippingAddressForm.dirty && this.shippingAddressForm.valid) ||
(this.billingAddressForm.dirty && this.billingAddressForm.valid)
);
}

Expand Down Expand Up @@ -350,7 +349,7 @@ export class OrderEditorComponent
? { updateShippingAddress: this.shippingAddressForm.value }
: {}),
dryRun: true,
note: this.note,
note: this.note ?? '',
options: {
recalculateShipping: this.recalculateShipping,
},
Expand Down

0 comments on commit 432a51a

Please sign in to comment.