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

Custom View Mode #5

Open
nimrod46 opened this issue Feb 11, 2024 · 2 comments
Open

Custom View Mode #5

nimrod46 opened this issue Feb 11, 2024 · 2 comments

Comments

@nimrod46
Copy link

Hi, I cant seem to make the custom view mode to compile,

  1. your code:
......
enum CustomViewMode {
  Day = TimelineViewMode.Day, //This also doesn't compile 
  Week = TimelineViewMode.Week,
  Month = TimelineViewMode.Month,
  Custom = 'Custom'
}

class CustomStrategyManager extends StrategyManager implements IStrategyManager<TimelineViewMode> {
  getScaleGenerator(viewMode: CustomViewMode): IScaleGenerator {
    if (viewMode === CustomViewMode.Custom) {
      return {...};  // your custom logic here
    }

    return super.getScaleGenerator(viewMode);
  };

  getViewModeAdaptor(viewMode: CustomViewMode): IViewModeAdaptor {
    if (viewMode === CustomViewMode.Custom) {
      return {...} // custom adaptor;
    }

    return super.getAdaptor(viewMode); //This should be  super.getViewModeAdaptor(viewMode); 
  }
}
......

In the class signature you gave TimelineViewMode as a type for the modes, but in each method you except CustomViewMode, this can't compile.

  1. Also when setting the zoom mode, it excepts a ITimelineZoom implementing that interface also doesn't compile when using it because of the enum:
export enum CustomViewMode {
    Month = "Month",
    Week = "Week",
    Day = "Day",
    Hour = 'Hour'
  }
  

export class TimelineZoom implements ITimelineZoom<CustomViewMode> {
    viewMode!: CustomViewMode;
    columnWidth!: number;
}

but setting a mode with that type:

zooms: TimelineZoom[] = [
    {columnWidth: 50, viewMode: CustomViewMode.Month},
    {columnWidth: 55, viewMode: CustomViewMode.Month},
    {columnWidth: 50, viewMode: CustomViewMode.Day},
    {columnWidth: 50, viewMode: CustomViewMode.Hour},
  ];  
  ngAfterViewInit() {
    // this.timelineComponent!.zooms = this.zooms;
    console.log(DefaultZooms);
    this.timelineComponent!.changeZoom(this.zooms[0]);

results in an error:

image

@oOps1627
Copy link
Owner

@nimrod46 Sorry for the long response. If it's still relevant for you, I've uploaded a new version with corrected types.

@oOps1627
Copy link
Owner

now you have to use component with generic type like this:
@ViewChild('timelineComponent) timeline: TimelineComponent<CustomViewMode>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants