-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ngrid): re-structure datasource code
- Loading branch information
1 parent
fc259ba
commit 6194f0e
Showing
24 changed files
with
129 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types'; | ||
export { PblDataSourceAdapter } from './adapter'; |
7 changes: 4 additions & 3 deletions
7
.../data-source/data-source-adapter.types.ts → ...core/src/lib/data-source/adapter/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 3 additions & 7 deletions
10
...b/data-source/data-source-base-factory.ts → .../core/src/lib/data-source/base/factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,40 @@ | ||
export * from './events'; | ||
|
||
export { | ||
PblDataSourceConfigurableTriggers, | ||
PblDataSourceTriggers, | ||
PblDataSourceTriggerChange, | ||
PblDataSourceTriggerChangedEvent, | ||
PblDataSourceTriggerChangedEventSource, | ||
PblDataSourceAdapterProcessedResult, | ||
PblDataSourceTriggerChangeHandler, | ||
} from './data-source-adapter.types'; | ||
export { PblDataSourceAdapter } from './data-source-adapter'; | ||
PblNgridPaginatorKind, | ||
PblPaginator, | ||
PblPaginatorChangeEvent, | ||
PblPagingPaginator, | ||
PblTokenPaginator, | ||
} from './triggers/pagination'; | ||
|
||
export { | ||
PblNgridSortInstructions, | ||
PblNgridSortDefinition, | ||
DataSourceFilterToken, | ||
DataSourcePredicate, | ||
DataSourceColumnPredicate, | ||
} from './triggers/filter'; | ||
|
||
export { | ||
PblNgridSortInstructions, | ||
PblNgridSortDefinition, | ||
PblNgridSorter, | ||
PblNgridDataSourceSortChange, | ||
PblNgridSortOrder, | ||
} from './types'; | ||
export { PblDataSource, PblDataSourceOptions, DataSourceOf } from './data-source'; | ||
export { PblDataSourceBaseFactory } from './data-source-base-factory'; | ||
applySort | ||
} from './triggers/sort'; | ||
|
||
export { | ||
PblDataSourceConfigurableTriggers, | ||
PblDataSourceTriggers, | ||
PblDataSourceTriggerChange, | ||
PblDataSourceTriggerChangedEvent, | ||
PblDataSourceTriggerChangedEventSource, | ||
PblDataSourceAdapterProcessedResult, | ||
PblDataSourceTriggerChangeHandler, | ||
PblDataSourceAdapter, | ||
} from './adapter/index'; | ||
|
||
export { DataSourceOf } from './types'; | ||
export { PblDataSource, PblDataSourceOptions } from './data-source'; | ||
export { PblDataSourceBaseFactory } from './base/factory'; | ||
export { PblDataSourceFactory, createDS } from './factory'; | ||
export { applySort, } from './sorting'; |
4 changes: 2 additions & 2 deletions
4
...rid/core/src/lib/data-source/filtering.ts → ...lib/data-source/triggers/filter/filter.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types'; | ||
export * from './filter'; |
25 changes: 25 additions & 0 deletions
25
libs/ngrid/core/src/lib/data-source/triggers/filter/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { PblColumnDefinition } from '../../../models/column'; | ||
|
||
/** | ||
* A function the return true then the value should be included in the result or false when not. | ||
* This is a single column filter predicated, returning false will filter out the entire row but the | ||
* predicate is only intended to filter a specific column. | ||
*/ | ||
export type DataSourceColumnPredicate = (filterValue: any, colValue: any, row?: any, col?: PblColumnDefinition) => boolean; | ||
|
||
/** | ||
* A function the return true then the row should be included in the result or false when not. | ||
* @param row The row in the data source that the filter apply on | ||
* @param properties A list of column instances (`PblColumnDefinition`) to filter values by. | ||
*/ | ||
export type DataSourcePredicate = (row: any, properties: PblColumnDefinition[]) => boolean; | ||
|
||
export type DataSourceFilterToken = undefined | DataSourcePredicate | any; | ||
|
||
export interface DataSourceFilterType { | ||
type: 'value' | 'predicate'; | ||
columns: PblColumnDefinition[]; | ||
filter: any | DataSourcePredicate; | ||
} | ||
|
||
export type DataSourceFilter = undefined | DataSourceFilterType ; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './types'; | ||
export * from './sort'; |
4 changes: 2 additions & 2 deletions
4
...ngrid/core/src/lib/data-source/sorting.ts → ...src/lib/data-source/triggers/sort/sort.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
libs/ngrid/core/src/lib/data-source/triggers/sort/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { PblColumnDefinition } from '../../../models/column'; | ||
|
||
export type PblNgridSortOrder = 'asc' | 'desc'; | ||
|
||
export interface PblNgridSortInstructions { | ||
order?: PblNgridSortOrder; | ||
} | ||
|
||
/** | ||
* Event fired when sort changes. | ||
*/ | ||
export interface PblNgridSortDefinition extends PblNgridSortInstructions { | ||
sortFn?: PblNgridSorter; | ||
} | ||
|
||
/** | ||
* A function that can sort a dataset based on `PblNgridSortInstructions` | ||
*/ | ||
export interface PblNgridSorter<T = any> { | ||
(column: PblColumnDefinition, sort: PblNgridSortInstructions, data: T[]): T[]; | ||
} | ||
|
||
export interface PblNgridDataSourceSortChange { | ||
column: PblColumnDefinition; | ||
sort: PblNgridSortDefinition; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,3 @@ | ||
import { PblColumnDefinition } from '../models/column'; | ||
import { Observable } from 'rxjs'; | ||
|
||
export type PblNgridSortOrder = 'asc' | 'desc'; | ||
|
||
export interface PblNgridSortInstructions { | ||
order?: PblNgridSortOrder; | ||
} | ||
|
||
/** | ||
* Event fired when sort changes. | ||
*/ | ||
export interface PblNgridSortDefinition extends PblNgridSortInstructions { | ||
sortFn?: PblNgridSorter; | ||
} | ||
|
||
/** | ||
* A function that can sort a dataset based on `PblNgridSortInstructions` | ||
*/ | ||
export interface PblNgridSorter<T = any> { | ||
(column: PblColumnDefinition, sort: PblNgridSortInstructions, data: T[]): T[]; | ||
} | ||
|
||
export interface PblNgridDataSourceSortChange { | ||
column: PblColumnDefinition; | ||
sort: PblNgridSortDefinition; | ||
} | ||
|
||
|
||
// FILTERING | ||
/** | ||
* A function the return true then the value should be included in the result or false when not. | ||
* This is a single column filter predicated, returning false will filter out the entire row but the | ||
* predicate is only intended to filter a specific column. | ||
*/ | ||
export type DataSourceColumnPredicate = (filterValue: any, colValue: any, row?: any, col?: PblColumnDefinition) => boolean; | ||
/** | ||
* A function the return true then the row should be included in the result or false when not. | ||
* @param row The row in the data source that the filter apply on | ||
* @param properties A list of column instances (`PblColumnDefinition`) to filter values by. | ||
*/ | ||
export type DataSourcePredicate = (row: any, properties: PblColumnDefinition[]) => boolean; | ||
|
||
export type DataSourceFilterToken = undefined | DataSourcePredicate | any; | ||
|
||
export interface DataSourceFilterType { | ||
type: 'value' | 'predicate'; | ||
columns: PblColumnDefinition[]; | ||
filter: any | DataSourcePredicate; | ||
} | ||
|
||
export type DataSourceFilter = undefined | DataSourceFilterType ; | ||
export type DataSourceOf<T> = T[] | Promise<T[]> | Observable<T[]>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...infinite-scroll/src/lib/infinite-scroll-data-source/infinite-scroll-datasource.factory.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters