ngx-render-material-forms 1.4.8 → 1.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Injectable, Component, Input, ViewChild, ViewContainerRef, ViewChildren, EventEmitter, Output, forwardRef, Directive, Inject, Optional, NgModule } from '@angular/core';
3
3
  import * as i1$1 from '@angular/common/http';
4
- import { HttpClientModule } from '@angular/common/http';
4
+ import { HttpHeaders, HttpClientModule } from '@angular/common/http';
5
5
  import * as i1 from '@angular/common';
6
6
  import { CommonModule } from '@angular/common';
7
7
  import * as i2 from '@angular/forms';
@@ -82,6 +82,8 @@ import SelectBoxesComponent from 'formiojs/components/selectboxes/SelectBoxes.js
82
82
  import SelectComponent from 'formiojs/components/select/Select.js';
83
83
  import { Subject } from 'rxjs';
84
84
  import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
85
+ import * as CryptoJS from 'crypto-js';
86
+ import { isNullOrUndefined } from 'util';
85
87
  import * as i9 from 'ngx-mat-select-search';
86
88
  import { NgxMatSelectSearchModule } from 'ngx-mat-select-search';
87
89
  import WellComponent from 'formiojs/components/well/Well.js';
@@ -2556,8 +2558,8 @@ class MaterialSelectComponent extends MaterialComponent {
2556
2558
  // Variable to hold the reference to the current panel element
2557
2559
  this.currentPanelElement = null;
2558
2560
  this.openCounter = 1;
2559
- // this.holy = CryptoJS.enc.Base64.parse('8F/2+T2NXqUBQERR12R4sw==');
2560
- // this.grail = CryptoJS.enc.Base64.parse('yE0CgQbYzK5wqeoKTVzhOQ==');
2561
+ this.holy = CryptoJS.enc.Base64.parse('8F/2+T2NXqUBQERR12R4sw==');
2562
+ this.grail = CryptoJS.enc.Base64.parse('yE0CgQbYzK5wqeoKTVzhOQ==');
2561
2563
  }
2562
2564
  onInputChange(event) {
2563
2565
  if (this.instance.component.key.toLowerCase() === 'vendorproductid' && event.target.value === '') {
@@ -2569,29 +2571,28 @@ class MaterialSelectComponent extends MaterialComponent {
2569
2571
  this.onClearAll();
2570
2572
  }
2571
2573
  }
2572
- // scrumble(msg) {
2573
- // if (!isNullOrUndefined(msg)) {
2574
- // var conceal = this.getcampaign(msg, this.holy, this.grail);
2575
- // var sha256 = CryptoJS.HmacSHA256(CryptoJS.enc.Base64.stringify(this.grail) + conceal.toString(), CryptoJS.enc.Base64.stringify(this.holy));
2576
- // var hashInBase64 = CryptoJS.enc.Base64.stringify(sha256);
2577
- // let keyValue = {
2578
- // "value": conceal.toString(),
2579
- // "mac": hashInBase64
2580
- // };
2581
- // var result = JSON.stringify(keyValue);
2582
- // var jumbled = CryptoJS.enc.Utf8.parse(result);
2583
- // return CryptoJS.enc.Base64.stringify(jumbled);
2584
- // }
2585
- // }
2586
- // getcampaign(data: any, holy: any, grail: any) {
2587
- // return CryptoJS.AES.encrypt(data.toString(), holy,
2588
- // {
2589
- // blockSize: 128,
2590
- // iv: grail,
2591
- // mode: CryptoJS.mode.CBC,
2592
- // padding: CryptoJS.pad.Pkcs7
2593
- // });
2594
- // }
2574
+ scrumble(msg) {
2575
+ if (!isNullOrUndefined(msg)) {
2576
+ var conceal = this.getcampaign(msg, this.holy, this.grail);
2577
+ var sha256 = CryptoJS.HmacSHA256(CryptoJS.enc.Base64.stringify(this.grail) + conceal.toString(), CryptoJS.enc.Base64.stringify(this.holy));
2578
+ var hashInBase64 = CryptoJS.enc.Base64.stringify(sha256);
2579
+ let keyValue = {
2580
+ "value": conceal.toString(),
2581
+ "mac": hashInBase64
2582
+ };
2583
+ var result = JSON.stringify(keyValue);
2584
+ var jumbled = CryptoJS.enc.Utf8.parse(result);
2585
+ return CryptoJS.enc.Base64.stringify(jumbled);
2586
+ }
2587
+ }
2588
+ getcampaign(data, holy, grail) {
2589
+ return CryptoJS.AES.encrypt(data.toString(), holy, {
2590
+ blockSize: 128,
2591
+ iv: grail,
2592
+ mode: CryptoJS.mode.CBC,
2593
+ padding: CryptoJS.pad.Pkcs7
2594
+ });
2595
+ }
2595
2596
  registerPanelScrollEvent(selectElem) {
2596
2597
  const panelElement = selectElem.panel.nativeElement;
2597
2598
  panelElement.addEventListener('scroll', this.onScroll.bind(this));
@@ -2630,78 +2631,75 @@ class MaterialSelectComponent extends MaterialComponent {
2630
2631
  return item ? item.value : null;
2631
2632
  }
2632
2633
  loadData(pageNumber, pageSize, searchQuery) {
2633
- // const paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
2634
- // const includeDescription = this.getValueByKey(paramsData, 'includeDescription');
2635
- // const vendorId = this.getValueByKey(paramsData, 'vendorId');
2636
- // const onlyActive = this.getValueByKey(paramsData, 'onlyActive');
2637
- // var currentUser = JSON.parse(localStorage.getItem('currentUser'));
2638
- // let headers;
2639
- // if (currentUser && currentUser.Tokens && currentUser.Tokens.AccessToken) {
2640
- // var accessToken = currentUser.Tokens.AccessToken;
2641
- // headers = new HttpHeaders({
2642
- // 'Content-Type': 'application/json',
2643
- // 'Authorization': 'Bearer ' + accessToken
2644
- // });
2645
- // } else {
2646
- // console.error('User not authenticated or tokens missing.');
2647
- // }
2648
- // const envendorId = this.scrumble(vendorId)
2649
- // const enpageNumber = this.scrumble(pageNumber)
2650
- // const enpageSize = this.scrumble(pageSize);
2651
- // const ensearchQuery = this.scrumble(searchQuery);
2652
- // let enactive = this.scrumble(onlyActive);
2653
- // //Check if enactive is undefined, null, or blank
2654
- // if (enactive === undefined || enactive === null || enactive === '') {
2655
- // enactive = this.scrumble(true); // Set default value to true
2656
- // }
2657
- // // Scrumble and handle the includeDescription parameter
2658
- // let endescription = this.scrumble(includeDescription);
2659
- // if (!endescription) {
2660
- // endescription = this.scrumble(false); // Set to 'false' if undefined, null, or blank
2661
- // }
2662
- // const baseUrlMapping = {
2663
- // 'localhost': 'http://localhost:58504',
2664
- // 'lincoln.vartopia.com': 'https://lincoln-api.vartopia.com',
2665
- // 'stage.vartopia.com': 'https://stage-api.vartopia.com',
2666
- // 'my.vartopia.com': 'https://reagan-api.vartopia.com',
2667
- // 'jackson.vartopia.com': 'https://jackson-api.vartopia.com'
2668
- // };
2669
- // // Get the current hostname
2670
- // const hostname = window.location.hostname;
2671
- // const baseApiUrl = baseUrlMapping[hostname] || null;
2672
- // interface VendorProductsResponse {
2673
- // code: number;
2674
- // data: any;
2675
- // message: string;
2676
- // statusCode: number;
2677
- // }
2678
- // this.http.get<VendorProductsResponse>(`${baseApiUrl}/api/VendorFormBuilder/GetVendorProducts?vendorId=${envendorId}&pageNumber=${enpageNumber}&pageSize=${enpageSize}&search=${ensearchQuery}&onlyActive=${enactive}&includeDescription=${endescription}`, { headers }).subscribe(response => {
2679
- // if (response && response.code === 200) {
2680
- // if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
2681
- // this.totalPages = response?.data?.totalPages;
2682
- // const data = response.data.dataSource;
2683
- // this.filteredOptionsLength = data.length;
2684
- // if (this.productList.length > 0) {
2685
- // data.map(item => {
2686
- // return item
2687
- // }).forEach(i => this.productList.push(i))
2688
- // } else {
2689
- // this.productList = data;
2690
- // }
2691
- // // Update filteredOptions with transformedData
2692
- // var allProductList = this.transformResponseData(this.productList);
2693
- // this.filteredOptions = Promise.resolve(allProductList);
2694
- // this.searching = false;
2695
- // this.productsloadingFlag = true;
2696
- // setTimeout(() => {
2697
- // const ele = this.selectElem.panel.nativeElement;
2698
- // const trackHeight = ele.scrollHeight - ele.offsetHeight
2699
- // const middlePosition = trackHeight / 2 - 50;
2700
- // ele.scrollTo({ top: middlePosition, behavior: 'auto' });
2701
- // }, 250);
2702
- // }
2703
- // }
2704
- // });
2634
+ const paramsData = JSON.parse(localStorage.getItem('productPickerParams'));
2635
+ const includeDescription = this.getValueByKey(paramsData, 'includeDescription');
2636
+ const vendorId = this.getValueByKey(paramsData, 'vendorId');
2637
+ const onlyActive = this.getValueByKey(paramsData, 'onlyActive');
2638
+ var currentUser = JSON.parse(localStorage.getItem('currentUser'));
2639
+ let headers;
2640
+ if (currentUser && currentUser.Tokens && currentUser.Tokens.AccessToken) {
2641
+ var accessToken = currentUser.Tokens.AccessToken;
2642
+ headers = new HttpHeaders({
2643
+ 'Content-Type': 'application/json',
2644
+ 'Authorization': 'Bearer ' + accessToken
2645
+ });
2646
+ }
2647
+ else {
2648
+ console.error('User not authenticated or tokens missing.');
2649
+ }
2650
+ const envendorId = this.scrumble(vendorId);
2651
+ const enpageNumber = this.scrumble(pageNumber);
2652
+ const enpageSize = this.scrumble(pageSize);
2653
+ const ensearchQuery = this.scrumble(searchQuery);
2654
+ let enactive = this.scrumble(onlyActive);
2655
+ //Check if enactive is undefined, null, or blank
2656
+ if (enactive === undefined || enactive === null || enactive === '') {
2657
+ enactive = this.scrumble(true); // Set default value to true
2658
+ }
2659
+ // Scrumble and handle the includeDescription parameter
2660
+ let endescription = this.scrumble(includeDescription);
2661
+ if (!endescription) {
2662
+ endescription = this.scrumble(false); // Set to 'false' if undefined, null, or blank
2663
+ }
2664
+ const baseUrlMapping = {
2665
+ 'localhost': 'http://localhost:58504',
2666
+ 'lincoln.vartopia.com': 'https://lincoln-api.vartopia.com',
2667
+ 'stage.vartopia.com': 'https://stage-api.vartopia.com',
2668
+ 'my.vartopia.com': 'https://reagan-api.vartopia.com',
2669
+ 'jackson.vartopia.com': 'https://jackson-api.vartopia.com'
2670
+ };
2671
+ // Get the current hostname
2672
+ const hostname = window.location.hostname;
2673
+ const baseApiUrl = baseUrlMapping[hostname] || null;
2674
+ this.http.get(`${baseApiUrl}/api/VendorFormBuilder/GetVendorProducts?vendorId=${envendorId}&pageNumber=${enpageNumber}&pageSize=${enpageSize}&search=${ensearchQuery}&onlyActive=${enactive}&includeDescription=${endescription}`, { headers }).subscribe(response => {
2675
+ var _a;
2676
+ if (response && response.code === 200) {
2677
+ if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
2678
+ this.totalPages = (_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.totalPages;
2679
+ const data = response.data.dataSource;
2680
+ this.filteredOptionsLength = data.length;
2681
+ if (this.productList.length > 0) {
2682
+ data.map(item => {
2683
+ return item;
2684
+ }).forEach(i => this.productList.push(i));
2685
+ }
2686
+ else {
2687
+ this.productList = data;
2688
+ }
2689
+ // Update filteredOptions with transformedData
2690
+ var allProductList = this.transformResponseData(this.productList);
2691
+ this.filteredOptions = Promise.resolve(allProductList);
2692
+ this.searching = false;
2693
+ this.productsloadingFlag = true;
2694
+ setTimeout(() => {
2695
+ const ele = this.selectElem.panel.nativeElement;
2696
+ const trackHeight = ele.scrollHeight - ele.offsetHeight;
2697
+ const middlePosition = trackHeight / 2 - 50;
2698
+ ele.scrollTo({ top: middlePosition, behavior: 'auto' });
2699
+ }, 250);
2700
+ }
2701
+ }
2702
+ });
2705
2703
  }
2706
2704
  // Utility function to transform response data
2707
2705
  transformResponseData(data) {