Skip to content

Commit

Permalink
Use ID to select format for the order address
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Rusakov committed Dec 6, 2024
1 parent 62c9562 commit 835173d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/app/account/new-order/new-order.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class NewOrderComponent implements OnInit, OnDestroy {
}

get IsOrderTypePrivate() {
return this.orderFormGroup?.get('orderType')?.value?.name.startsWith('Priv');
return this.orderFormGroup?.get('orderType')?.value?.id === 1;
}

get orderTypeCtrl() {
Expand Down Expand Up @@ -201,9 +201,8 @@ export class NewOrderComponent implements OnInit, OnDestroy {
return returnValue;
}

private getOrderType(id: string | number) {
return this.orderTypes.find(x => typeof id === 'number' ?
id === x.id : id === x.name) || {
private getOrderType(id: number) {
return this.orderTypes.find(x => id === x.id) || {
id: 1,
name: ConstantsService.ORDERTYPE_PRIVATE
};
Expand All @@ -221,11 +220,7 @@ export class NewOrderComponent implements OnInit, OnDestroy {
});
this.orderTypeCtrl?.valueChanges.subscribe(
(choice) => {
if (choice.name === ConstantsService.ORDER_NAME.PRIVATE) {
this.addressChoiceCtrl?.setValue('1');
} else {
this.addressChoiceCtrl?.setValue('2');
}
this.addressChoiceCtrl?.setValue(choice.id);
}
);
this.emailDeliverChoiceCtrl?.valueChanges.subscribe(
Expand Down Expand Up @@ -270,7 +265,7 @@ export class NewOrderComponent implements OnInit, OnDestroy {
this.isCustomerSelected = order.HasInvoiceContact;

this.orderFormGroup?.setValue({
orderType: this.getOrderType(order.order_type),
orderType: this.getOrderType(parseInt(order.order_type)),
title: order.title,
invoice_reference: order.invoice_reference,
emailDeliver: order.email_deliver,
Expand Down Expand Up @@ -428,7 +423,7 @@ export class NewOrderComponent implements OnInit, OnDestroy {
resetForms() {
this.isCustomerSelected = this.currentOrder.HasInvoiceContact;
this.orderFormGroup.reset({
orderType: this.getOrderType(this.currentOrder.order_type),
orderType: this.getOrderType(parseInt(this.currentOrder.order_type)),
title: this.currentOrder.title,
invoice_reference: this.currentOrder.invoice_reference,
emailDeliver: this.currentOrder.email_deliver,
Expand Down
4 changes: 2 additions & 2 deletions src/locale/messages.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -1175,15 +1175,15 @@
</trans-unit>
<trans-unit id="order.public" datatype="html">
<source>Public</source>
<target>Öffentlich</target>
<target>Für einen Mandanten</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/constants.service.ts</context>
<context context-type="linenumber">37</context>
</context-group>
</trans-unit>
<trans-unit id="order.private" datatype="html">
<source>Privé</source>
<target>Privat</target>
<target>Für mich selbst</target>
<context-group purpose="location">
<context context-type="sourcefile">src/app/constants.service.ts</context>
<context context-type="linenumber">38</context>
Expand Down

0 comments on commit 835173d

Please sign in to comment.