AddressPipe angepasst, fehlende Adresszusatz Felder hinzugefügt

This commit is contained in:
Andreas Schickinger
2021-01-08 15:50:11 +01:00
parent a537437046
commit 65446b19cb
6 changed files with 51 additions and 30 deletions

View File

@@ -28,6 +28,9 @@
<ui-form-control label="Ort" variant="inline">
<input uiInput type="text" formControlName="city" />
</ui-form-control>
<ui-form-control label="Adresszusatz" variant="inline">
<input uiInput type="text" formControlName="info" />
</ui-form-control>
<ui-form-control label="Land" variant="inline">
<ui-select formControlName="country">
<ui-select-option

View File

@@ -39,6 +39,9 @@
<ui-form-control label="Ort" variant="inline">
<input uiInput type="text" formControlName="city" />
</ui-form-control>
<ui-form-control label="Adresszusatz" variant="inline">
<input uiInput type="text" formControlName="info" />
</ui-form-control>
<ui-form-control label="Land" variant="inline">
<ui-select formControlName="country">
<ui-select-option
@@ -73,10 +76,6 @@
</ui-form-control>
</ng-container>
<ui-form-control label="Adresszusatz" formGroupName="address" variant="inline">
<input uiInput type="text" formControlName="info" />
</ui-form-control>
<div class="actions">
<button class="btn-cancel" type="button" (click)="cancel()">Abbrechen</button>
<button class="btn-save" type="submit" [disabled]="control.invalid || control.disabled" [ngSwitch]="control.enabled">

View File

@@ -26,9 +26,13 @@
<span class="name">Ort</span>
<span class="value">{{ customer?.address?.city }}</span>
</div>
<div class="field">
<span class="name">Adresszusatz</span>
<span class="value">{{ customer?.address?.info }}</span>
</div>
<div class="field">
<span class="name">Land</span>
<span class="value">{{ customer?.address?.country }}</span>
<span class="value">{{ customer?.address?.country | country }}</span>
</div>
<div class="field">
<span class="name">Anrede</span>

View File

@@ -34,6 +34,10 @@
<span class="name">Ort</span>
<span class="value">{{ customer?.address?.city }}</span>
</div>
<div class="field">
<span class="name">Adresszusatz</span>
<span class="value">{{ customer?.address?.info }}</span>
</div>
<div class="field">
<span class="name">Land</span>
<span class="value">{{ customer?.address?.country | country }}</span>
@@ -62,7 +66,3 @@
<span class="name">USt-ID</span>
<span class="value">{{ customer?.organisation?.vatId }}</span>
</div>
<div class="field">
<span class="name">Adresszusatz</span>
<span class="value">{{ customer?.address?.info }}</span>
</div>

View File

@@ -54,12 +54,15 @@
<div class="address-wrapper">
<div class="card-section-title">
<h3>Rechnungsadresse</h3>
<a class="button-add-address" [routerLink]="['/customer', customerId$ | async, 'payer', 'create', (isB2b$ | async) ? 'b2b' : 'b2c']"
<a
*ngIf="(isB2b$ | async) === false"
class="button-add-address"
[routerLink]="['/customer', customerId$ | async, 'payer', 'create', 'b2c']"
>Hinzufügen</a
>
</div>
<ul class="card-customer-address">
<li *ngIf="customer.address | address as defaultPayerAddress">
<li *ngIf="customer | address as defaultPayerAddress">
<ui-form-control [label]="defaultPayerAddress">
<input name="payerAddress" uiInput type="radio" [value]="undefined" [(ngModel)]="selectedPayer" />
</ui-form-control>
@@ -68,16 +71,18 @@
>
</li>
<li *ngFor="let payer of customer.payers">
<ui-form-control [label]="payer?.payer?.data?.address | address">
<input name="payerAddress" uiInput type="radio" [value]="payer?.payer?.id" [(ngModel)]="selectedPayer" />
</ui-form-control>
<a
class="button-edit-address"
[routerLink]="['/customer', customerId$ | async, 'payer', payer?.payer?.id, 'edit', (isB2b$ | async) ? 'b2b' : 'b2c']"
>Bearbeiten</a
>
</li>
<ng-container *ngIf="(isB2b$ | async) === false">
<li *ngFor="let payer of customer.payers">
<ui-form-control [label]="payer?.payer?.data | address">
<input name="payerAddress" uiInput type="radio" [value]="payer?.payer?.id" [(ngModel)]="selectedPayer" />
</ui-form-control>
<a
class="button-edit-address"
[routerLink]="['/customer', customerId$ | async, 'payer', payer?.payer?.id, 'edit', (isB2b$ | async) ? 'b2b' : 'b2c']"
>Bearbeiten</a
>
</li>
</ng-container>
</ul>
<div class="card-section-title">
@@ -89,7 +94,7 @@
>
</div>
<ul class="card-customer-address">
<li *ngIf="customer.address | address as defaultShippingAddress">
<li *ngIf="customer | address as defaultShippingAddress">
<ui-form-control [label]="defaultShippingAddress">
<input name="shippingAddress" uiInput type="radio" [value]="undefined" [(ngModel)]="selectedAddress" />
</ui-form-control>
@@ -99,7 +104,7 @@
</li>
<li *ngFor="let address of customer.shippingAddresses">
<ui-form-control [label]="address?.data?.address | address">
<ui-form-control [label]="address?.data | address">
<input name="shippingAddress" uiInput type="radio" [value]="address?.id" [(ngModel)]="selectedAddress" />
</ui-form-control>
<a

View File

@@ -1,6 +1,16 @@
import { ChangeDetectorRef, Pipe, PipeTransform } from '@angular/core';
import { CrmCustomerService } from '@domain/crm';
import { AddressDTO } from '@swagger/crm';
import { AddressDTO, CommunicationDetailsDTO, OrganisationDTO } from '@swagger/crm';
export interface AddressData {
gender: number;
title: string;
firstName: string;
lastName: string;
address: AddressDTO;
organisation: OrganisationDTO;
communicationDetails: CommunicationDetailsDTO;
}
@Pipe({
name: 'address',
@@ -8,12 +18,12 @@ import { AddressDTO } from '@swagger/crm';
})
export class AddressPipe implements PipeTransform {
private result: string;
private address: AddressDTO;
private data: AddressData;
constructor(private customerService: CrmCustomerService, private cdr: ChangeDetectorRef) {}
transform(address: AddressDTO): string {
this.address = address;
transform(data: AddressData): string {
this.data = data;
this.getResult();
return this.result;
@@ -21,11 +31,11 @@ export class AddressPipe implements PipeTransform {
async getResult() {
let result = undefined;
if (!!this.address?.street && !!this.address?.city && !!this.address?.zipCode && !!this.address?.country) {
if (!!this.data?.address?.street && !!this.data?.address?.city && !!this.data?.address?.zipCode && !!this.data?.address?.country) {
const countries = await this.customerService.getCountries().toPromise();
const country = countries.result.find((c) => c.isO3166_A_3 === this.address.country)?.name || this.address.country;
const country = countries.result.find((c) => c.isO3166_A_3 === this.data?.address.country)?.name || this.data?.address.country;
result = `${this.address?.street} ${this.address?.streetNumber}, ${this.address?.zipCode} ${this.address?.city}, ${country}`;
result = `${this.data?.address?.street} ${this.data?.address?.streetNumber}, ${this.data?.address?.zipCode} ${this.data?.address?.city}, ${country}`;
}
if (result !== this.result) {