From 94f7e6038daf1c0c2c21cf7d027eeaf0179cd4ab Mon Sep 17 00:00:00 2001 From: Deepika Mahindroo Date: Wed, 17 Jul 2024 13:46:11 +0530 Subject: [PATCH 1/4] feat(arc-lib): updating gantt module updating gantt module GH-58 --- .../gantt/components/bb-gantt.component.html | 14 -- .../gantt/components/bb-gantt.component.scss | 15 -- .../gantt/components/bb-gantt.component.ts | 157 ------------------ .../gantt-bars/gantt-bars-routing.module.ts | 10 -- .../gantt-bars/gantt-bars.component.html | 4 +- .../gantt-bars/gantt-bars.component.scss | 5 +- .../gantt-bars/gantt-bars.component.spec.ts | 24 +-- .../gantt-bars/gantt-bars.component.ts | 48 +++--- .../gantt-bars/gantt-bars.module.ts | 13 -- .../gantt-column-routing.module.ts | 10 -- .../gantt-column/gantt-column.component.html | 13 +- .../gantt-column/gantt-column.component.scss | 18 +- .../gantt-column.component.spec.ts | 22 +++ .../gantt-column/gantt-column.component.ts | 28 +--- .../gantt-column/gantt-column.module.ts | 13 -- .../gantt-header-routing.module.ts | 10 -- .../gantt-header/gantt-header.component.html | 25 +-- .../gantt-header/gantt-header.component.scss | 3 +- .../gantt-header.component.spec.ts | 7 +- .../gantt-header/gantt-header.component.ts | 16 +- .../gantt-header/gantt-header.module.ts | 13 -- .../gantt-tooltip-routing.module.ts | 10 -- .../gantt-tooltip.component.html | 75 +++++---- .../gantt-tooltip.component.scss | 28 +++- .../gantt-tooltip.component.spec.ts | 18 -- .../gantt-tooltip/gantt-tooltip.component.ts | 38 +++-- .../gantt-tooltip/gantt-tooltip.module.ts | 13 -- .../lib/components/gantt/components/index.ts | 2 +- .../arc-lib/src/lib/components/gantt/const.ts | 7 +- .../components/gantt/gantt-routing.module.ts | 38 +---- .../src/lib/components/gantt/gantt.module.ts | 49 ++++-- .../lib/components/gantt/model/item.model.ts | 42 +++++ .../selector/select/select.component.html | 4 +- 33 files changed, 270 insertions(+), 522 deletions(-) delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.html delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.scss delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars-routing.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column-routing.module.ts create mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.spec.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header-routing.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-tooltip/gantt-tooltip-routing.module.ts delete mode 100644 projects/arc-lib/src/lib/components/gantt/components/gantt-tooltip/gantt-tooltip.module.ts create mode 100644 projects/arc-lib/src/lib/components/gantt/model/item.model.ts diff --git a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.html b/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.html deleted file mode 100644 index 4408045d..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
-
- - -
- -
-
diff --git a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.scss b/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.scss deleted file mode 100644 index ac35a2a9..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.scss +++ /dev/null @@ -1,15 +0,0 @@ -@use 'sass:map'; -@import 'projects/arc-lib/src/lib/theme/styles/_variables.scss'; -//@use "projects/arc-lib/src/lib/theme/styles/_variables.scss"; - -.gantt-container { - position: relative; - border-top: 0.063rem solid map.get($color, gantt-lines); - height: 100%; -} - -.gantt-menu { - background-color: map.get($color, light); - box-shadow: 0px 0.938rem 1.25rem 0px #00000029; - width: 11.75rem; -} diff --git a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.ts b/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.ts deleted file mode 100644 index 84d44893..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/bb-gantt.component.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { - AfterViewInit, - Component, - ElementRef, - EventEmitter, - Input, - OnChanges, - OnDestroy, - OnInit, - Output, - TemplateRef, - Type, - ViewChild, - ViewContainerRef, -} from '@angular/core'; -import {AnyObject} from '@project-lib/core/api'; -import {ComponentBaseDirective} from '@project-lib/core/component-base'; -import {NbMenuItem, NbMenuService} from '@nebular/theme'; -import {takeUntil} from 'rxjs'; -import {GANTT_COLUMN_WIDTH} from '../const'; -import {GanttService} from '../services'; -import { - ContextItemClickEvent, - ContextItemFilter, - GanttEvent, - GanttRenderOptions, - GanttTaskValue, - IBarComponent, - IColumnComponent, - Timelines, -} from '../types'; -import {GanttBarsComponent} from './gantt-bars/gantt-bars.component'; -import {GanttColumnComponent} from './gantt-column/gantt-column.component'; - -@Component({ - selector: 'gantt', - templateUrl: './bb-gantt.component.html', - styleUrls: ['./bb-gantt.component.scss'], -}) -export class BbGanttComponent - extends ComponentBaseDirective - implements OnChanges, OnInit, AfterViewInit, OnDestroy, GanttRenderOptions -{ - @ViewChild('gantt', {static: true}) ganttContainer!: ElementRef; - - @Input() - data!: T[]; - - @Input() - contextItems: NbMenuItem[] = []; - - @Input() - contextItemFilter!: ContextItemFilter; - - @Output() - contextItemClick = new EventEmitter>(); - - @Output() - event = new EventEmitter>(); - - @Input() - showParentInitials = false; - - @Input() - showChildInitials = false; - - @ViewChild('menu', {static: true}) - contextTemplate!: TemplateRef; - - @Input() - columnName = 'Employee Name'; - - @Input() - showKebab = true; - - @Input() - columnWidth = GANTT_COLUMN_WIDTH; - - @Input() - resizer = true; - - @Input() - columnComponent: Type> = GanttColumnComponent; - - @Input() - barComponent: Type> = GanttBarsComponent; - - @Input() - searchPlaceholder?: string; - - @Input() - showSearch = true; - - @Input() - showBorder = true; - - @Input() - moveToToday = true; - - @Input() - highlightRange!: [Date, Date]; - - @Input() - showOverallocatedIcon = true; - - @Input() - defaultScale: Timelines = Timelines.Monthly; - - @Input() - showGridBorder = true; - - @Input() - showTooltip = false; - - @Input() - markToday = true; - - @Input() - childIndent = true; - - constructor( - private readonly ganttSvc: GanttService, - private readonly menuService: NbMenuService, - public readonly viewContainerRef: ViewContainerRef, - ) { - super(); - } - - ngOnInit() { - this.menuService - .onItemClick() - .pipe(takeUntil(this._destroy$)) - .subscribe(event => { - this.contextItemClick.emit({ - event: event.item, - task: event.tag as unknown as GanttTaskValue, - }); - this.ganttSvc.closeContextMenu(); - }); - this.ganttSvc.events.pipe(takeUntil(this._destroy$)).subscribe(event => { - this.event.emit(event); - }); - } - - ngOnChanges() { - this.ganttSvc.feed(); - } - - ngAfterViewInit() { - this.ganttSvc.render(this.ganttContainer, this); - } - - override ngOnDestroy() { - this.ganttSvc.destroy(); - super.ngOnDestroy(); - } -} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars-routing.module.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars-routing.module.ts deleted file mode 100644 index 03520731..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars-routing.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; - -const routes: Routes = []; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], -}) -export class GanttBarsRoutingModule {} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.html b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.html index 90e2d17f..96d9c8fa 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.html +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.html @@ -38,9 +38,7 @@ [attr.gantt-bar-data]="stringify(allocationBar)" gantt-hover="bar" [ngClass]="allocationBar.classes ?? []" - [ngStyle]="{ - width: allocationBar.percent + '%', - }" + [ngStyle]="{width: allocationBar.percent + '%'}" [class.empty]="!allocationBar.allocation" [class.over-allocated]="allocationBar.allocation > allocationBase" > diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.scss b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.scss index 46f1769e..43142620 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.scss +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.scss @@ -1,6 +1,5 @@ @use 'sass:map'; -// @use "../../../../theme/styles/variables" as *; -@use 'projects/arc-lib/src/lib/theme/styles/_variables.scss' as *; +@use '../../../../theme/styles/variables' as *; .actual-rate { padding: 0.25rem 0.5rem; @@ -28,7 +27,7 @@ display: flex; justify-content: space-between; align-items: center; - height: 100%; + height: 20px; overflow: hidden; &.actual-bar { diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.spec.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.spec.ts index 2800e0b9..e80f1f75 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.spec.ts +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.spec.ts @@ -1,34 +1,16 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; -import {AnyObject} from '@project-lib/core/api'; -import {TranslationService} from '@project-lib/core/localization'; -import { - TranslateFakeLoader, - TranslateLoader, - TranslateModule, - TranslateService, -} from '@ngx-translate/core'; + import {GanttBarsComponent} from './gantt-bars.component'; describe('GanttBarsComponent', () => { - let component: GanttBarsComponent; - let fixture: ComponentFixture>; + let component: GanttBarsComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [GanttBarsComponent], - providers: [TranslateService, TranslationService], - imports: [ - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useClass: TranslateFakeLoader, - }, - }), - ], }).compileComponents(); - }); - beforeEach(() => { fixture = TestBed.createComponent(GanttBarsComponent); component = fixture.componentInstance; fixture.detectChanges(); diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts index 135d8091..ade32143 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.component.ts @@ -1,42 +1,32 @@ -import {Component} from '@angular/core'; -import {AnyObject} from '@project-lib/core/api'; -import {MAX_ALLOCATION} from '@project-lib/core/constants'; -import {TranslationService} from '@project-lib/core/localization'; -import {TranslateService} from '@ngx-translate/core'; -import { - GanttTaskValue, - GanttTaskValueWithSubAllocation, - SubAllocation, -} from '../../types'; +import {Component, Input} from '@angular/core'; +import {AllocationBar, Item} from '../../model/item.model'; @Component({ - selector: 'gantt-bars', + selector: 'arc-gantt-bars', templateUrl: './gantt-bars.component.html', styleUrls: ['./gantt-bars.component.scss'], }) -export class GanttBarsComponent { - item!: GanttTaskValue; - allocationTypes: AnyObject; - allocationBase = MAX_ALLOCATION; - private translate: TranslateService; - constructor(private translateSvc: TranslationService) { - this.translate = translateSvc.translate; - } +export class GanttBarsComponent { + @Input() item: Item; + @Input() allocationTypes: any; + @Input() allocationBase: number; - stringify(subAllocation: SubAllocation) { - return JSON.stringify(subAllocation); + constructor() { + console.log('hii tiny'); + } + formatAllocation(value: number): string { + return `${value} hours`; } - formatter(rate: number) { - return `$${rate}/${this.translate.instant('hr')}`; + + formatter(value: number): string { + return `$${value}/hour`; } - formatAllocation(allocation: number) { - return `${allocation}${this.translate.instant('h/d')}`; + hasSubAllocation(item: Item): boolean { + return item.subAllocations && item.subAllocations.length > 0; } - hasSubAllocation( - item: GanttTaskValue, - ): item is GanttTaskValueWithSubAllocation { - return !!(item as GanttTaskValueWithSubAllocation).subAllocations; + stringify(allocationBar: AllocationBar): string { + return JSON.stringify(allocationBar); } } diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.module.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.module.ts deleted file mode 100644 index bffe28d3..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-bars/gantt-bars.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; - -import {GanttBarsRoutingModule} from './gantt-bars-routing.module'; -import {GanttBarsComponent} from './gantt-bars.component'; -import {ThemeModule} from '@project-lib/theme/theme.module'; - -@NgModule({ - declarations: [GanttBarsComponent], - imports: [CommonModule, GanttBarsRoutingModule, ThemeModule], - exports: [GanttBarsComponent], -}) -export class GanttBarsModule {} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column-routing.module.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column-routing.module.ts deleted file mode 100644 index 9ae3f0ff..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column-routing.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; - -const routes: Routes = []; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], -}) -export class GanttColumnRoutingModule {} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.html b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.html index a6559da9..5e20fe63 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.html +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.html @@ -1,4 +1,4 @@ -
+
{{ item.name }}
@@ -32,13 +32,4 @@
This resource is over allocated
-
- -
diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.scss b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.scss index 5a8b7f4d..04386efb 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.scss +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.scss @@ -1,7 +1,13 @@ -// @use "../../../../theme/styles/variables" as *; -@use 'projects/arc-lib/src/lib/theme/styles/_variables.scss' as *; +@use '../../../../theme/styles/variables' as *; @use 'sass:map'; -.column-container { + +.employee-list-item { + display: flex; + align-items: center; + gap: 15px; + margin-bottom: 10px; + border-bottom: 1px solid #d9d9d9; + padding-bottom: 10px; .kebab-container { position: absolute; background: linear-gradient( @@ -14,10 +20,12 @@ opacity: 0; transition: opacity 0.2s ease-in; height: 100%; + width: 70%; .kebab { padding: 0 2rem; } } + &:hover, &.active { .kebab-container { @@ -32,6 +40,7 @@ .employee-icon { min-width: 2.375rem; + max-width: 2.375rem; height: 2.375rem; border-radius: 50%; background: map.get($color, 'menu-item-active'); @@ -43,6 +52,7 @@ margin: auto; } } + .with-designation { overflow: hidden; flex-grow: 1; @@ -72,6 +82,7 @@ text-overflow: ellipsis; } } + .without-designation { overflow: hidden; flex-grow: 1; @@ -108,6 +119,7 @@ right: -4.063rem; top: -0.313rem; } + .overallocation_icon:hover div { display: flex; line-height: 1; diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.spec.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.spec.ts new file mode 100644 index 00000000..e55dcf7c --- /dev/null +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.spec.ts @@ -0,0 +1,22 @@ +import {ComponentFixture, TestBed} from '@angular/core/testing'; + +import {GanttColumnComponent} from './gantt-column.component'; + +describe('GColumnComponent', () => { + let component: GanttColumnComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [GanttColumnComponent], + }).compileComponents(); + + fixture = TestBed.createComponent(GanttColumnComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.ts index 83e11025..7562c674 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.ts +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.component.ts @@ -1,35 +1,21 @@ import {Component, Input} from '@angular/core'; -import {AnyObject} from '@project-lib/core/api'; -import {NbMenuItem} from '@nebular/theme'; -import {ContextItemFilter, GanttTaskValue} from '../../types'; +import {empData} from '../../model/item.model'; @Component({ - selector: 'gantt-column', + selector: 'arc-gantt-column', templateUrl: './gantt-column.component.html', styleUrls: ['./gantt-column.component.scss'], }) -export class GanttColumnComponent { +export class GanttColumnComponent { @Input() - item!: GanttTaskValue; + items: empData[]; @Input() - contextItems: NbMenuItem[] = []; + showParentInitials: boolean; @Input() - active!: boolean; + showChildInitials: boolean; @Input() - showKebab!: boolean; - - @Input() - showParentInitials!: boolean; - - @Input() - showChildInitials!: boolean; - - @Input() - showOverallocatedIcon!: boolean; - - @Input() - contextItemFilter!: ContextItemFilter; + showOverallocatedIcon: boolean; } diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.module.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.module.ts deleted file mode 100644 index bbac0283..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-column/gantt-column.module.ts +++ /dev/null @@ -1,13 +0,0 @@ -import {NgModule} from '@angular/core'; -import {CommonModule} from '@angular/common'; - -import {GanttColumnRoutingModule} from './gantt-column-routing.module'; -import {GanttColumnComponent} from './gantt-column.component'; -import {ThemeModule} from '@project-lib/theme/theme.module'; - -@NgModule({ - declarations: [GanttColumnComponent], - imports: [CommonModule, GanttColumnRoutingModule, ThemeModule], - exports: [GanttColumnComponent], -}) -export class GanttColumnModule {} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header-routing.module.ts b/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header-routing.module.ts deleted file mode 100644 index f13d934c..00000000 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header-routing.module.ts +++ /dev/null @@ -1,10 +0,0 @@ -import {NgModule} from '@angular/core'; -import {RouterModule, Routes} from '@angular/router'; - -const routes: Routes = []; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule], -}) -export class GanttHeaderRoutingModule {} diff --git a/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html b/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html index 6ee77585..a35f033b 100644 --- a/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html +++ b/projects/arc-lib/src/lib/components/gantt/components/gantt-header/gantt-header.component.html @@ -1,22 +1,9 @@ -
-