Search This Blog

Thursday, July 21, 2022

splice vs. slice in JavaScript

Reference :  

https://www.educative.io/answers/splice-vs-slice-in-javascript

Angular: conditional class with *ngClass

 Reference:

https://stackoverflow.com/questions/35269179/angular-conditional-class-with-ngclass



One one

[class.my_class] = "step === 'step1'"

type two

[ngClass]="{'my_class': step === 'step1'}"

and multiple option:

[ngClass]="{'my_class': step === 'step1', 'my_class2' : step === 'step2' }"

type three

[ngClass]="{1 : 'my_class1', 2 : 'my_class2', 3 : 'my_class4'}[step]"

type four

[ngClass]="step == 'step1' ? 'my_class1' : 'my_class2'"

Tuesday, July 19, 2022

If else and else if in angular template in html

 if (foo === 1) {


} else if (bar === 99) {

} else if (foo === 2) {

} else {

}

in the template:

<ng-container *ngIf="foo === 1; else elseif1">foo === 1</ng-container>

<ng-template #elseif1>
    <ng-container *ngIf="bar === 99; else elseif2">bar === 99</ng-container>
</ng-template>
<ng-template #elseif2>
    <ng-container *ngIf="foo === 2; else else1">foo === 2</ng-container>
</ng-template>
<ng-template #else1>else</ng-template>



  <ng-container class="f-11" *ngIf="data.dcblWsp ==='' && data.cbrand1Wsp  === '' &&  data.billingPrice ==='0' else wsp">    
                                 
  <li> PD cannot be calculated because no WSP was captured for the district </li>  
  </ng-container>

                                                                 
  <ng-template #wsp>
                                     
  <li *ngIf="data.dcblWsp ==='' else noinvoice"> (Captured WSP - B1 WSP) is ignored as B1 WSP cannot be calculated  </li>
                                     
</ng-template>

<ng-template #noinvoice>
                                     
  <li  *ngIf="data.billingPrice ==='0'"> PD cannot be calculated because no invoices were generated for the district </li>
                                       
  </ng-template>



Reference:

https://stackoverflow.com/questions/43812770/ngif-else-if-in-template

Monday, July 18, 2022

how-to-add-a-property-to-each-object-in-an-array-of-objects-with-javascript

    

   this.pricingDetailData=res["pricedata"]; this.pricingDetailData.forEach((element:any) =>
    {
      let item = {

     
 
     
          "ASO":  [ "497", "26" ,"33", "497", "26" ,"33", "497", "26" ,"33", "50"],
          "TSM" : [ "497", "26" ,"33", "497", "26" ,"33", "497", "26" ,"33", "50"]
     
      }
   
       element.asoTsmData  = item;
    });                          https://thewebdev.info/2021/05/11/ how-to-add-a-property-to-each-object-in-an-array-of-objects-with-javascript/#:~:text=We%20can%20use%20the%20forEach,add%20a%20property%20to%20each.&text=We%20have%20the%20arr%20array,b%20property%20to%20a%20value.&text=according%20to%20the%20console%20log.                                                            

Thursday, June 2, 2022

Checkin Process

Checkin Process

======= =======


git status 


git add . (stage is nothing but saving a copy in my branch)


git commit -m "LZCTCPSCNT-645 and LZCTCPSCNT-1098 is fixed" 


git stash   (temporarily shelves (or stashes) changes you've made to your working copy) 


git checkout develop


git pull


git checkout bugfix/faizal-bugfixes


git rebase develop  (Git rebase and merge both integrate changes from one branch into another. Where they differ is how it's done. Git rebase moves a feature branch into a master. 

                     Git merge adds a new commit, preserving the history.)

 

Any Conflicts Appears:


   1. Resolve conflicts 

   2. Commit   - Git commit -m "merge the changes"

   3. Git rebase --continue

   4. Git push or git push --force

   


git push --force


git stash apply    (git stash temporarily shelves (or stashes) changes you've made to your working copy so you can work on something else,

                    and then come back and re-apply them later on.) 




Rebase steps


      Our Branch ( Front End Ui)

      git pull

      git push


Rebase branch name


git pull origin develop (branch)


Any Conflicts Appears:


          1. Resolve conflicts 

          2. Add the files

          3. Commit - Git commit -m "merge the changes"

    4. Git push or git push --force

    .

if its no conflict directly we can push

Saturday, May 28, 2022

Constructing the object to send the payload

 placeOrder()
  {
    let payload:any ={};
 
    payload['customerCode'] = this._storage.getCustomerCode();
    payload['contractNo'] = this.contractId;
    payload['ordType'] = "ZSPS";
 
   

    console.log(this.contractdetails.length);

    let items = [];

    for(let index = 0; index < this.contractdetails.length; index ++)
    {
     
      let item:any = {};

      item['itemNo']  = this.contractdetails[index].contOrderItmno;
      item['material'] = this.contractdetails[index].contOrderProduct;
      item['qty']  = this.contractdetails[index].SelectedQty ?  this.contractdetails[index].SelectedQty : 0;
 
      items.push(item);
     
    }

    payload['item'] = items;


   console.log(payload);

    this._authService.contractOrder(payload).subscribe((res:any)=>
    {
        let id:any = res.body.salesdocument;
        let remark:any = res.body.remark;
        let trackLink = res.body.trackLink;
        this.contGSTMessage =  res.body.contGSTMessage;
        this.orderTotal = this.orderTotal ? this.orderTotal : 0;

        if(res.body.error && res.body.error.length > 0)
        {
          this._PromptService.openDialog({title : 'ORDER NOT CREATED',
           url :this.redirecturl,
         
          btnLabel : 'OK',
          type : false,  
          status: false,  
          content: `${res.body.error[0].message}`})
        }

else
{
  this._PromptService.openDialog({title : 'ORDER CONFIRMED!', url :this.redirecturl, type : true, btnLabel1 : 'CLOSE',  status: false,  content: `Your Order for ${this.orderQuantity} items 0f <b class="amount-value"> ₹ ${this.orderTotal}/- </b> (${this.contGSTMessage}) has been confirmed. Your order ID is <b>${id}.</b> You can track the same via whatsapp @ <a class="cursor-pointer" href ='http://${trackLink}' target="_blank"> ${trackLink} </a>`})
}
     
    })
   
  }

Tuesday, May 10, 2022

Angular Router

 

<a [routerLink]="['/auth/login']" class="btn btn-link" class="btn btn-link"> Back to Home</a>

Validating to select in sequencial order using angular

    < input type = "checkbox" (change) = "handleSelectTaskItem($event, taskItem)" [checked] = " taskItem . i...