ngx-render-material-forms 1.3.0 → 1.3.2
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.
- package/esm2020/lib/components/select/select.component.mjs +51 -28
- package/fesm2015/ngx-render-material-forms.js +50 -27
- package/fesm2015/ngx-render-material-forms.mjs.map +1 -1
- package/fesm2020/ngx-render-material-forms.js +50 -27
- package/fesm2020/ngx-render-material-forms.mjs.map +1 -1
- package/lib/components/select/select.component.d.ts +2 -0
- package/package.json +1 -1
|
@@ -81,7 +81,7 @@ import RadioComponent from 'formiojs/components/radio/Radio.js';
|
|
|
81
81
|
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
|
-
import { debounceTime,
|
|
84
|
+
import { debounceTime, distinctUntilChanged, takeUntil } from 'rxjs/operators';
|
|
85
85
|
import * as CryptoJS from 'crypto-js';
|
|
86
86
|
import { isNullOrUndefined } from 'util';
|
|
87
87
|
import * as i9 from 'ngx-mat-select-search';
|
|
@@ -2539,8 +2539,10 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2539
2539
|
this.grail = '';
|
|
2540
2540
|
this.productsloadingFlag = false;
|
|
2541
2541
|
this.searching = false;
|
|
2542
|
+
this.productList = [];
|
|
2542
2543
|
// Variable to hold the reference to the current panel element
|
|
2543
2544
|
this.currentPanelElement = null;
|
|
2545
|
+
this.openCounter = 1;
|
|
2544
2546
|
this.holy = CryptoJS.enc.Base64.parse('8F/2+T2NXqUBQERR12R4sw==');
|
|
2545
2547
|
this.grail = CryptoJS.enc.Base64.parse('yE0CgQbYzK5wqeoKTVzhOQ==');
|
|
2546
2548
|
}
|
|
@@ -2584,14 +2586,23 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2584
2586
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
|
|
2585
2587
|
const scrollElement = event.target;
|
|
2586
2588
|
const trackHeight = scrollElement.scrollHeight - scrollElement.offsetHeight;
|
|
2589
|
+
if (this.openCounter < 2) {
|
|
2590
|
+
const retrievedObject = JSON.parse(localStorage.getItem('storageObject'));
|
|
2591
|
+
this.totalPages = Number(retrievedObject?.totalPages);
|
|
2592
|
+
this.productsloadingFlag = true;
|
|
2593
|
+
this.productList = retrievedObject?.dataSource;
|
|
2594
|
+
}
|
|
2587
2595
|
if (this.productsloadingFlag && Math.floor(scrollElement.scrollTop / trackHeight * 100) > 50) {
|
|
2588
2596
|
this.productsloadingFlag = false;
|
|
2597
|
+
this.openCounter = this.openCounter + 1;
|
|
2589
2598
|
if (this.pageNumber < this.totalPages) {
|
|
2590
2599
|
this.pageNumber = this.pageNumber + 1;
|
|
2600
|
+
this.searching = true;
|
|
2591
2601
|
this.loadData(this.pageNumber, this.pageSize, this.searchQuery);
|
|
2592
2602
|
}
|
|
2593
2603
|
else {
|
|
2594
2604
|
this.productsloadingFlag = true;
|
|
2605
|
+
this.searching = false;
|
|
2595
2606
|
}
|
|
2596
2607
|
}
|
|
2597
2608
|
}
|
|
@@ -2610,11 +2621,17 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2610
2621
|
const vendorId = this.getValueByKey(paramsData, 'vendorId');
|
|
2611
2622
|
const onlyActive = this.getValueByKey(paramsData, 'onlyActive');
|
|
2612
2623
|
var currentUser = JSON.parse(localStorage.getItem('currentUser'));
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2624
|
+
let headers;
|
|
2625
|
+
if (currentUser && currentUser.Tokens && currentUser.Tokens.AccessToken) {
|
|
2626
|
+
var accessToken = currentUser.Tokens.AccessToken;
|
|
2627
|
+
headers = new HttpHeaders({
|
|
2628
|
+
'Content-Type': 'application/json',
|
|
2629
|
+
'Authorization': 'Bearer ' + accessToken
|
|
2630
|
+
});
|
|
2631
|
+
}
|
|
2632
|
+
else {
|
|
2633
|
+
console.error('User not authenticated or tokens missing.');
|
|
2634
|
+
}
|
|
2618
2635
|
const envendorId = this.scrumble(vendorId);
|
|
2619
2636
|
const enpageNumber = this.scrumble(pageNumber);
|
|
2620
2637
|
const enpageSize = this.scrumble(pageSize);
|
|
@@ -2644,25 +2661,26 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2644
2661
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
|
|
2645
2662
|
this.totalPages = response?.data?.totalPages;
|
|
2646
2663
|
const data = response.data.dataSource;
|
|
2647
|
-
|
|
2648
|
-
this.
|
|
2664
|
+
this.filteredOptionsLength = data.length;
|
|
2665
|
+
if (this.productList.length > 0) {
|
|
2666
|
+
data.map(item => {
|
|
2667
|
+
return item;
|
|
2668
|
+
}).forEach(i => this.productList.push(i));
|
|
2669
|
+
}
|
|
2670
|
+
else {
|
|
2671
|
+
this.productList = data;
|
|
2672
|
+
}
|
|
2649
2673
|
// Update filteredOptions with transformedData
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
value: item.value,
|
|
2653
|
-
date: item.date
|
|
2654
|
-
})));
|
|
2674
|
+
var allProductList = this.transformResponseData(this.productList);
|
|
2675
|
+
this.filteredOptions = Promise.resolve(allProductList);
|
|
2655
2676
|
this.searching = false;
|
|
2656
|
-
// Update filteredOptions with transformedData
|
|
2657
|
-
// this.filteredOptions = this.filteredOptions.then(existingOptions => {
|
|
2658
|
-
// const newOptions = transformedData.map(item => ({
|
|
2659
|
-
// label: item.label,
|
|
2660
|
-
// value: item.value,
|
|
2661
|
-
// date: item.date
|
|
2662
|
-
// }));
|
|
2663
|
-
// return existingOptions.concat(newOptions);
|
|
2664
|
-
// });
|
|
2665
2677
|
this.productsloadingFlag = true;
|
|
2678
|
+
setTimeout(() => {
|
|
2679
|
+
const ele = this.selectElem.panel.nativeElement;
|
|
2680
|
+
const trackHeight = ele.scrollHeight - ele.offsetHeight;
|
|
2681
|
+
const middlePosition = trackHeight / 2 - 50;
|
|
2682
|
+
ele.scrollTo({ top: middlePosition, behavior: 'auto' });
|
|
2683
|
+
}, 250);
|
|
2666
2684
|
}
|
|
2667
2685
|
}
|
|
2668
2686
|
});
|
|
@@ -2708,6 +2726,8 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2708
2726
|
this.pageNumber = 1;
|
|
2709
2727
|
this.pageSize = 20;
|
|
2710
2728
|
this.searchQuery = '';
|
|
2729
|
+
this.searching = false;
|
|
2730
|
+
this.productList = [];
|
|
2711
2731
|
this.loadData(this.pageNumber, this.pageSize, this.searchQuery);
|
|
2712
2732
|
}
|
|
2713
2733
|
}
|
|
@@ -2715,16 +2735,16 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2715
2735
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
|
|
2716
2736
|
this.selectElem.openedChange.subscribe((isOpen) => {
|
|
2717
2737
|
if (isOpen) {
|
|
2718
|
-
this.pageNumber =
|
|
2738
|
+
this.pageNumber = 2;
|
|
2719
2739
|
this.pageSize = 20;
|
|
2720
2740
|
this.searchQuery = '';
|
|
2721
|
-
this.searching =
|
|
2722
|
-
this.loadData(this.pageNumber, this.pageSize, this.searchQuery);
|
|
2741
|
+
this.searching = false;
|
|
2742
|
+
//this.loadData(this.pageNumber, this.pageSize, this.searchQuery);
|
|
2723
2743
|
this.registerPanelScrollEvent(this.selectElem);
|
|
2724
2744
|
}
|
|
2725
2745
|
else {
|
|
2726
2746
|
this.removePanelScrollEvent();
|
|
2727
|
-
|
|
2747
|
+
this.searching = false;
|
|
2728
2748
|
}
|
|
2729
2749
|
});
|
|
2730
2750
|
}
|
|
@@ -2741,11 +2761,14 @@ class MaterialSelectComponent extends MaterialComponent {
|
|
|
2741
2761
|
if (this.instance.component.key.toLowerCase() === 'vendorproductid') {
|
|
2742
2762
|
this.websiteMultiFilterCtrl.valueChanges
|
|
2743
2763
|
.pipe(debounceTime(1000), // Time in milliseconds between key events
|
|
2744
|
-
tap(() => this.searching = true),
|
|
2764
|
+
// tap(() => this.searching = true),
|
|
2765
|
+
distinctUntilChanged(), takeUntil(this._onDestroy))
|
|
2745
2766
|
.subscribe((searchQuery) => {
|
|
2746
2767
|
if (searchQuery != '') {
|
|
2747
2768
|
this.pageNumber = 1;
|
|
2748
2769
|
this.pageSize = 20;
|
|
2770
|
+
this.productList = [];
|
|
2771
|
+
this.searching = true;
|
|
2749
2772
|
this.loadData(this.pageNumber, this.pageSize, searchQuery);
|
|
2750
2773
|
}
|
|
2751
2774
|
});
|