Skip to content

Commit f65f382

Browse files
committed
feat(arc): gantt module added with demo component which includes demo of all sub component
gantt module added with demo component which includes demo of all sub component
1 parent b80f391 commit f65f382

31 files changed

+1771
-249
lines changed

projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
justify-content: space-between;
8888
align-items: center;
8989
height: 100%;
90-
overflow: hidden;
90+
9191

9292
background: repeating-linear-gradient(
9393
305deg,

projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input} from '@angular/core';
1+
import {Component, Input, OnChanges, SimpleChanges} from '@angular/core';
22
import {AllocationBar, Item} from '../../model/item.model';
33

44
@Component({
@@ -7,7 +7,7 @@ import {AllocationBar, Item} from '../../model/item.model';
77
styleUrls: ['./gantt-bars.component.scss'],
88
})
99
export class GanttBarsComponent {
10-
@Input() item: Item;
10+
@Input() item: any;
1111
@Input() allocationTypes: any;
1212
@Input() allocationBase: number;
1313
showTooltip = -1;

projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
<div *ngFor="let item of items" class="employee-list-item">
1+
<div
2+
*ngFor="let item of items"
3+
(click)="onItemClick(item)"
4+
class="employee-list-item"
5+
>
26
<nb-icon
37
*ngIf="item.hasChildren"
48
[icon]="item.$open ? 'chevron-up' : 'chevron-down'"

projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Input} from '@angular/core';
1+
import {Component, EventEmitter, Input, Output} from '@angular/core';
22
import {empData} from '../../model/item.model';
33

44
@Component({
@@ -18,4 +18,12 @@ export class GanttColumnComponent {
1818

1919
@Input()
2020
showOverallocatedIcon: boolean;
21+
// for testing
22+
23+
@Output() itemSelected = new EventEmitter<empData>();
24+
25+
onItemClick(item: empData): void {
26+
this.itemSelected.emit(item);
27+
console.log('hi tiny');
28+
}
2129
}

projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@ <h2 class="project-title">{{ name }}</h2>
55
<p>Description is enabled.</p>
66
</div>
77
</div>
8-
9-
<nb-card>
10-
<nb-card-body>
11-
<div class="search-wrapper" *ngIf="showSearch">
12-
<input
13-
nbInput
14-
fieldSize="medium"
15-
type="text"
16-
status="basic"
17-
[placeholder]="searchPlaceholder"
18-
/>
19-
</div>
20-
</nb-card-body>
21-
</nb-card>
8+
<div class="search-wrapper" *ngIf="showSearch">
9+
<input
10+
nbInput
11+
fieldSize="medium"
12+
type="text"
13+
status="basic"
14+
[placeholder]="searchPlaceholder"
15+
/>
16+
</div>
2217
</div>

projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.scss

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,22 @@
5656
.header-wrapper {
5757
display: flex;
5858
justify-content: space-between;
59+
align-items: center;
5960
width: calc(100vw - 1rem);
6061
}
6162

6263
.project-title {
6364
font-size: x-large;
64-
margin-bottom: -2px;
65+
line-height: 1;
6566
}
6667

6768
.desc-wrapper {
68-
margin-top: -8px;
69+
margin-top: 6px;
70+
p{
71+
margin:0;
72+
}
6973
}
7074

71-
.search-wrapper {
72-
margin-top: 32px;
75+
.project-title{
76+
margin:0;
7377
}

projects/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="w-100 p-3 mt-1 display-flex flex-direction-row">
1+
<div class="w-100 p-3 mt-1 display-flex flex-direction-row icon-wrapper">
22
<nb-icon
33
icon="chevron-left"
44
class="gantt-scroll-icon cursor-pointer"

projects/arc-lib/src/lib/components/gantt/components/gantt-scroll/gantt-scroll.component.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22
height: 2rem;
33
width: 2rem;
44
}
5+
6+
.icon-wrapper{
7+
display: flex;
8+
justify-content: flex-start;
9+
align-items: center;
10+
margin-top: -24px;
11+
}

projects/arc-lib/src/lib/components/gantt/components/gantt-tooltip/gantt-tooltip.component.scss

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
font-family: var(--font-family-primary);
1515
font-weight: map.get($font-weight, light);
1616
font-size: map.get($font-size, default);
17-
width: 35rem;
17+
width: 25rem;
1818
max-height: 25rem;
1919
overflow-y: auto;
2020
}
@@ -77,7 +77,7 @@ hr {
7777

7878
.deal-name {
7979
text-decoration: underline;
80-
width: 24rem !important;
80+
width: 20rem !important;
8181
color: map.get($color, light) !important;
8282
font-weight: map.get($font-weight, bold);
8383
text-overflow: ellipsis;
@@ -87,7 +87,7 @@ hr {
8787
}
8888
.deal-key {
8989
display: flex;
90-
gap: 20px;
90+
gap: 15px;
9191
justify-content: end;
9292
}
9393
.status-circle {
@@ -96,6 +96,7 @@ hr {
9696
height: 10px;
9797
border-radius: 50%;
9898
margin-right: 10px;
99+
99100
&.active {
100101
background-color: green;
101102
}
Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1-
<nb-layout>
2-
<nb-layout-header fixed>
3-
<div class="icon-wrapper">
4-
<nb-icon class="icon" icon="fit_content" (click)="fitToScreen()">
5-
</nb-icon>
6-
<nb-icon class="icon" pack="eva" name="maximize-outline"></nb-icon>
7-
<nb-icon class="icon" icon="star" (click)="zoomIn()"> </nb-icon>
8-
<nb-icon class="icon" icon="heart-outline" (click)="zoomOut()"> </nb-icon>
9-
</div>
10-
</nb-layout-header>
11-
</nb-layout>
1+
<div class="icon-wrapper">
2+
<nb-icon class="icon" icon="fit_content" (click)="fitToScreen()"> </nb-icon>
3+
<nb-icon class="icon" pack="eva" name="maximize-outline"></nb-icon>
4+
<nb-icon nbPrefix icon="move-outline" pack="eva" (click)="zoomIn()"></nb-icon>
5+
<nb-icon
6+
nbPrefix
7+
icon="maximize-outline"
8+
pack="eva"
9+
(click)="zoomIn()"
10+
></nb-icon>
11+
<nb-icon
12+
nbPrefix
13+
icon="minimize-outline"
14+
pack="eva"
15+
(click)="zoomOut()"
16+
></nb-icon>
17+
</div>

projects/arc-lib/src/lib/components/gantt/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ export * from './gantt-bars/gantt-bars.component';
22
export * from './gantt-column/gantt-column.component';
33
export * from './gantt-header/gantt-header.component';
44
export * from './gantt-tooltip/gantt-tooltip.component';
5+
export * from './gantt-scroll/gantt-scroll.component';
6+
export * from './gantt-zoombar/gantt-zoombar.component';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<div #gantt id="gantt_here" style="width: 100%; height: 135px"></div>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* gantt.component.scss */
2+
3+
/* Ensure the Gantt chart container takes the full width and height */
4+
#gantt_here {
5+
width: 100%;
6+
height: 600px;
7+
background-color: #f5f5f5; /* Light grey background for the Gantt container */
8+
border: 1px solid #ddd; /* Light border to distinguish the container */
9+
}
10+
11+
/* Customize Gantt chart grid */
12+
.gantt_grid_scale, .gantt_grid_head_cell, .gantt_grid_data .gantt_cell {
13+
background-color: #e6e6e6; /* Light grey background for grid header and cells */
14+
border-color: #ccc; /* Light grey border for grid cells */
15+
}
16+
17+
/* Customize Gantt chart tasks */
18+
.gantt_task_line {
19+
background-color: #4CAF50; /* Green background for tasks */
20+
border-color: #4CAF50; /* Green border for tasks */
21+
}
22+
23+
.gantt_task_progress {
24+
background-color: #81C784; /* Lighter green for task progress */
25+
}
26+
27+
/* Customize Gantt chart timeline scale */
28+
.gantt_scale_line {
29+
background-color: #e6e6e6; /* Light grey background for timeline scale */
30+
border-color: #ccc; /* Light grey border for timeline scale */
31+
}
32+
33+
/* Customize Gantt chart subscale */
34+
.gantt_task_scale {
35+
background-color: #f0f0f0; /* Slightly lighter grey for task scale */
36+
border-color: #ddd; /* Light grey border for task scale */
37+
}
38+
39+
/* Add custom styling for weekends */
40+
.gantt_task_cell.week_end {
41+
background-color: #f2dede !important; /* Light red background for weekends */
42+
}
43+
44+
/* Add custom styling for today marker */
45+
.gantt_today {
46+
background-color: #ffeb3b !important; /* Yellow background for today marker */
47+
opacity: 0.3; /* Semi-transparent */
48+
}
49+
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {ComponentFixture, TestBed} from '@angular/core/testing';
2+
3+
import {TimelineComponent} from './timeline.component';
4+
5+
describe('TimelineComponent', () => {
6+
let component: TimelineComponent;
7+
let fixture: ComponentFixture<TimelineComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [TimelineComponent],
12+
}).compileComponents();
13+
14+
fixture = TestBed.createComponent(TimelineComponent);
15+
component = fixture.componentInstance;
16+
fixture.detectChanges();
17+
});
18+
19+
it('should create', () => {
20+
expect(component).toBeTruthy();
21+
});
22+
});
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import {
2+
AfterViewInit,
3+
Component,
4+
ElementRef,
5+
OnDestroy,
6+
OnInit,
7+
TemplateRef,
8+
Type,
9+
ViewChild,
10+
ViewContainerRef,
11+
} from '@angular/core';
12+
import {NbMenuItem} from '@nebular/theme';
13+
import {
14+
GanttProviders,
15+
GanttAdapter,
16+
CustomGanttAdapter,
17+
GanttService,
18+
GanttRenderOptions,
19+
ContextItemFilter,
20+
GanttRowConfig,
21+
GanttTaskValue,
22+
IBarComponent,
23+
IColumnComponent,
24+
KebabListItem,
25+
Timelines,
26+
MONTHS_IN_QUARTER,
27+
} from '@project-lib/components/gantt';
28+
import {GanttScaleUnits} from '@project-lib/components/gantt/enum';
29+
import {Item, empData} from '@project-lib/components/gantt/model/item.model';
30+
import {AnyObject} from '@project-lib/core/api';
31+
import {BehaviorSubject, takeUntil} from 'rxjs';
32+
declare let gantt: any;
33+
@Component({
34+
selector: 'arc-timeline-gantt',
35+
templateUrl: './timeline.component.html',
36+
styleUrls: ['./timeline.component.scss'],
37+
})
38+
export class TimelineComponent<T extends AnyObject>
39+
implements AfterViewInit, GanttRenderOptions<T>
40+
{
41+
private _data: BehaviorSubject<T[]> = new BehaviorSubject<T[]>([]);
42+
@ViewChild('gantt', {static: true}) ganttContainer!: ElementRef;
43+
// data for tooltip component
44+
showTooltip = false;
45+
selectedItem: Item;
46+
infiniteScroll = false;
47+
constructor(
48+
private readonly ganttSvc: GanttService<AnyObject>,
49+
public readonly viewContainerRef: ViewContainerRef,
50+
) {}
51+
showParentInitials: boolean;
52+
showChildInitials: boolean;
53+
showOverallocatedIcon: boolean;
54+
ngAfterViewInit(): void {
55+
this.initializeGantt();
56+
}
57+
58+
columnComponent: Type<IColumnComponent<T>>;
59+
barComponent: Type<IBarComponent<T>>;
60+
contextItems: NbMenuItem[];
61+
contextTemplate?: TemplateRef<AnyObject>;
62+
columnName?: string;
63+
showKebab?: boolean;
64+
columnWidth: number;
65+
resizer: boolean;
66+
sorting: boolean;
67+
moveToToday: boolean;
68+
highlightRange?: [Date, Date];
69+
showNonBillableIcon: boolean;
70+
contextItemFilter?: ContextItemFilter<T>;
71+
defaultScale: Timelines;
72+
markToday: boolean;
73+
showBillingRate?: boolean;
74+
groupings?: string[];
75+
childIndent: boolean;
76+
tooltipOffset?: number;
77+
batchSize?: number;
78+
searchPlaceholder?: string;
79+
showSearch: boolean;
80+
ganttStartDate?: Date;
81+
kebabOption: (task: GanttTaskValue<T>) => KebabListItem[];
82+
ganttRowConfig: GanttRowConfig;
83+
private _formatWeeklyScale(date: Date) {
84+
const noOfDigits = 2;
85+
return `${date.toLocaleString('default', {month: 'short'})} ${date
86+
.getDate()
87+
.toString()
88+
.padStart(noOfDigits, '0')}, ${date.toLocaleString('default', {
89+
year: 'numeric',
90+
})}`;
91+
}
92+
private _formatQuarterScale(date: Date) {
93+
const month = date.getMonth();
94+
const year = date.getFullYear();
95+
return `Q${Math.ceil((month + 1) / MONTHS_IN_QUARTER)} ` + year;
96+
}
97+
private initializeGantt(): void {
98+
gantt.config.scale_unit = 'year';
99+
gantt.config.date_scale = '%Y';
100+
gantt.config.subscales = [
101+
{
102+
unit: GanttScaleUnits.Quarter,
103+
step: 1,
104+
format: (date: Date) => this._formatQuarterScale(date),
105+
},
106+
{
107+
unit: GanttScaleUnits.Week,
108+
step: 1,
109+
format: (date: Date) => this._formatWeeklyScale(date),
110+
},
111+
];
112+
gantt.config.start_date = new Date();
113+
gantt.config.end_date = new Date(
114+
gantt.config.start_date.getFullYear() + 1,
115+
0,
116+
1,
117+
);
118+
119+
gantt.config.columns = [];
120+
gantt.init(this.ganttContainer.nativeElement);
121+
gantt.parse({
122+
data: [{}],
123+
});
124+
}
125+
}

0 commit comments

Comments
 (0)