Skip to content

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,33 +1,40 @@
import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {Component, EventEmitter, Inject, OnInit} from '@angular/core';
import {CustomerPnFieldsEnum, CustomersPnFieldStatusEnum} from '../../enums';
import {FieldsPnUpdateModel, CustomerPnFullModel} from '../../models';
import {CustomersPnService} from '../../services';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';

@Component({
selector: 'app-customer-pn-add',
templateUrl: './customer-pn-add.component.html',
styleUrls: ['./customer-pn-add.component.scss']
styleUrls: ['./customer-pn-add.component.scss'],
standalone: false
})
export class CustomerPnAddComponent implements OnInit {
@ViewChild('frame', {static: false}) frame;
@Output() onCustomerCreated: EventEmitter<void> = new EventEmitter<void>();
@Input() fieldsModel = new FieldsPnUpdateModel();
customerCreated: EventEmitter<void> = new EventEmitter<void>();
fieldsModel = new FieldsPnUpdateModel();
get fieldsEnum() { return CustomerPnFieldsEnum; }
newCustomerModel: CustomerPnFullModel = new CustomerPnFullModel();

constructor(private customersService: CustomersPnService) { }
constructor(
private customersService: CustomersPnService,
public dialogRef: MatDialogRef<CustomerPnAddComponent>,
@Inject(MAT_DIALOG_DATA) public data: {customerId?: number, fields: FieldsPnUpdateModel}
) {
if (data && data.fields) {
this.fieldsModel = data.fields;
}
}

ngOnInit() {
if (this.data && this.data.customerId) {
this.getSingleCustomer(this.data.customerId);
}
}

show() {
this.newCustomerModel = new CustomerPnFullModel();
this.frame.show();
}
showCopy(customerId: number) {
hide() {
this.dialogRef.close();
this.newCustomerModel = new CustomerPnFullModel();
this.getSingleCustomer(customerId);
this.frame.show();
}

getSingleCustomer(customerId: number) {
Expand All @@ -44,8 +51,8 @@ export class CustomerPnAddComponent implements OnInit {
this.customersService.createCustomer(this.newCustomerModel).subscribe(((data) => {
if (data && data.success) {
this.newCustomerModel = new CustomerPnFullModel();
this.onCustomerCreated.emit();
this.frame.hide();
this.customerCreated.emit();
this.dialogRef.close(true);
}
}));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,55 +1,47 @@
<div mdbModal class="modal fade" #frame="mdbModal">
<div class="modal-dialog modal-xl modal-dialog-scrollable">
<div class="modal-content">
<div class="modal-header">
<h3>{{'Are you sure you want to delete' | translate}}?</h3>
<button class="close" data-dismiss="modal" (click)="frame.hide()">
<span>×</span>
</button>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-3">
<strong>{{'Name:' | translate }}</strong> {{selectedCustomer.contactPerson}}
</div>
<div class="col-md-3">
<strong>{{'Number: ' | translate }}</strong> {{selectedCustomer.customerNo}}
</div>
<div class="col-md-3">
<strong>{{'Address: ' | translate }}</strong> {{selectedCustomer.companyAddress}}
</div>
<div class="col-md-3">
<strong>{{'Address 2: ' | translate }}</strong> {{selectedCustomer.companyAddress2}}
</div>
</div>
<div class="row">
<div class="col-md-3">
<strong>{{'Zip Code: ' | translate }}</strong> {{selectedCustomer.zipCode}}
</div>
<div class="col-md-3">
<strong>{{'Created By: ' | translate }}</strong> {{selectedCustomer.createdBy}}
</div>
<div class="col-md-3">
<strong>{{'City Name: ' | translate}}</strong> {{selectedCustomer.cityName }}
</div>
<div class="col-md-3">
<strong>{{'Phone: ' | translate}}</strong> {{selectedCustomer.phone }}
</div>
</div>
<div class="row">
<div class="col-md-3">
<strong>{{'Email: ' | translate}}</strong> {{selectedCustomer.email }}
</div>
<div class="col-md-3">
<strong>{{'EAN Code: ' | translate}}</strong> {{selectedCustomer.eanCode }}
</div>
<div class="col-md-3">
<strong>{{'Vat Number: ' | translate}}</strong> {{selectedCustomer.vatNumber }}
</div>
<div class="col-md-3">
<strong>{{'Country Code: ' | translate}}</strong> {{selectedCustomer.countryCode }}
</div>
</div>
<h3 mat-dialog-title>{{'Are you sure you want to delete' | translate}}?</h3>
<div mat-dialog-content>
<div class="row">
<div class="col-md-3">
<strong>{{'Name:' | translate }}</strong> {{selectedCustomer.contactPerson}}
</div>
<div class="col-md-3">
<strong>{{'Number: ' | translate }}</strong> {{selectedCustomer.customerNo}}
</div>
<div class="col-md-3">
<strong>{{'Address: ' | translate }}</strong> {{selectedCustomer.companyAddress}}
</div>
<div class="col-md-3">
<strong>{{'Address 2: ' | translate }}</strong> {{selectedCustomer.companyAddress2}}
</div>
</div>
<div class="row">
<div class="col-md-3">
<strong>{{'Zip Code: ' | translate }}</strong> {{selectedCustomer.zipCode}}
</div>
<div class="col-md-3">
<strong>{{'Created By: ' | translate }}</strong> {{selectedCustomer.createdBy}}
</div>
<div class="col-md-3">
<strong>{{'City Name: ' | translate}}</strong> {{selectedCustomer.cityName }}
</div>
<div class="col-md-3">
<strong>{{'Phone: ' | translate}}</strong> {{selectedCustomer.phone }}
</div>
</div>
<div class="row">
<div class="col-md-3">
<strong>{{'Email: ' | translate}}</strong> {{selectedCustomer.email }}
</div>
<div class="col-md-3">
<strong>{{'EAN Code: ' | translate}}</strong> {{selectedCustomer.eanCode }}
</div>
<div class="col-md-3">
<strong>{{'Vat Number: ' | translate}}</strong> {{selectedCustomer.vatNumber }}
</div>
<div class="col-md-3">
<strong>{{'Country Code: ' | translate}}</strong> {{selectedCustomer.countryCode }}
</div>
</div>
<!-- <table class="table table-sm table-striped text-center z-depth-1">-->
<!-- <tbody id="tableBody">-->
<!-- <ng-container *ngFor="let field of selectedCustomer.fields">-->
Expand All @@ -73,11 +65,8 @@ <h3>{{'Are you sure you want to delete' | translate}}?</h3>
<!-- </ng-container>-->
<!-- </tbody>-->
<!-- </table>-->
</div>
<div class="modal-footer d-flex justify-content-center">
<button mdbBtn class="btn-danger btn-small-height" (click)="deleteCustomer()" id="customerSaveDeleteBtn">{{'Delete' | translate}}</button>
<button mdbBtn class="btn-accent text-black-50 btn-small-height" (click)="frame.hide()" id="customerDeleteCancelBtn">{{'Close' | translate}}</button>
</div>
</div>
</div>
</div>
<div mat-dialog-actions class="d-flex flex-row justify-content-end">
<button mat-raised-button color="warn" (click)="deleteCustomer()" id="customerSaveDeleteBtn">{{'Delete' | translate}}</button>
<button mat-raised-button (click)="hide()" id="customerDeleteCancelBtn">{{'Close' | translate}}</button>
</div>
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
import {Component, EventEmitter, Input, OnInit, Output, ViewChild} from '@angular/core';
import {Component, EventEmitter, Inject, OnInit} from '@angular/core';
import {CustomerPnFieldsEnum} from 'src/app/plugins/modules/customers-pn/enums';
import {CustomerPnModel} from 'src/app/plugins/modules/customers-pn/models/customer';
import {FieldsPnUpdateModel} from 'src/app/plugins/modules/customers-pn/models/field';
import {CustomersPnService} from '../../services';
import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog';

@Component({
selector: 'app-customer-pn-delete',
templateUrl: './customer-pn-delete.component.html',
styleUrls: ['./customer-pn-delete.component.scss']
styleUrls: ['./customer-pn-delete.component.scss'],
standalone: false
})
export class CustomerPnDeleteComponent implements OnInit {
@ViewChild('frame', {static: false}) frame;
@Output() onCustomerDeleted: EventEmitter<void> = new EventEmitter<void>();
customerDeleted: EventEmitter<void> = new EventEmitter<void>();
selectedCustomer: CustomerPnModel = new CustomerPnModel();
@Input() fields: FieldsPnUpdateModel = new FieldsPnUpdateModel();
fields: FieldsPnUpdateModel = new FieldsPnUpdateModel();
get fieldsEnum() { return CustomerPnFieldsEnum; }


constructor(private customersService: CustomersPnService) { }
constructor(
private customersService: CustomersPnService,
public dialogRef: MatDialogRef<CustomerPnDeleteComponent>,
@Inject(MAT_DIALOG_DATA) public data: {customer: CustomerPnModel, fields: FieldsPnUpdateModel}
) {
if (data) {
this.selectedCustomer = data.customer;
if (data.fields) {
this.fields = data.fields;
}
}
}

ngOnInit() {
}

show(customer: CustomerPnModel) {
this.selectedCustomer = customer;
this.frame.show();
hide() {
this.dialogRef.close();
}

deleteCustomer() {
this.customersService.deleteCustomer(this.selectedCustomer.id).subscribe(((data) => {
if (data && data.success) {
this.onCustomerDeleted.emit();
this.frame.hide();
this.customerDeleted.emit();
this.dialogRef.close(true);
}
}));
}
Expand Down
Loading
Loading