-
Notifications
You must be signed in to change notification settings - Fork 674
GridCore data: Remove DataSourceAdapter dynamic member-copy and type _dataSource
#34980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
bit-byte0
wants to merge
10
commits into
DevExpress:main
Choose a base branch
from
bit-byte0:refactor/gridcore-datacontroller-type-datasource-adapter-26_2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2c4531d
refactor(dataSourceAdapter): replace dynamic member-copy with explici…
bit-byte0 57d2a99
refactor(dataController): type _dataSource as DataSourceAdapter
bit-byte0 9f1bee8
Merge remote-tracking branch 'upstream/main' into refactor/gridcore-d…
bit-byte0 3ca0c3b
fix(dataSourceAdapter): add beginLoading/endLoading delegates missed …
bit-byte0 1a292cc
fix(dataController): allow null _dataSource + complete MockGridDataSo…
bit-byte0 ae2208c
refactor(dataController): carry null in narrowed _dataSource decls + …
bit-byte0 8cde228
refactor(dataController): use arguments as any for delegation to matc…
bit-byte0 d70bd1b
refactor(dataController): address review - @ts-expect-error over cast…
bit-byte0 f712140
revert(data): restore DataSource enumerable-member shim - viz/vectorM…
bit-byte0 e8fad59
fix(dataController): bind adapter this in loadAll error handler
bit-byte0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -33,7 +33,6 @@ import type { | |
| CallbackFlags, | ||
| DataChange, | ||
| DataFilter, | ||
| DataSourceAdapterLike, | ||
| GeneratedItem, | ||
| ItemChange, | ||
| ItemProcessingOptions, | ||
|
|
@@ -66,8 +65,7 @@ import { | |
| import { generateRowValues } from './utils/row_values'; | ||
|
|
||
| export class DataController extends modules.Controller { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| public _dataSource?: any; | ||
| public _dataSource?: DataSourceAdapter | null; | ||
|
|
||
| protected isSharedDataSource?: boolean; | ||
|
|
||
|
|
@@ -188,7 +186,8 @@ export class DataController extends modules.Controller { | |
| * @extended: virtual_scrolling | ||
| */ | ||
| protected _getPagingOptionValue(optionName: PagingOptionName): number { | ||
| return this._dataSource[optionName]() as number; | ||
| // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
| return this._dataSource![optionName]() as number; | ||
| } | ||
|
|
||
| protected callbackNames(): string[] { | ||
|
|
@@ -333,8 +332,7 @@ export class DataController extends modules.Controller { | |
| } | ||
|
|
||
| public getDataSource(): DataSource | null | undefined { | ||
| const adapter: DataSourceAdapterLike | null | undefined = this._dataSource; | ||
| return adapter ? adapter._dataSource : null; | ||
| return this._dataSource?._dataSource; | ||
| } | ||
|
|
||
| public getCombinedFilter(returnDataField?: boolean): DataFilter { | ||
|
|
@@ -418,6 +416,9 @@ export class DataController extends modules.Controller { | |
| private readonly customizeStoreLoadOptionsHandler = (e: LoadOperation): void => { | ||
| const columnsController = this._columnsController; | ||
| const dataSource = this._dataSource; | ||
| if (!dataSource) { | ||
| return; | ||
| } | ||
| const { storeLoadOptions } = e; | ||
|
|
||
| if (e.isCustomLoading && !storeLoadOptions.isLoadingAll) { | ||
|
|
@@ -726,7 +727,7 @@ export class DataController extends modules.Controller { | |
| dataSource.load().done((...args: unknown[]) => { | ||
| this._isPaging = false; | ||
| result.resolve(...args); | ||
| }).fail(result.reject); | ||
| }).fail((...args: unknown[]) => { result.reject(...args); }); | ||
| } else { | ||
| result.resolve(); | ||
| } | ||
|
|
@@ -1478,7 +1479,7 @@ export class DataController extends modules.Controller { | |
| } | ||
|
|
||
| public pageCount(): number { | ||
| return this._dataSource ? this._dataSource.pageCount() as number : 1; | ||
| return this._dataSource ? this._dataSource.pageCount() : 1; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
|
|
@@ -1525,15 +1526,15 @@ export class DataController extends modules.Controller { | |
| requireTotalCount: false, | ||
| }; | ||
| dataSource.load(loadOptions) | ||
| .done((loadedItems: RawItemData[], extra: LoadOperation['extra']): void => { | ||
| .done((loadedItems: unknown, extra: unknown): void => { | ||
| const items = this._processItems( | ||
| this._beforeProcessItems(loadedItems), | ||
| this._beforeProcessItems(loadedItems as RawItemData[]), | ||
| { changeType: 'loadingAll' }, | ||
| ); | ||
| // @ts-expect-error DataGrid-only summary leaks into grid_core | ||
| d.resolve(items, extra?.summary); | ||
| d.resolve(items, (extra as LoadOperation['extra'])?.summary); | ||
| }) | ||
| .fail(d.reject); | ||
| .fail(d.reject as (...args: unknown[]) => void); | ||
|
Comment on lines
1528
to
+1537
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can keep these |
||
| } else { | ||
| d.reject(); | ||
| } | ||
|
|
@@ -1628,7 +1629,8 @@ export class DataController extends modules.Controller { | |
| this._skipProcessingPagingChange = false; | ||
| } | ||
|
|
||
| const pageIndex = dataSource.pageIndex(); | ||
| // @ts-expect-error badly typed DataSourceAdapter | ||
| const pageIndex: number = dataSource.pageIndex(); | ||
| this._isPaging = optionName === 'pageIndex'; | ||
|
|
||
| const loadResult: DeferredObj<unknown> = dataSource[optionName === 'pageIndex' ? 'load' : 'reload'](); | ||
|
|
@@ -1779,19 +1781,20 @@ export class DataController extends modules.Controller { | |
| } | ||
|
|
||
| public push(...args: unknown[]): unknown { | ||
| // @ts-expect-error badly typed DataSourceAdapter | ||
| return this._dataSource?.push(...args); | ||
| } | ||
|
bit-byte0 marked this conversation as resolved.
|
||
|
|
||
| private itemsCount(): number { | ||
| return (this._dataSource ? this._dataSource.itemsCount() : 0) as number; | ||
| return (this._dataSource ? this._dataSource.itemsCount() : 0); | ||
| } | ||
|
|
||
| public totalItemsCount(): number { | ||
| return (this._dataSource ? this._dataSource.totalItemsCount() : 0) as number; | ||
| return (this._dataSource ? this._dataSource.totalItemsCount() : 0); | ||
| } | ||
|
|
||
| public hasKnownLastPage(): boolean { | ||
| return (this._dataSource ? this._dataSource.hasKnownLastPage() : true) as boolean; | ||
| return (this._dataSource ? this._dataSource.hasKnownLastPage() : true); | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1802,7 +1805,7 @@ export class DataController extends modules.Controller { | |
| } | ||
|
|
||
| public totalCount(): number { | ||
| return (this._dataSource ? this._dataSource.totalCount() : 0) as number; | ||
| return (this._dataSource ? this._dataSource.totalCount() : 0); | ||
| } | ||
|
|
||
| public hasLoadOperation(): boolean { | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then make DataSourceAdapter._dataSource to be public and delete
DataSourceAdapterLiketype as it is not used anywhere else