Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { StoreChange } from '@js/data/store';
import errors from '@js/ui/widget/ui.errors';
import { findChanges } from '@ts/core/utils/m_array_compare';
import { fromPromise } from '@ts/core/utils/m_deferred';
import type { ChangingEvent, DataSource, StoreLoadOptions } from '@ts/data/data_source/types';
import type { ChangingEvent, DataSource } from '@ts/data/data_source/types';
import type { Column, ColumnsChanges } from '@ts/grids/grid_core/columns_controller/types';
import type DataSourceAdapter from '@ts/grids/grid_core/data_source_adapter/m_data_source_adapter';
import type {
Expand Down Expand Up @@ -1478,51 +1478,37 @@ export class DataController extends modules.Controller {
const d = Deferred<ProcessedItem[]>();
const dataSource = this._dataSource;

if (dataSource) {
if (data) {
const loadOperation: Omit<LoadOperation, 'data'> & Required<Pick<LoadOperation, 'data'>> = {
data,
isCustomLoading: true,
storeLoadOptions: { isLoadingAll: true },
loadOptions: {
filter: skipFilter ? null : this.getCombinedFilter(),
group: dataSource.group(),
sort: dataSource.sort(),
},
};
dataSource.customizeLoadResultHandler(loadOperation);

when<RawItemData[]>(loadOperation.data)
.done((loadedData: RawItemData[]): void => {
const items = this._processItems(
this._beforeProcessItems(loadedData),
{ changeType: 'loadingAll' },
);
// @ts-expect-error DataGrid-only summary leaks into grid_core
d.resolve(items, loadOperation.extra?.summary);
})
.fail(d.reject as (...args: unknown[]) => void);
} else if (!dataSource.isLoading()) {
const loadOptions: StoreLoadOptions & { isLoadingAll: boolean } = {
...dataSource.loadOptions(),
isLoadingAll: true,
requireTotalCount: false,
};
dataSource.load(loadOptions)
.done((loadedItems: RawItemData[], extra: LoadOperation['extra']): void => {
const items = this._processItems(
this._beforeProcessItems(loadedItems),
{ changeType: 'loadingAll' },
);
// @ts-expect-error DataGrid-only summary leaks into grid_core
d.resolve(items, extra?.summary);
})
.fail(d.reject);
} else {
d.reject();
}
} else {
if (!dataSource) {
d.resolve([]);
return d;
}

const resolveWithProcessedItems = (
loadedData: RawItemData[],
extra: LoadOperation['extra'],
): void => {
const items = this._processItems(
this._beforeProcessItems(loadedData),
{ changeType: 'loadingAll' },
);
// @ts-expect-error DataGrid-only summary leaks into grid_core
d.resolve(items, extra?.summary);
};

if (data) {
dataSource.customProcessLoadedData(data, {
filter: skipFilter ? null : this.getCombinedFilter(),
group: dataSource.group(),
sort: dataSource.sort(),
})
.done(resolveWithProcessedItems)
.fail(d.reject as (...args: unknown[]) => void);
} else if (!dataSource.isLoading()) {
dataSource.customLoadAll()
.done(resolveWithProcessedItems)
.fail(d.reject as (...args: unknown[]) => void);
} else {
d.reject();
}

return d;
Expand Down
Loading
Loading