bways-grid 0.0.15 → 0.0.16
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/fesm2022/bways-grid.mjs
CHANGED
|
@@ -2755,6 +2755,11 @@ class UltraGridComponent {
|
|
|
2755
2755
|
activeFilters = new Map();
|
|
2756
2756
|
// Tracks condition-based filters per column
|
|
2757
2757
|
conditionFilters = new Map();
|
|
2758
|
+
/**
|
|
2759
|
+
* Input to apply filters via a JSON object or string.
|
|
2760
|
+
* Expected format: { activeFilters: Record<string, any[]>, conditionFilters: Record<string, ColumnConditionFilter> }
|
|
2761
|
+
*/
|
|
2762
|
+
filterModel;
|
|
2758
2763
|
isChooseColumnsOpen = false;
|
|
2759
2764
|
chooseColumnsPosition = { x: 0, y: 0 };
|
|
2760
2765
|
destroy$ = new Subject();
|
|
@@ -2803,8 +2808,6 @@ class UltraGridComponent {
|
|
|
2803
2808
|
if (this.sortingWorker) {
|
|
2804
2809
|
this.sortingWorker.postMessage({ action: 'INIT', rows: this._mappedRowData });
|
|
2805
2810
|
}
|
|
2806
|
-
// We do not immediately `applyLocalData()` here anymore if we have a worker,
|
|
2807
|
-
// because INIT needs to finish first. If no worker, we apply directly.
|
|
2808
2811
|
if (!this.sortingWorker) {
|
|
2809
2812
|
this.applyLocalData();
|
|
2810
2813
|
}
|
|
@@ -2812,6 +2815,13 @@ class UltraGridComponent {
|
|
|
2812
2815
|
this.ssrData = this.renderedLocalData.slice(0, 50);
|
|
2813
2816
|
}
|
|
2814
2817
|
}
|
|
2818
|
+
// If filters are changed from outside (e.g. loading a report), refresh the grid
|
|
2819
|
+
if (changes['activeFilters'] || changes['conditionFilters']) {
|
|
2820
|
+
this.applyLocalData();
|
|
2821
|
+
}
|
|
2822
|
+
if (changes['filterModel'] && this.filterModel) {
|
|
2823
|
+
this.applyImportedFilters(this.filterModel);
|
|
2824
|
+
}
|
|
2815
2825
|
}
|
|
2816
2826
|
ngOnDestroy() {
|
|
2817
2827
|
this.destroy$.next();
|
|
@@ -3628,19 +3638,29 @@ class UltraGridComponent {
|
|
|
3628
3638
|
applyImportedFilters(data) {
|
|
3629
3639
|
if (!data)
|
|
3630
3640
|
return;
|
|
3641
|
+
let parsedData = data;
|
|
3642
|
+
if (typeof data === 'string') {
|
|
3643
|
+
try {
|
|
3644
|
+
parsedData = JSON.parse(data);
|
|
3645
|
+
}
|
|
3646
|
+
catch (err) {
|
|
3647
|
+
console.error('Error parsing filter JSON string:', err);
|
|
3648
|
+
return;
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3631
3651
|
try {
|
|
3632
3652
|
// Restore activeFilters (Record -> Map<string, Set>)
|
|
3633
3653
|
// Important: We create a NEW Map instance to trigger Output/Input change detection
|
|
3634
3654
|
const newActiveFilters = new Map();
|
|
3635
|
-
if (
|
|
3636
|
-
Object.keys(
|
|
3637
|
-
newActiveFilters.set(field, new Set(
|
|
3655
|
+
if (parsedData.activeFilters) {
|
|
3656
|
+
Object.keys(parsedData.activeFilters).forEach(field => {
|
|
3657
|
+
newActiveFilters.set(field, new Set(parsedData.activeFilters[field]));
|
|
3638
3658
|
});
|
|
3639
3659
|
}
|
|
3640
3660
|
this.activeFilters = newActiveFilters;
|
|
3641
3661
|
// Restore conditionFilters (Object -> Map)
|
|
3642
|
-
if (
|
|
3643
|
-
this.conditionFilters = new Map(Object.entries(
|
|
3662
|
+
if (parsedData.conditionFilters) {
|
|
3663
|
+
this.conditionFilters = new Map(Object.entries(parsedData.conditionFilters));
|
|
3644
3664
|
}
|
|
3645
3665
|
else {
|
|
3646
3666
|
this.conditionFilters = new Map();
|
|
@@ -3653,11 +3673,10 @@ class UltraGridComponent {
|
|
|
3653
3673
|
}
|
|
3654
3674
|
catch (err) {
|
|
3655
3675
|
console.error('Error applying imported filters:', err);
|
|
3656
|
-
alert('Error importing report. Please ensure the JSON file is valid.');
|
|
3657
3676
|
}
|
|
3658
3677
|
}
|
|
3659
3678
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.18", ngImport: i0, type: UltraGridComponent, deps: [{ token: PLATFORM_ID }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GridFlattenerService }, { token: ExcelExportService }], target: i0.ɵɵFactoryTarget.Component });
|
|
3660
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: UltraGridComponent, isStandalone: true, selector: "bways-grid", inputs: { columns: "columns", rowData: "rowData", serverDataSource: "serverDataSource", config: "config", pagination: "pagination", pageSize: "pageSize", groupModel: "groupModel", valuesModel: "valuesModel", pivotColumns: "pivotColumns" }, outputs: { rowClicked: "rowClicked", sortChanged: "sortChanged", selectionChanged: "selectionChanged", reportSaved: "reportSaved" }, viewQueries: [{ propertyName: "headerElement", first: true, predicate: ["headerComponent"], descendants: true, read: ElementRef }, { propertyName: "viewport", first: true, predicate: ["viewport"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
3679
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.18", type: UltraGridComponent, isStandalone: true, selector: "bways-grid", inputs: { columns: "columns", rowData: "rowData", serverDataSource: "serverDataSource", config: "config", pagination: "pagination", pageSize: "pageSize", groupModel: "groupModel", valuesModel: "valuesModel", pivotColumns: "pivotColumns", activeFilters: "activeFilters", conditionFilters: "conditionFilters", filterModel: "filterModel" }, outputs: { rowClicked: "rowClicked", sortChanged: "sortChanged", selectionChanged: "selectionChanged", reportSaved: "reportSaved" }, viewQueries: [{ propertyName: "headerElement", first: true, predicate: ["headerComponent"], descendants: true, read: ElementRef }, { propertyName: "viewport", first: true, predicate: ["viewport"], descendants: true }], usesOnChanges: true, ngImport: i0, template: `
|
|
3661
3680
|
<div class="ug-wrapper" [ngClass]="config.theme || 'ag-theme-alpine'">
|
|
3662
3681
|
|
|
3663
3682
|
<div class="ug-main">
|
|
@@ -3953,6 +3972,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.18", ngImpo
|
|
|
3953
3972
|
type: Input
|
|
3954
3973
|
}], pivotColumns: [{
|
|
3955
3974
|
type: Input
|
|
3975
|
+
}], activeFilters: [{
|
|
3976
|
+
type: Input
|
|
3977
|
+
}], conditionFilters: [{
|
|
3978
|
+
type: Input
|
|
3979
|
+
}], filterModel: [{
|
|
3980
|
+
type: Input
|
|
3956
3981
|
}] } });
|
|
3957
3982
|
|
|
3958
3983
|
const COMPONENTS = [
|