-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arc-lib): created component zoombar and scrollbar
created component zoombar and scrollbar GH-58
- Loading branch information
1 parent
755b2df
commit b80f391
Showing
14 changed files
with
308 additions
and
10 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
...ects/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.html
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<div class="w-100 p-3 mt-1 display-flex flex-direction-row"> | ||
<nb-icon | ||
icon="chevron-left" | ||
class="gantt-scroll-icon cursor-pointer" | ||
(click)="scrollBack()" | ||
></nb-icon> | ||
<nb-icon | ||
icon="chevron-right" | ||
class="gantt-scroll-icon cursor-pointer" | ||
(click)="scrollForward()" | ||
></nb-icon> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
...ects/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.scss
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.gantt-scroll-icon { | ||
height: 2rem; | ||
width: 2rem; | ||
} |
22 changes: 22 additions & 0 deletions
22
...s/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.spec.ts
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {GanttScrollComponent} from './gantt-scroll.component'; | ||
|
||
describe('GanttScrollComponent', () => { | ||
let component: GanttScrollComponent; | ||
let fixture: ComponentFixture<GanttScrollComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [GanttScrollComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GanttScrollComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
28 changes: 28 additions & 0 deletions
28
projects/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.ts
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {Component, Inject} from '@angular/core'; | ||
import {AnyObject} from '@project-lib/core/api'; | ||
import {GANTT_SCALES} from '../../const'; | ||
import {GanttService} from '../../services'; | ||
import {GanttScaleService} from '../../types'; | ||
|
||
@Component({ | ||
selector: 'arc-gantt-scroll', | ||
templateUrl: './gantt-scroll.component.html', | ||
styleUrls: ['./gantt-scroll.component.scss'], | ||
}) | ||
export class GanttScrollComponent<T extends AnyObject> { | ||
constructor( | ||
private ganttService: GanttService<T>, | ||
@Inject(GANTT_SCALES) | ||
private readonly scales: GanttScaleService<T>[], | ||
) {} | ||
scrollBack() { | ||
const selectedScale = this.ganttService.selectedScale; | ||
const scale = this.scales.find(s => s.scale === selectedScale); | ||
scale?.scroll(false, this.ganttService); | ||
} | ||
scrollForward() { | ||
const selectedScale = this.ganttService.selectedScale; | ||
const scale = this.scales.find(s => s.scale === selectedScale); | ||
scale?.scroll(true, this.ganttService); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...ts/arc-lib/src/lib/components/gantt/components/gantt-zoombar/gantt-zoombar.component.html
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<nb-layout> | ||
<nb-layout-header fixed> | ||
<div class="icon-wrapper"> | ||
<nb-icon class="icon" icon="fit_content" (click)="fitToScreen()"> | ||
</nb-icon> | ||
<nb-icon class="icon" pack="eva" name="maximize-outline"></nb-icon> | ||
<nb-icon class="icon" icon="star" (click)="zoomIn()"> </nb-icon> | ||
<nb-icon class="icon" icon="heart-outline" (click)="zoomOut()"> </nb-icon> | ||
</div> | ||
</nb-layout-header> | ||
</nb-layout> |
8 changes: 8 additions & 0 deletions
8
...ts/arc-lib/src/lib/components/gantt/components/gantt-zoombar/gantt-zoombar.component.scss
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.icon-wrapper { | ||
display: flex; | ||
gap: 16px; | ||
} | ||
|
||
.icon { | ||
cursor: pointer; | ||
} |
42 changes: 42 additions & 0 deletions
42
...arc-lib/src/lib/components/gantt/components/gantt-zoombar/gantt-zoombar.component.spec.ts
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
|
||
import {GanttZoomBarComponent} from './gantt-zoombar.component'; | ||
import {AnyObject} from '@project-lib/core/api'; | ||
import {CoreModule} from '@project-lib/core/core.module'; | ||
import {LocalizationModule} from '@project-lib/core/localization'; | ||
import {IconPacksManagerService} from '@project-lib/theme/services'; | ||
import {ThemeModule} from '@project-lib/theme/theme.module'; | ||
import {GanttProviders, GANTT_SCALES} from '../../const'; | ||
|
||
describe('GanttZoomBarComponent', () => { | ||
let component: GanttZoomBarComponent<AnyObject>; | ||
let fixture: ComponentFixture<GanttZoomBarComponent<AnyObject>>; | ||
let service: IconPacksManagerService; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [GanttZoomBarComponent], | ||
providers: [ | ||
GanttProviders, | ||
{ | ||
provide: GANTT_SCALES, | ||
useValue: [], | ||
}, | ||
], | ||
imports: [ThemeModule.forRoot('arc'), LocalizationModule, CoreModule], | ||
}).compileComponents(); | ||
service = TestBed.inject(IconPacksManagerService); | ||
service.registerFontAwesome(); | ||
service.registerSvgs(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(GanttZoomBarComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
...ects/arc-lib/src/lib/components/gantt/components/gantt-zoombar/gantt-zoombar.component.ts
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {Component} from '@angular/core'; | ||
import {TranslateService} from '@ngx-translate/core'; | ||
import {TranslationService} from '@project-lib/core/localization'; | ||
import {GanttService} from '../../services'; | ||
import {AnyObject} from '@project-lib/core/api'; | ||
import {TimelineArray} from '../../types'; | ||
|
||
@Component({ | ||
selector: 'arc-gantt-zoombar', | ||
templateUrl: './gantt-zoombar.component.html', | ||
styleUrls: ['./gantt-zoombar.component.scss'], | ||
}) | ||
export class GanttZoomBarComponent<T extends AnyObject> { | ||
translate: TranslateService; | ||
constructor( | ||
private ganttService: GanttService<T>, | ||
private readonly translationService: TranslationService, | ||
) { | ||
this.translate = this.translationService.translate; | ||
console.log(TimelineArray); | ||
} | ||
|
||
zoomIn() { | ||
this.ganttService.zoomIn(); | ||
} | ||
|
||
zoomOut() { | ||
this.ganttService.zoomOut(); | ||
} | ||
|
||
fitToScreen() { | ||
this.ganttService.fitToScreen(); | ||
} | ||
} |
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
45 changes: 45 additions & 0 deletions
45
projects/arc-lib/src/lib/components/gantt/services/date-operation.service.ts
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import {Injectable} from '@angular/core'; | ||
import * as moment from 'moment'; | ||
|
||
@Injectable() | ||
export class DateOperationService { | ||
convertToMoment(date: moment.MomentInput) { | ||
return moment(date); | ||
} | ||
|
||
getTotalMonths(startDate: moment.Moment, endDate: moment.Moment) { | ||
let months = 0; | ||
const date = startDate.clone().startOf('month'); | ||
const end = endDate.clone().endOf('month'); | ||
while (date < end) { | ||
months++; | ||
date.add(1, 'month'); | ||
} | ||
return months; | ||
} | ||
|
||
calculateWeeksBetweenDates(startDate: Date | string, endDate: Date | string) { | ||
const startMoment = moment(startDate); | ||
const endMoment = moment(endDate); | ||
const totalWeeks = endMoment.diff(startMoment, 'weeks') + 1; | ||
return totalWeeks; | ||
} | ||
|
||
getNumberOfDaysBetweenDates(date1: Date, date2: Date): number { | ||
const momentDate1 = moment(date1); | ||
const momentDate2 = moment(date2); | ||
|
||
const daysDifference = momentDate2.diff(momentDate1, 'days'); | ||
|
||
return daysDifference; | ||
} | ||
|
||
getNumberOfMonthsBetweenDates(date1: Date, date2: Date): number { | ||
const momentDate1 = moment(date1); | ||
const momentDate2 = moment(date2); | ||
|
||
const monthsDifference = momentDate2.diff(momentDate1, 'months') + 1; | ||
|
||
return monthsDifference; | ||
} | ||
} |
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
Oops, something went wrong.