Skip to content
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

CardView: Implement Pager #28782

Open
wants to merge 4 commits into
base: grids/cardview/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 @@ -5,6 +5,8 @@ exports[`common initial render should be successfull 1`] = `
class="dx-widget dx-cardview"
>
This is cardView
<div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,46 @@
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
import { combined } from '@ts/core/reactive/index';
import { View } from '@ts/grids/new/grid_core/core/view';
import { PagerView } from '@ts/grids/new/grid_core/pager/view';
import { ToolbarView } from '@ts/grids/new/grid_core/toolbar/view';
import type { ComponentType } from 'inferno';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface MainViewProps {
Toolbar: ComponentType;
Pager: ComponentType;
}

// eslint-disable-next-line no-empty-pattern
function MainViewComponent({
Toolbar,
Toolbar, Pager,
}: MainViewProps): JSX.Element {
return (<>
{/* @ts-expect-error */}
<Toolbar/>
This is cardView
<div>
{/*
TODO:
Pager, as renovated component, has strange disposing.
See `inferno_renderer.remove` method.
It somehow mutates $V prop of parent element.
Without this div, CardView would be parent of Pager.
In this case all `componentWillUnmount`s aren't called
*/}
{/* @ts-expect-error */}
<Pager/>
</div>
</>);
}

export class MainView extends View<MainViewProps> {
protected override component = MainViewComponent;

public static dependencies = [ToolbarView] as const;
public static dependencies = [
PagerView, ToolbarView,
] as const;

constructor(
private readonly pager: PagerView,
private readonly toolbar: ToolbarView,
) {
super();
Expand All @@ -37,6 +52,7 @@ export class MainView extends View<MainViewProps> {
protected override getProps() {
return combined({
Toolbar: this.toolbar.asInferno(),
Pager: this.pager.asInferno(),
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { Properties as PaginationProperties } from '@js/ui/pagination';
import dxPagination from '@js/ui/pagination';

import { InfernoWrapper } from './widget_wrapper';

export class Pager extends InfernoWrapper<PaginationProperties, dxPagination> {
protected getComponentFabric(): typeof dxPagination {
return dxPagination;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { WidgetOptions } from '@js/ui/widget/ui.widget';

import * as columnsController from './columns_controller/index';
import * as dataController from './data_controller/index';
import type * as toolbar from './toolbar';
import * as pager from './pager/index';
import type * as toolbar from './toolbar/index';
import type { GridCoreNew } from './widget';

/**
Expand All @@ -13,12 +14,14 @@ import type { GridCoreNew } from './widget';
export type Options =
& WidgetOptions<GridCoreNew>
& dataController.Options
& pager.Options
& columnsController.Options
& toolbar.Options;

export const defaultOptions = {
...dataController.defaultOptions,
...columnsController.defaultOptions,
...pager.defaultOptions,
} satisfies Options;

// TODO: separate by modules
Expand Down
Loading
Loading