Skip to content

Commit

Permalink
Fix failing build
Browse files Browse the repository at this point in the history
  • Loading branch information
erzik987 committed Jul 12, 2024
1 parent b1c2d12 commit 9818c30
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,8 @@ export const widgets: IWidget[] = [
descendantSorting: false,
sortBy: "column1",
},
hasVirtualScroll: true,
scrollType: ScrollType.virtual,
hasVirtualScroll: false,
searchConfiguration: {
enabled: true,
},
Expand Down Expand Up @@ -691,7 +692,8 @@ export const widgets: IWidget[] = [
descendantSorting: false,
sortBy: "column1",
},
hasVirtualScroll: true,
scrollType: ScrollType.paginator,
hasVirtualScroll: false,
searchConfiguration: {
enabled: true,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,26 @@ import {
ClientSideDataSource,
EventBus,
IDataField,
INovaFilteringOutputs,
ISelectChangedEvent,
LocalFilteringDataSource,
LoggerService,
NuiBusyModule,
NuiImageModule,
NuiSpinnerModule,
NuiTableModule,
PaginatorComponent,
SearchService,
SorterDirection,
VirtualViewportManager,
} from "@nova-ui/bits";

import { NuiDashboardsModule } from "../../dashboards.module";
import { mockLoggerService } from "../../mocks";
import {
mockChangeDetector,
mockLoggerService,
mockPopupContainer,
} from "../../mocks";
import { NuiPizzagnaModule } from "../../pizzagna/pizzagna.module";
import { DynamicComponentCreator } from "../../pizzagna/services/dynamic-component-creator.service";
import { PizzagnaService } from "../../pizzagna/services/pizzagna.service";
Expand Down Expand Up @@ -73,6 +80,7 @@ interface BasicTableModel {

class MockDatasource extends ClientSideDataSource<any> {
public busy = new BehaviorSubject(true);
// public getFilteredData(): Promise<INovaFilteringOutputs>
}

const oneDataFieldColumns: ITableWidgetColumnConfig[] = [
Expand Down Expand Up @@ -361,6 +369,7 @@ describe("TableWidgetComponent", () => {
component.dataFields = dataFields;
component.configuration = configuration;
component.range = tableData.length;

fixture.detectChanges();
});

Expand Down Expand Up @@ -675,15 +684,21 @@ describe("TableWidgetComponent", () => {
});
});

// TODO: Not working properly, fix in NUI-5893
describe("paginator >", () => {
it("should be enabled if hasVirtualScroll is set to false and scrollType is set to paginator", () => {
xit("should be enabled if hasVirtualScroll is set to false and scrollType is set to paginator", () => {
const configWithoutVirtualScrollAndScrollType: ITableWidgetConfig =
{
...configuration,
hasVirtualScroll: false,
scrollType: ScrollType.paginator,
};

component.paginator = new PaginatorComponent(
mockLoggerService,
mockPopupContainer,
mockChangeDetector
);
component.ngOnChanges(
createSimpleChanges(
configWithoutVirtualScrollAndScrollType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ export class TableWidgetComponent

this.virtualScrollAddon.initVirtualScroll(this);
this.paginatorAddon.initPaginator(this);
this.dataSource.applyFilters();

if (this.scrollTypeChanged(changes.configuration)) {
this.dataSource.applyFilters();
}
}

public ngOnInit(): void {
Expand Down Expand Up @@ -683,6 +686,13 @@ export class TableWidgetComponent
this.tableData = [];
}

private scrollTypeChanged(configurationChange: SimpleChange): boolean {
return !configurationChange.previousValue
? false
: configurationChange.previousValue.scrollType !==
configurationChange.currentValue.scrollType;
}

private getTableScrollRange(): number {
// Note: To work properly virtual viewport should be scrollable
// to ensure that container will be scrollable we're adding 50% more items
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ describe("TableScrollTypeEditorComponent", () => {
component.ngOnChanges(changes);

expect(component.subtitle).toEqual(
"Scroll Type: " +
"Scroll Type: " +
component.loadStrategies.find(
(ls) => ls.id === ScrollType.virtual
)?.title
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ export class TableScrollTypeEditorComponent
}

public ngOnInit(): void {
console.log("this.scrollType", this.scrollType);
this.form = this.formBuilder.group({
paginatorConfiguration: this.formBuilder.group({
scrollType: get(this.scrollType, "", ScrollType.virtual),
Expand Down
5 changes: 5 additions & 0 deletions packages/dashboards/src/lib/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { ChangeDetectorRef } from "@angular/core";

import { LoggerService } from "@nova-ui/bits";
import { PopupContainerService } from "@nova-ui/bits/lib/popup/popup-container.service";

export const mockLoggerService = {
info: () => {},
Expand All @@ -33,3 +34,7 @@ export const mockChangeDetector = {
markForCheck: () => {},
detectChanges: () => {},
} as ChangeDetectorRef;

export const mockPopupContainer = {
parent: () => {},
} as PopupContainerService;

0 comments on commit 9818c30

Please sign in to comment.