Skip to content

Commit

Permalink
build: migration standalone #INFR-11783
Browse files Browse the repository at this point in the history
  • Loading branch information
lswl66 authored and walkerkay committed Mar 7, 2024
1 parent 5652b84 commit 70a821a
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 40 deletions.
5 changes: 4 additions & 1 deletion packages/gantt/src/components/bar/bar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { barBackground } from '../../gantt.styles';
import { GanttBarClickEvent } from '../../class';
import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper';
import { GanttItemUpper } from '../../gantt-item-upper';
import { NgIf, NgTemplateOutlet } from '@angular/common';

function linearGradient(sideOrCorner: string, color: string, stop: string) {
return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
Expand All @@ -32,7 +33,9 @@ function linearGradient(sideOrCorner: string, color: string, stop: string) {
@Component({
selector: 'ngx-gantt-bar,gantt-bar',
templateUrl: './bar.component.html',
providers: [GanttBarDrag]
providers: [GanttBarDrag],
standalone: true,
imports: [NgIf, NgTemplateOutlet]
})
export class NgxGanttBarComponent extends GanttItemUpper implements OnInit, AfterViewInit, OnChanges, OnDestroy {
@Output() barClick = new EventEmitter<GanttBarClickEvent>();
Expand Down
5 changes: 4 additions & 1 deletion packages/gantt/src/components/baseline/baseline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { GanttBaselineItemInternal } from '../../class/baseline';
import { GanttUpper, GANTT_UPPER_TOKEN } from '../../gantt-upper';
import { NgIf, NgTemplateOutlet } from '@angular/common';

@Component({
selector: 'ngx-gantt-baseline,gantt-baseline',
templateUrl: './baseline.component.html'
templateUrl: './baseline.component.html',
standalone: true,
imports: [NgIf, NgTemplateOutlet]
})
export class NgxGanttBaselineComponent implements OnInit {
@Input() baselineItem: GanttBaselineItemInternal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import { isNumber } from '../../../utils/helpers';
import { GANTT_UPPER_TOKEN, GanttUpper } from '../../../gantt-upper';
import { GanttViewType } from './../../../class/view-type';
import { headerHeight, todayBorderRadius } from '../../../gantt.styles';
import { NgIf, NgFor } from '@angular/common';

const mainHeight = 5000;

@Component({
selector: 'gantt-calendar-grid',
templateUrl: './calendar-grid.component.html'
templateUrl: './calendar-grid.component.html',
standalone: true,
imports: [NgIf, NgFor]
})
export class GanttCalendarGridComponent implements OnInit, OnDestroy {
get view() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { take, takeUntil } from 'rxjs/operators';
import { Subject, merge } from 'rxjs';
import { GanttDate } from '../../../utils/date';
import { isNumber } from '../../../utils/helpers';
import { NgFor, NgStyle } from '@angular/common';

@Component({
selector: 'gantt-calendar-header',
templateUrl: './calendar-header.component.html'
templateUrl: './calendar-header.component.html',
standalone: true,
imports: [NgFor, NgStyle]
})
export class GanttCalendarHeaderComponent implements OnInit {
get view() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Component } from '@angular/core';
templateUrl: `./drag-backdrop.component.html`,
host: {
class: 'gantt-drag-backdrop'
}
},
standalone: true
})
export class GanttDragBackdropComponent {}
3 changes: 2 additions & 1 deletion packages/gantt/src/components/icon/icon.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { icons } from './icons';

@Component({
selector: 'gantt-icon',
template: ''
template: '',
standalone: true
})
export class GanttIconComponent {
@HostBinding('class.gantt-icon') isIcon = true;
Expand Down
5 changes: 4 additions & 1 deletion packages/gantt/src/components/links/links.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper';
import { GanttLinkItem, LinkInternal, LinkColors, GanttLinkType } from '../../class/link';
import { GanttLinkLine } from './lines/line';
import { createLineGenerator } from './lines/factory';
import { NgFor, NgIf } from '@angular/common';

@Component({
selector: 'gantt-links-overlay',
templateUrl: './links.component.html'
templateUrl: './links.component.html',
standalone: true,
imports: [NgFor, NgIf]
})
export class GanttLinksComponent implements OnInit, OnChanges, OnDestroy {
// @Input() groups: GanttGroupInternal[] = [];
Expand Down
3 changes: 2 additions & 1 deletion packages/gantt/src/components/loader/loader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Component } from '@angular/core';
`,
host: {
class: 'gantt-loader gantt-loader-overlay'
}
},
standalone: true
})
export class GanttLoaderComponent {}
22 changes: 21 additions & 1 deletion packages/gantt/src/components/main/gantt-main.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import { Component, HostBinding, Inject, Input, TemplateRef, Output, EventEmitter } 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';
import { NgxGanttBaselineComponent } from '../baseline/baseline.component';
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';

@Component({
selector: 'gantt-main',
templateUrl: './gantt-main.component.html'
templateUrl: './gantt-main.component.html',
standalone: true,
imports: [
GanttLinksComponent,
NgFor,
NgIf,
NgClass,
NgTemplateOutlet,
NgxGanttRangeComponent,
NgxGanttBarComponent,
NgxGanttBaselineComponent,
IsGanttRangeItemPipe,
IsGanttBarItemPipe,
IsGanttCustomItemPipe
]
})
export class GanttMainComponent {
@Input() viewportItems: (GanttGroupInternal | GanttItemInternal)[];
Expand Down
5 changes: 4 additions & 1 deletion packages/gantt/src/components/range/range.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { Component, HostBinding, ElementRef, Inject } from '@angular/core';
import { GANTT_UPPER_TOKEN, GanttUpper } from '../../gantt-upper';
import { GanttItemUpper } from '../../gantt-item-upper';
import { NgIf, NgTemplateOutlet } from '@angular/common';

@Component({
selector: 'ngx-gantt-range,gantt-range',
templateUrl: './range.component.html'
templateUrl: './range.component.html',
standalone: true,
imports: [NgIf, NgTemplateOutlet]
})
export class NgxGanttRangeComponent extends GanttItemUpper {
@HostBinding('class.gantt-range') ganttRangeClass = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ import { coerceCssPixelValue } from '@angular/cdk/coercion';
import { GanttAbstractComponent, GANTT_ABSTRACT_TOKEN } from '../../../gantt-abstract';
import { defaultColumnWidth } from '../header/gantt-table-header.component';
import { GanttUpper, GANTT_UPPER_TOKEN } from '../../../gantt-upper';
import { CdkDrag, CdkDragDrop, CdkDragEnd, CdkDragMove, CdkDragStart, DragRef } from '@angular/cdk/drag-drop';
import { DOCUMENT } from '@angular/common';
import { CdkDrag, CdkDragDrop, CdkDragEnd, CdkDragMove, CdkDragStart, DragRef, CdkDropList, CdkDragHandle } from '@angular/cdk/drag-drop';
import { DOCUMENT, NgIf, NgTemplateOutlet, NgFor, NgClass } from '@angular/common';
import { IsGanttRangeItemPipe } from '../../../gantt.pipe';
import { GanttIconComponent } from '../../icon/icon.component';
@Component({
selector: 'gantt-table-body',
templateUrl: './gantt-table-body.component.html'
templateUrl: './gantt-table-body.component.html',
standalone: true,
imports: [CdkDropList, NgIf, GanttIconComponent, NgTemplateOutlet, NgFor, NgClass, CdkDrag, CdkDragHandle, IsGanttRangeItemPipe]
})
export class GanttTableBodyComponent implements OnInit, OnDestroy, AfterViewInit {
private _viewportItems: (GanttGroupInternal | GanttItemInternal)[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ import {
ChangeDetectorRef
} from '@angular/core';
import { NgxGanttTableColumnComponent } from '../../../table/gantt-column.component';
import { CdkDragEnd, CdkDragMove, CdkDragStart } from '@angular/cdk/drag-drop';
import { CdkDragEnd, CdkDragMove, CdkDragStart, CdkDrag } from '@angular/cdk/drag-drop';
import { coerceCssPixelValue } from '@angular/cdk/coercion';
import { GanttAbstractComponent, GANTT_ABSTRACT_TOKEN } from '../../../gantt-abstract';
import { setStyleWithVendorPrefix } from '../../../utils/set-style-with-vendor-prefix';
import { Subject, takeUntil } from 'rxjs';
import { NgFor, NgIf, NgTemplateOutlet } from '@angular/common';

export const defaultColumnWidth = 100;
export const minColumnWidth = 80;
Expand All @@ -27,7 +28,9 @@ interface DragFixedConfig {
}
@Component({
selector: 'gantt-table-header',
templateUrl: './gantt-table-header.component.html'
templateUrl: './gantt-table-header.component.html',
standalone: true,
imports: [NgFor, NgIf, NgTemplateOutlet, CdkDrag]
})
export class GanttTableHeaderComponent implements OnInit, OnDestroy {
public dragStartLeft: number;
Expand Down
5 changes: 4 additions & 1 deletion packages/gantt/src/components/toolbar/toolbar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { Component, HostBinding, Input, TemplateRef, Inject, SimpleChanges, OnCh
import { ganttViews, GanttViewType } from '../../class';
import { GanttUpper, GANTT_UPPER_TOKEN } from '../../gantt-upper';
import { keyBy } from '../../utils/helpers';
import { NgIf, NgFor, NgTemplateOutlet } from '@angular/common';

@Component({
selector: 'ngx-gantt-toolbar,gantt-toolbar',
templateUrl: './toolbar.component.html'
templateUrl: './toolbar.component.html',
standalone: true,
imports: [NgIf, NgFor, NgTemplateOutlet]
})
export class NgxGanttToolbarComponent {
@Input() template: TemplateRef<any>;
Expand Down
27 changes: 26 additions & 1 deletion packages/gantt/src/gantt.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ import { GANTT_ABSTRACT_TOKEN } from './gantt-abstract';
import { GanttGlobalConfig, GANTT_GLOBAL_CONFIG } from './gantt.config';
import { NgxGanttRootComponent } from './root.component';
import { GanttDate } from './utils/date';
import { CdkVirtualScrollViewport, ViewportRuler } from '@angular/cdk/scrolling';
import { CdkVirtualScrollViewport, ViewportRuler, CdkFixedSizeVirtualScroll, CdkVirtualForOf } from '@angular/cdk/scrolling';
import { Dictionary, keyBy, recursiveItems, uniqBy } from './utils/helpers';
import { GanttDragBackdropComponent } from './components/drag-backdrop/drag-backdrop.component';
import { GanttMainComponent } from './components/main/gantt-main.component';
import { GanttCalendarGridComponent } from './components/calendar/grid/calendar-grid.component';
import { GanttTableBodyComponent } from './components/table/body/gantt-table-body.component';
import { GanttLoaderComponent } from './components/loader/loader.component';
import { NgIf, NgClass, NgTemplateOutlet } from '@angular/common';
import { GanttCalendarHeaderComponent } from './components/calendar/header/calendar-header.component';
import { GanttTableHeaderComponent } from './components/table/header/gantt-table-header.component';
@Component({
selector: 'ngx-gantt',
templateUrl: './gantt.component.html',
Expand All @@ -55,6 +63,23 @@ import { Dictionary, keyBy, recursiveItems, uniqBy } from './utils/helpers';
provide: GANTT_ABSTRACT_TOKEN,
useExisting: forwardRef(() => NgxGanttComponent)
}
],
standalone: true,
imports: [
NgxGanttRootComponent,
GanttTableHeaderComponent,
GanttCalendarHeaderComponent,
NgIf,
GanttLoaderComponent,
CdkVirtualScrollViewport,
CdkFixedSizeVirtualScroll,
NgClass,
CdkVirtualForOf,
GanttTableBodyComponent,
GanttCalendarGridComponent,
GanttMainComponent,
GanttDragBackdropComponent,
NgTemplateOutlet
]
})
export class NgxGanttComponent extends GanttUpper implements OnInit, OnChanges, AfterViewInit, AfterViewChecked {
Expand Down
32 changes: 17 additions & 15 deletions packages/gantt/src/gantt.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,10 @@ import { GanttTableBodyComponent } from './components/table/body/gantt-table-bod
import { GanttLoaderComponent } from './components/loader/loader.component';

@NgModule({
imports: [CommonModule, DragDropModule, ScrollingModule],
exports: [
NgxGanttComponent,
NgxGanttTableComponent,
NgxGanttTableColumnComponent,
NgxGanttRootComponent,
NgxGanttBarComponent,
NgxGanttRangeComponent,
NgxGanttBaselineComponent,
NgxGanttToolbarComponent,
GanttCalendarHeaderComponent,
GanttCalendarGridComponent,
GanttDragBackdropComponent
],
declarations: [
imports: [
CommonModule,
DragDropModule,
ScrollingModule,
NgxGanttComponent,
NgxGanttTableComponent,
NgxGanttTableColumnComponent,
Expand All @@ -59,6 +48,19 @@ import { GanttLoaderComponent } from './components/loader/loader.component';
IsGanttBarItemPipe,
IsGanttCustomItemPipe
],
exports: [
NgxGanttComponent,
NgxGanttTableComponent,
NgxGanttTableColumnComponent,
NgxGanttRootComponent,
NgxGanttBarComponent,
NgxGanttRangeComponent,
NgxGanttBaselineComponent,
NgxGanttToolbarComponent,
GanttCalendarHeaderComponent,
GanttCalendarGridComponent,
GanttDragBackdropComponent
],
providers: [
CdkVirtualScrollViewport,
{
Expand Down
11 changes: 6 additions & 5 deletions packages/gantt/src/gantt.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ import { Pipe, PipeTransform } from '@angular/core';
import { GanttItemType } from './class';

@Pipe({
name: 'isGanttRangeItem'
name: 'isGanttRangeItem',
standalone: true
})
export class IsGanttRangeItemPipe implements PipeTransform {
transform(value: GanttItemType) {
return value === GanttItemType.range;
}
}


@Pipe({
name: 'isGanttBarItem'
name: 'isGanttBarItem',
standalone: true
})
export class IsGanttBarItemPipe implements PipeTransform {
transform(value: GanttItemType) {
return value === GanttItemType.bar;
}
}


@Pipe({
name: 'isGanttCustomItem'
name: 'isGanttCustomItem',
standalone: true
})
export class IsGanttCustomItemPipe implements PipeTransform {
transform(value: GanttItemType) {
Expand Down
17 changes: 16 additions & 1 deletion packages/gantt/src/root.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,29 @@ import { GanttPrintService } from './gantt-print.service';
import { passiveListenerOptions } from './utils/passive-listeners';
import { GanttDragBackdropComponent } from './components/drag-backdrop/drag-backdrop.component';
import { GanttDate } from './utils/date';
import { NgxGanttToolbarComponent } from './components/toolbar/toolbar.component';
import { GanttCalendarGridComponent } from './components/calendar/grid/calendar-grid.component';
import { GanttCalendarHeaderComponent } from './components/calendar/header/calendar-header.component';
import { CdkScrollable } from '@angular/cdk/scrolling';
import { NgIf, NgTemplateOutlet } from '@angular/common';

@Component({
selector: 'ngx-gantt-root',
templateUrl: './root.component.html',
providers: [GanttDomService, GanttDragContainer],
host: {
class: 'gantt'
}
},
standalone: true,
imports: [
NgIf,
CdkScrollable,
NgTemplateOutlet,
GanttCalendarHeaderComponent,
GanttCalendarGridComponent,
GanttDragBackdropComponent,
NgxGanttToolbarComponent
]
})
export class NgxGanttRootComponent implements OnInit, OnDestroy {
@Input() sideWidth: number;
Expand Down
3 changes: 2 additions & 1 deletion packages/gantt/src/table/gantt-column.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { GanttUpper, GANTT_UPPER_TOKEN } from '../gantt-upper';
template: '',
host: {
class: 'gantt-table-column'
}
},
standalone: true
})
export class NgxGanttTableColumnComponent {
public columnWidth: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/gantt/src/table/gantt-table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {

@Component({
selector: 'ngx-gantt-table',
template: ''
template: '',
standalone: true
})
export class NgxGanttTableComponent {
@Input() draggable = false;
Expand Down

0 comments on commit 70a821a

Please sign in to comment.