Skip to content

Commit

Permalink
fix email not working | issue #354
Browse files Browse the repository at this point in the history
  • Loading branch information
panic-coder committed Jan 7, 2020
1 parent cac97c0 commit 3d91734
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ <h4 class="modal-title">Email Report</h4>
<p>Multiple Emails can be comma(,) separated</p>
<div class="form-group col-sm-12">
<span>To: </span>
<input class="form-control" type="email" name="to" (ngModelChange)="toEmailValidation()"
<input class="form-control" type="email" name="sendTo" (ngModelChange)="toEmailValidation()" (keyup)="toEmailEmpty()"
[(ngModel)]="emailModalData.to"/>
<span class="text-success"
*ngIf="toValidEmailCounter > 0">{{toValidEmailCounter}} valid email(s)</span>
Expand All @@ -431,7 +431,7 @@ <h4 class="modal-title">Email Report</h4>
</div>
<div class="form-group col-sm-12">
<span>Cc: </span>
<input class="form-control" type="email" name="cc" (ngModelChange)="ccEmailValidation()"
<input class="form-control" type="email" name="cc" (ngModelChange)="ccEmailValidation()" (keyup)="ccEmailEmpty()"
[(ngModel)]="emailModalData.cc"/>
<span class="text-success"
*ngIf="ccValidEmailCounter > 0">{{ccValidEmailCounter}} valid email(s)</span>
Expand All @@ -442,7 +442,7 @@ <h4 class="modal-title">Email Report</h4>
</div>
<div class="form-group col-sm-12">
<span>Bcc: </span>
<input class="form-control" type="email" name="bcc" (ngModelChange)="bccEmailValidation()"
<input class="form-control" type="email" name="bcc" (ngModelChange)="bccEmailValidation()" (keyup)="bccEmailEmpty()"
[(ngModel)]="emailModalData.bcc"/>
<span class="text-success"
*ngIf="bccValidEmailCounter > 0">{{bccValidEmailCounter}} valid email(s)</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class GeneratedComponent implements OnInit, OnDestroy {

this._route.data.subscribe((data: any) => {
this.order = data.stockOrderDetails[0];
this.emailModalData.to = this.order.supplierModel ? this.order.supplierModel.email : '';
this.emailModalData.to = this.order.supplierModel ? ( this.order.supplierModel.email ? this.order.supplierModel.email : '') : '';
this.getNotApprovedStockOrderLineItems();
this.getApprovedStockOrderLineItems();
},
Expand Down Expand Up @@ -266,6 +266,7 @@ export class GeneratedComponent implements OnInit, OnDestroy {
toEmailValidation() {
this.toValidEmailCounter = 0;
this.toInvalidEmailCounter = 0;
this.emailModalData.to = this.emailModalData.to + ' ';
let toEmailArray = this.emailModalData.to.split(',');
if (toEmailArray.length) {
toEmailArray.forEach(eachEmail => {
Expand All @@ -279,9 +280,18 @@ export class GeneratedComponent implements OnInit, OnDestroy {
}
}

toEmailEmpty() {
this.emailModalData.to = this.emailModalData.to.trim();
if (this.emailModalData.to === '') {
this.toValidEmailCounter = 0;
this.toInvalidEmailCounter = 0;
}
}

ccEmailValidation() {
this.ccValidEmailCounter = 0;
this.ccInvalidEmailCounter = 0;
this.emailModalData.cc = this.emailModalData.cc + ' ';
let toEmailArray = this.emailModalData.cc.split(',');
if (toEmailArray.length) {
toEmailArray.forEach(eachEmail => {
Expand All @@ -295,9 +305,18 @@ export class GeneratedComponent implements OnInit, OnDestroy {
}
}

ccEmailEmpty() {
this.emailModalData.cc = this.emailModalData.cc.trim();
if (this.emailModalData.cc === '') {
this.ccValidEmailCounter = 0;
this.ccInvalidEmailCounter = 0;
}
}

bccEmailValidation() {
this.bccValidEmailCounter = 0;
this.bccInvalidEmailCounter = 0;
this.emailModalData.bcc = this.emailModalData.bcc + ' ';
let toEmailArray = this.emailModalData.bcc.split(',');
if (toEmailArray.length) {
toEmailArray.forEach(eachEmail => {
Expand All @@ -311,6 +330,14 @@ export class GeneratedComponent implements OnInit, OnDestroy {
}
}

bccEmailEmpty() {
this.emailModalData.bcc = this.emailModalData.bcc.trim();
if (this.emailModalData.bcc === '') {
this.bccValidEmailCounter = 0;
this.bccInvalidEmailCounter = 0;
}
}

createPurchaseOrderVend() {
if (!this.totalApprovedLineItems) {
this.toastr.error('Please approve at least one item to send order to supplier');
Expand Down

0 comments on commit 3d91734

Please sign in to comment.