Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import { provideHttpClient, withFetch } from '@angular/common/http';
import { DxDiagramModule } from 'devextreme-angular';
import { ArrayStore } from 'devextreme-angular/common/data';
import { Service } from './app.service';
import type { OrgItem } from './app.service';

type DiagramItem = OrgItem & {
Width?: number;
Height?: number;
};

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand Down Expand Up @@ -33,36 +39,36 @@ export class AppComponent {
data: this.service.getOrgLinks(),
});

itemTypeExpr(obj, value) {
itemTypeExpr(obj: DiagramItem, value?: string) {
if (value) {
obj.Type = (value === 'rectangle') ? undefined : 'group';
return null;
}
return obj.Type === 'group' ? 'ellipse' : 'rectangle';
}

itemWidthExpr(obj, value) {
itemWidthExpr(obj: DiagramItem, value?: number) {
if (value) {
obj.Width = value;
return null;
}
return obj.Width || (obj.Type === 'group' && 1.5) || 1;
}

itemHeightExpr(obj, value) {
itemHeightExpr(obj: DiagramItem, value?: number) {
if (value) {
obj.Height = value;
return null;
}
return obj.Height || (obj.Type === 'group' && 1) || 0.75;
}

itemTextStyleExpr(obj) {
itemTextStyleExpr(obj: DiagramItem) {
if (obj.Level === 'senior') { return { 'font-weight': 'bold', 'text-decoration': 'underline' }; }
return {};
}

itemStyleExpr(obj) {
itemStyleExpr(obj: DiagramItem) {
const style: Record<string, string> = { stroke: '#444444' };
if (obj.Type === 'group') { style.fill = '#f3f3f3'; }
return style;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class OrgItem {
export interface OrgItem {
ID: string;

Name: string;
Expand All @@ -10,7 +10,7 @@ export class OrgItem {
Level?: string;
}

export class OrgLink {
export interface OrgLink {
ID: string;

From: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import {
DxPopupModule, DxDiagramModule,
} from 'devextreme-angular';
import { ArrayStore } from 'devextreme-angular/common/data';
import { Service, Employee } from './app.service';
import { Service } from './app.service';
import type { Employee } from './app.service';

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand All @@ -26,7 +27,7 @@ if (!/localhost/.test(document.location.host)) {
export class AppComponent {
private readonly service = inject(Service);

readonly currentEmployee = signal<Employee>(new Employee());
readonly currentEmployee = signal<Partial<Employee>>({});

readonly employees: Employee[] = this.service.getEmployees();

Expand All @@ -37,7 +38,7 @@ export class AppComponent {

readonly popupVisible = signal(false);

itemTypeExpr(obj, value) {
itemTypeExpr(obj: Employee & { type?: string }, value?: string) {
if (value === undefined) {
return `employee${obj.ID}`;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import {
DxPopupModule, DxDiagramModule, DxTextBoxModule, DxButtonModule,
} from 'devextreme-angular';
import { ArrayStore } from 'devextreme-angular/common/data';
import { Service, Employee } from './app.service';
import type { DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { Service } from './app.service';
import type { Employee } from './app.service';

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand All @@ -26,7 +28,7 @@ if (!/localhost/.test(document.location.host)) {
],
})
export class AppComponent {
readonly currentEmployee = signal<Employee>(new Employee());
readonly currentEmployee = signal<Employee>({} as Employee);

readonly popupVisible = signal(false);

Expand All @@ -42,15 +44,15 @@ export class AppComponent {
},
});

itemTypeExpr(obj, value) {
itemTypeExpr(obj: Employee & { type?: string }, value?: string) {
if (value === undefined) {
return 'employee';
}
obj.type = value;
return null;
}

itemCustomDataExpr(obj, value) {
itemCustomDataExpr(obj: Employee, value?: Employee) {
if (value === undefined) {
return {
Full_Name: obj.Full_Name,
Expand All @@ -74,7 +76,7 @@ export class AppComponent {
return null;
}

requestLayoutUpdateHandler(e) {
requestLayoutUpdateHandler(e: DxDiagramTypes.RequestLayoutUpdateEvent) {
for (let i = 0; i < e.changes.length; i += 1) {
if (e.changes[i].type === 'remove') { e.allowed = true; } else if (e.changes[i].data.Head_ID !== undefined && e.changes[i].data.Head_ID !== null) { e.allowed = true; }
}
Expand All @@ -85,7 +87,7 @@ export class AppComponent {
this.popupVisible.set(true);
}

deleteEmployee(employee) {
deleteEmployee(employee: Employee) {
this.dataSource.push([{ type: 'remove', key: employee.ID }]);
}

Expand All @@ -108,7 +110,7 @@ export class AppComponent {
}

cancelEditEmployee() {
this.currentEmployee.set(new Employee());
this.currentEmployee.set({} as Employee);
this.popupVisible.set(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class OrgItem {
export interface OrgItem {
ID: string;

Text: string;
Expand All @@ -10,7 +10,7 @@ export class OrgItem {
Picture: string;
}

export class OrgLink {
export interface OrgLink {
ID: string;

From: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
Component,
Pipe,
type PipeTransform,
enableProdMode,
inject,
signal,
Component, Pipe, enableProdMode, inject, signal,
} from '@angular/core';
import type { PipeTransform } from '@angular/core';
import { bootstrapApplication } from '@angular/platform-browser';
import { ArrayStore } from 'devextreme-angular/common/data';
import { DxDiagramModule, DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { DxDiagramModule } from 'devextreme-angular/ui/diagram';
import type { DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { Service } from './app.service';

if (!/localhost/.test(document.location.host)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import { Injectable } from '@angular/core';

export class FlowNode {
export interface FlowNode {
id: number;

text: string;

type: string;
}

export class FlowEdge {
export interface FlowEdge {
id: number;

fromId: number;

toId: number;

text: string;
text: string | null;
}

const flowNodes: FlowNode[] = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
Full_Name: string;

Prefix: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Component, enableProdMode, inject } from '@angular/core';
import { provideHttpClient, withFetch } from '@angular/common/http';
import notify from 'devextreme/ui/notify';
import { ArrayStore } from 'devextreme-angular/common/data';
import { DxDiagramModule, DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { DxDiagramModule } from 'devextreme-angular/ui/diagram';
import type { DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { Service } from './app.service';

if (!/localhost/.test(document.location.host)) {
Expand Down Expand Up @@ -43,7 +44,7 @@ export class AppComponent {
}
}

requestEditOperationHandler(e) {
requestEditOperationHandler(e: Record<string, any>) {
const diagram = e.component.instance();
if (e.operation === 'addShape') {
if (e.args.shape.type !== 'employee' && e.args.shape.type !== 'team') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class OrgItem {
export interface OrgItem {
ID: string;

Name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core';

export class Employee {
export interface Employee {
ID: number;

Head_ID: number;
Head_ID?: number;

Full_Name: string;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
import { HttpClient, provideHttpClient, withFetch } from '@angular/common/http';

import { DxDiagramModule, DxDiagramComponent } from 'devextreme-angular';
import type { DxDiagramTypes } from 'devextreme-angular/ui/diagram';
import { confirm } from 'devextreme/ui/dialog';

if (!/localhost/.test(document.location.host)) {
Expand All @@ -30,7 +31,7 @@ export class AppComponent {
});
}

onCustomCommand(e) {
onCustomCommand(e: DxDiagramTypes.CustomCommandEvent) {
if (e.name === 'clear') {
const result = confirm('Are you sure you want to clear the diagram? This action cannot be undone.', 'Warning');
result.then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
</div>
<div class="widget-container">
<dx-gantt
taskListWidth="500"
[taskListWidth]="500"
height="700"
[taskTitlePosition]="titlePosition()"
[scaleType]="scaleType()"
Expand Down
10 changes: 6 additions & 4 deletions apps/demos/Demos/Gantt/Appearance/Angular/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import {
Component, enableProdMode, inject, signal, ViewEncapsulation,
} from '@angular/core';
import { DxCheckBoxModule, DxSelectBoxModule, DxDateBoxModule } from 'devextreme-angular';
import { DxGanttModule, type DxGanttTypes } from 'devextreme-angular/ui/gantt';
import { Service, type Task } from './app.service';
import { DxGanttModule } from 'devextreme-angular/ui/gantt';
import type { DxGanttTypes } from 'devextreme-angular/ui/gantt';
import { Service } from './app.service';
import type { Task } from './app.service';

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand Down Expand Up @@ -35,9 +37,9 @@ export class AppComponent {

readonly resourceAssignments = this.service.getResourceAssignments();

readonly scaleType = signal<DxGanttTypes.Properties['scaleType']>('months');
readonly scaleType = signal<NonNullable<DxGanttTypes.Properties['scaleType']>>('months');

readonly titlePosition = signal<DxGanttTypes.Properties['taskTitlePosition']>('outside');
readonly titlePosition = signal<NonNullable<DxGanttTypes.Properties['taskTitlePosition']>>('outside');

readonly showResources = signal(true);

Expand Down
Loading
Loading