-
Notifications
You must be signed in to change notification settings - Fork 77
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
feat(gantt): support quick time focus #TINFR-1044 #494
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
24f1aed
feat(gantt): support quick time focus
smile1016 e02e6f2
feat(gantt): support quick time focus
smile1016 57be5b4
feat(gantt): support quick time focus
smile1016 81a3a7e
feat(gantt): support quick time focus
smile1016 29552ff
feat(gantt): support quick time focus
smile1016 e56f2f6
feat(gantt): support quick time focus
smile1016 f027c74
feat(gantt): support quick time focus
smile1016 cc7d3b2
feat(gantt): support quick time focus
smile1016 484dd74
feat(gantt): support quick time focus
smile1016 7fd9244
feat(gantt): support quick time focus
smile1016 43f8745
feat(gantt): support quick time focus
smile1016 5893e9d
feat(gantt): support quick time focus
smile1016 0afd81b
feat(gantt): support quick time focus
smile1016 09aa978
feat(gantt): fix bug of virtualScroll and add element resize
smile1016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { Component, HostBinding, Inject, Input, TemplateRef, Output, EventEmitter } from '@angular/core'; | ||
import { Component, HostBinding, Inject, Input, TemplateRef, Output, EventEmitter, OnInit, AfterViewInit, NgZone } from '@angular/core'; | ||
import { GanttGroupInternal, GanttItemInternal, GanttBarClickEvent, GanttLineClickEvent } from '../../class'; | ||
import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper'; | ||
import { IsGanttRangeItemPipe, IsGanttBarItemPipe, IsGanttCustomItemPipe } from '../../gantt.pipe'; | ||
|
@@ -7,6 +7,10 @@ import { NgxGanttBarComponent } from '../bar/bar.component'; | |
import { NgxGanttRangeComponent } from '../range/range.component'; | ||
import { NgFor, NgIf, NgClass, NgTemplateOutlet } from '@angular/common'; | ||
import { GanttLinksComponent } from '../links/links.component'; | ||
import { NgxGanttRootComponent } from 'ngx-gantt'; | ||
import { GanttIconComponent } from '../icon/icon.component'; | ||
import { GanttDomService } from '../../gantt-dom.service'; | ||
import { combineLatest, from, Subject, take, takeUntil } from 'rxjs'; | ||
|
||
@Component({ | ||
selector: 'gantt-main', | ||
|
@@ -23,10 +27,11 @@ import { GanttLinksComponent } from '../links/links.component'; | |
NgxGanttBaselineComponent, | ||
IsGanttRangeItemPipe, | ||
IsGanttBarItemPipe, | ||
IsGanttCustomItemPipe | ||
IsGanttCustomItemPipe, | ||
GanttIconComponent | ||
] | ||
}) | ||
export class GanttMainComponent { | ||
export class GanttMainComponent implements OnInit { | ||
@Input() viewportItems: (GanttGroupInternal | GanttItemInternal)[]; | ||
|
||
@Input() flatItems: (GanttGroupInternal | GanttItemInternal)[]; | ||
|
@@ -41,15 +46,43 @@ export class GanttMainComponent { | |
|
||
@Input() baselineTemplate: TemplateRef<any>; | ||
|
||
@Input() ganttRoot: NgxGanttRootComponent; | ||
|
||
@Input() quickTimeFocus: boolean; | ||
|
||
@Output() barClick = new EventEmitter<GanttBarClickEvent>(); | ||
|
||
@Output() lineClick = new EventEmitter<GanttLineClickEvent>(); | ||
|
||
@HostBinding('class.gantt-main-container') ganttMainClass = true; | ||
|
||
constructor(@Inject(GANTT_UPPER_TOKEN) public ganttUpper: GanttUpper) {} | ||
private unsubscribe$ = new Subject<void>(); | ||
|
||
constructor(@Inject(GANTT_UPPER_TOKEN) public ganttUpper: GanttUpper, public dom: GanttDomService, protected ngZone: NgZone) {} | ||
|
||
ngOnInit(): void { | ||
const onStable$ = this.ngZone.isStable ? from(Promise.resolve()) : this.ngZone.onStable.pipe(take(1)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这些是不是可以去掉?是为了解决初始的时候,visibleRangeX没有值? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 最新的提交没有去掉,是为了稳定后获取到 mainContainer。对 mainContainer 的位置变化进行监听 |
||
this.ngZone.runOutsideAngular(() => { | ||
onStable$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => { | ||
this.setupResize(); | ||
}); | ||
}); | ||
} | ||
|
||
trackBy(index: number, item: GanttGroupInternal | GanttItemInternal) { | ||
return item.id || index; | ||
} | ||
|
||
private setupResize() { | ||
combineLatest([this.dom.getResize(), this.dom.getResizeByElement(this.dom.mainContainer)]) | ||
.pipe(takeUntil(this.unsubscribe$)) | ||
.subscribe(() => { | ||
this.dom.setVisibleRangeX(); | ||
}); | ||
} | ||
|
||
quickTime(item: GanttItemInternal, type: 'left' | 'right') { | ||
const date = type === 'left' ? item.start || item.end : item.end || item.start; | ||
this.ganttRoot.scrollToDate(date); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
最好使用新的特性 takeUntilDestroyed