Skip to content

Commit 819c791

Browse files
authored
Merge pull request #990 from microting/copilot/fix-65080a1a-3f0b-49ba-a168-ab1bc44af929
Migrate from Akita to ngrx state management and MDBModal to Angular Material Dialog
2 parents 1f96045 + df26d66 commit 819c791

23 files changed

+861
-756
lines changed

eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.html

Lines changed: 201 additions & 231 deletions
Large diffs are not rendered by default.

eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-add/customer-pn-add.component.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
1-
import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
1+
import {Component, EventEmitter, Inject, OnInit} from '@angular/core';
22
import {CustomerPnFieldsEnum, CustomersPnFieldStatusEnum} from '../../enums';
33
import {FieldsPnUpdateModel, CustomerPnFullModel} from '../../models';
44
import {CustomersPnService} from '../../services';
5+
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
56

67
@Component({
78
selector: 'app-customer-pn-add',
89
templateUrl: './customer-pn-add.component.html',
9-
styleUrls: ['./customer-pn-add.component.scss']
10+
styleUrls: ['./customer-pn-add.component.scss'],
11+
standalone: false
1012
})
1113
export class CustomerPnAddComponent implements OnInit {
12-
@ViewChild('frame', {static: false}) frame;
13-
@Output() onCustomerCreated: EventEmitter<void> = new EventEmitter<void>();
14-
@Input() fieldsModel = new FieldsPnUpdateModel();
14+
customerCreated: EventEmitter<void> = new EventEmitter<void>();
15+
fieldsModel = new FieldsPnUpdateModel();
1516
get fieldsEnum() { return CustomerPnFieldsEnum; }
1617
newCustomerModel: CustomerPnFullModel = new CustomerPnFullModel();
1718

18-
constructor(private customersService: CustomersPnService) { }
19+
constructor(
20+
private customersService: CustomersPnService,
21+
public dialogRef: MatDialogRef<CustomerPnAddComponent>,
22+
@Inject(MAT_DIALOG_DATA) public data: {customerId?: number, fields: FieldsPnUpdateModel}
23+
) {
24+
if (data && data.fields) {
25+
this.fieldsModel = data.fields;
26+
}
27+
}
1928

2029
ngOnInit() {
30+
if (this.data && this.data.customerId) {
31+
this.getSingleCustomer(this.data.customerId);
32+
}
2133
}
2234

23-
show() {
24-
this.newCustomerModel = new CustomerPnFullModel();
25-
this.frame.show();
26-
}
27-
showCopy(customerId: number) {
35+
hide() {
36+
this.dialogRef.close();
2837
this.newCustomerModel = new CustomerPnFullModel();
29-
this.getSingleCustomer(customerId);
30-
this.frame.show();
3138
}
3239

3340
getSingleCustomer(customerId: number) {
@@ -44,8 +51,8 @@ export class CustomerPnAddComponent implements OnInit {
4451
this.customersService.createCustomer(this.newCustomerModel).subscribe(((data) => {
4552
if (data && data.success) {
4653
this.newCustomerModel = new CustomerPnFullModel();
47-
this.onCustomerCreated.emit();
48-
this.frame.hide();
54+
this.customerCreated.emit();
55+
this.dialogRef.close(true);
4956
}
5057
}));
5158
}
Lines changed: 48 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,47 @@
1-
<div mdbModal class="modal fade" #frame="mdbModal">
2-
<div class="modal-dialog modal-xl modal-dialog-scrollable">
3-
<div class="modal-content">
4-
<div class="modal-header">
5-
<h3>{{'Are you sure you want to delete' | translate}}?</h3>
6-
<button class="close" data-dismiss="modal" (click)="frame.hide()">
7-
<span>×</span>
8-
</button>
9-
</div>
10-
<div class="modal-body">
11-
<div class="row">
12-
<div class="col-md-3">
13-
<strong>{{'Name:' | translate }}</strong> {{selectedCustomer.contactPerson}}
14-
</div>
15-
<div class="col-md-3">
16-
<strong>{{'Number: ' | translate }}</strong> {{selectedCustomer.customerNo}}
17-
</div>
18-
<div class="col-md-3">
19-
<strong>{{'Address: ' | translate }}</strong> {{selectedCustomer.companyAddress}}
20-
</div>
21-
<div class="col-md-3">
22-
<strong>{{'Address 2: ' | translate }}</strong> {{selectedCustomer.companyAddress2}}
23-
</div>
24-
</div>
25-
<div class="row">
26-
<div class="col-md-3">
27-
<strong>{{'Zip Code: ' | translate }}</strong> {{selectedCustomer.zipCode}}
28-
</div>
29-
<div class="col-md-3">
30-
<strong>{{'Created By: ' | translate }}</strong> {{selectedCustomer.createdBy}}
31-
</div>
32-
<div class="col-md-3">
33-
<strong>{{'City Name: ' | translate}}</strong> {{selectedCustomer.cityName }}
34-
</div>
35-
<div class="col-md-3">
36-
<strong>{{'Phone: ' | translate}}</strong> {{selectedCustomer.phone }}
37-
</div>
38-
</div>
39-
<div class="row">
40-
<div class="col-md-3">
41-
<strong>{{'Email: ' | translate}}</strong> {{selectedCustomer.email }}
42-
</div>
43-
<div class="col-md-3">
44-
<strong>{{'EAN Code: ' | translate}}</strong> {{selectedCustomer.eanCode }}
45-
</div>
46-
<div class="col-md-3">
47-
<strong>{{'Vat Number: ' | translate}}</strong> {{selectedCustomer.vatNumber }}
48-
</div>
49-
<div class="col-md-3">
50-
<strong>{{'Country Code: ' | translate}}</strong> {{selectedCustomer.countryCode }}
51-
</div>
52-
</div>
1+
<h3 mat-dialog-title>{{'Are you sure you want to delete' | translate}}?</h3>
2+
<div mat-dialog-content>
3+
<div class="row">
4+
<div class="col-md-3">
5+
<strong>{{'Name:' | translate }}</strong> {{selectedCustomer.contactPerson}}
6+
</div>
7+
<div class="col-md-3">
8+
<strong>{{'Number: ' | translate }}</strong> {{selectedCustomer.customerNo}}
9+
</div>
10+
<div class="col-md-3">
11+
<strong>{{'Address: ' | translate }}</strong> {{selectedCustomer.companyAddress}}
12+
</div>
13+
<div class="col-md-3">
14+
<strong>{{'Address 2: ' | translate }}</strong> {{selectedCustomer.companyAddress2}}
15+
</div>
16+
</div>
17+
<div class="row">
18+
<div class="col-md-3">
19+
<strong>{{'Zip Code: ' | translate }}</strong> {{selectedCustomer.zipCode}}
20+
</div>
21+
<div class="col-md-3">
22+
<strong>{{'Created By: ' | translate }}</strong> {{selectedCustomer.createdBy}}
23+
</div>
24+
<div class="col-md-3">
25+
<strong>{{'City Name: ' | translate}}</strong> {{selectedCustomer.cityName }}
26+
</div>
27+
<div class="col-md-3">
28+
<strong>{{'Phone: ' | translate}}</strong> {{selectedCustomer.phone }}
29+
</div>
30+
</div>
31+
<div class="row">
32+
<div class="col-md-3">
33+
<strong>{{'Email: ' | translate}}</strong> {{selectedCustomer.email }}
34+
</div>
35+
<div class="col-md-3">
36+
<strong>{{'EAN Code: ' | translate}}</strong> {{selectedCustomer.eanCode }}
37+
</div>
38+
<div class="col-md-3">
39+
<strong>{{'Vat Number: ' | translate}}</strong> {{selectedCustomer.vatNumber }}
40+
</div>
41+
<div class="col-md-3">
42+
<strong>{{'Country Code: ' | translate}}</strong> {{selectedCustomer.countryCode }}
43+
</div>
44+
</div>
5345
<!-- <table class="table table-sm table-striped text-center z-depth-1">-->
5446
<!-- <tbody id="tableBody">-->
5547
<!-- <ng-container *ngFor="let field of selectedCustomer.fields">-->
@@ -73,11 +65,8 @@ <h3>{{'Are you sure you want to delete' | translate}}?</h3>
7365
<!-- </ng-container>-->
7466
<!-- </tbody>-->
7567
<!-- </table>-->
76-
</div>
77-
<div class="modal-footer d-flex justify-content-center">
78-
<button mdbBtn class="btn-danger btn-small-height" (click)="deleteCustomer()" id="customerSaveDeleteBtn">{{'Delete' | translate}}</button>
79-
<button mdbBtn class="btn-accent text-black-50 btn-small-height" (click)="frame.hide()" id="customerDeleteCancelBtn">{{'Close' | translate}}</button>
80-
</div>
81-
</div>
82-
</div>
68+
</div>
69+
<div mat-dialog-actions class="d-flex flex-row justify-content-end">
70+
<button mat-raised-button color="warn" (click)="deleteCustomer()" id="customerSaveDeleteBtn">{{'Delete' | translate}}</button>
71+
<button mat-raised-button (click)="hide()" id="customerDeleteCancelBtn">{{'Close' | translate}}</button>
8372
</div>

eform-client/src/app/plugins/modules/customers-pn/components/customer-pn-delete/customer-pn-delete.component.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,47 @@
1-
import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
1+
import {Component, EventEmitter, Inject, OnInit} from '@angular/core';
22
import {CustomerPnFieldsEnum} from 'src/app/plugins/modules/customers-pn/enums';
33
import {CustomerPnModel} from 'src/app/plugins/modules/customers-pn/models/customer';
44
import {FieldsPnUpdateModel} from 'src/app/plugins/modules/customers-pn/models/field';
55
import {CustomersPnService} from '../../services';
6+
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';
67

78
@Component({
89
selector: 'app-customer-pn-delete',
910
templateUrl: './customer-pn-delete.component.html',
10-
styleUrls: ['./customer-pn-delete.component.scss']
11+
styleUrls: ['./customer-pn-delete.component.scss'],
12+
standalone: false
1113
})
1214
export class CustomerPnDeleteComponent implements OnInit {
13-
@ViewChild('frame', {static: false}) frame;
14-
@Output() onCustomerDeleted: EventEmitter<void> = new EventEmitter<void>();
15+
customerDeleted: EventEmitter<void> = new EventEmitter<void>();
1516
selectedCustomer: CustomerPnModel = new CustomerPnModel();
16-
@Input() fields: FieldsPnUpdateModel = new FieldsPnUpdateModel();
17+
fields: FieldsPnUpdateModel = new FieldsPnUpdateModel();
1718
get fieldsEnum() { return CustomerPnFieldsEnum; }
1819

19-
20-
constructor(private customersService: CustomersPnService) { }
20+
constructor(
21+
private customersService: CustomersPnService,
22+
public dialogRef: MatDialogRef<CustomerPnDeleteComponent>,
23+
@Inject(MAT_DIALOG_DATA) public data: {customer: CustomerPnModel, fields: FieldsPnUpdateModel}
24+
) {
25+
if (data) {
26+
this.selectedCustomer = data.customer;
27+
if (data.fields) {
28+
this.fields = data.fields;
29+
}
30+
}
31+
}
2132

2233
ngOnInit() {
2334
}
2435

25-
show(customer: CustomerPnModel) {
26-
this.selectedCustomer = customer;
27-
this.frame.show();
36+
hide() {
37+
this.dialogRef.close();
2838
}
2939

3040
deleteCustomer() {
3141
this.customersService.deleteCustomer(this.selectedCustomer.id).subscribe(((data) => {
3242
if (data && data.success) {
33-
this.onCustomerDeleted.emit();
34-
this.frame.hide();
43+
this.customerDeleted.emit();
44+
this.dialogRef.close(true);
3545
}
3646
}));
3747
}

0 commit comments

Comments
 (0)