Skip to content

Commit

Permalink
fix: fix demo and support rerenderView #INFR-5754 (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
HandsomeButterball authored Dec 20, 2022
1 parent 2cc8cc8 commit c77f9ef
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 6 additions & 4 deletions example/src/app/gantt-custom-view/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ import { ThyNotifyService } from 'ngx-tethys/notify';
import { randomItems, random } from '../helper';
import { GanttViewCustom } from './custom-day-view';

const customViewType = 'custom';

registerView(customViewType, GanttViewCustom);

@Component({
selector: 'app-gantt-custom-view-example',
templateUrl: './gantt.component.html'
})
export class AppGanttCustomViewExampleComponent implements OnInit, AfterViewInit {
viewType: 'custom';
viewType = customViewType;

showWeekend = true;

Expand Down Expand Up @@ -72,9 +76,7 @@ export class AppGanttCustomViewExampleComponent implements OnInit, AfterViewInit

constructor(private thyNotify: ThyNotifyService) {}

ngOnInit(): void {
registerView(this.viewType, GanttViewCustom);
}
ngOnInit(): void {}

ngAfterViewInit() {
setTimeout(() => this.ganttComponent.scrollToDate(1627729997), 200);
Expand Down
2 changes: 1 addition & 1 deletion packages/gantt/src/components/toolbar/toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export class NgxGanttToolbarComponent {
constructor(@Inject(GANTT_UPPER_TOKEN) protected ganttUpper: GanttUpper) {}

selectView(view: GanttViewType) {
this.ganttUpper.viewTypeChange(view);
this.ganttUpper.changeView(view);
}
}
10 changes: 5 additions & 5 deletions packages/gantt/src/gantt-upper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ export abstract class GanttUpper implements OnChanges, OnInit, OnDestroy {
ngOnChanges(changes: SimpleChanges) {
if (!this.firstChange) {
if (changes.viewType && changes.viewType.currentValue && changes.viewType.currentValue !== changes.viewType.previousValue) {
this.viewTypeChange(changes.viewType.currentValue);
this.changeView(changes.viewType.currentValue);
}
if (changes.viewOptions) {
this.viewTypeChange(this.viewType);
this.changeView(this.viewType);
}
if (changes.originItems || changes.originGroups) {
this.setupExpandedState();
Expand Down Expand Up @@ -423,7 +423,7 @@ export abstract class GanttUpper implements OnChanges, OnInit, OnDestroy {
return this.selectionModel.isSelected(id);
}

viewTypeChange(type: GanttViewType) {
changeView(type: GanttViewType) {
this.viewType = type;
this.createView();
this.setupGroups();
Expand All @@ -434,8 +434,8 @@ export abstract class GanttUpper implements OnChanges, OnInit, OnDestroy {
this.viewChange.emit(this.view);
}

renderView(type: GanttViewType) {
this.viewTypeChange(type);
rerenderView() {
this.changeView(this.viewType);
}
}

Expand Down

0 comments on commit c77f9ef

Please sign in to comment.