Skip to content

Commit 41f7b3b

Browse files
Fix: Angular implementation, lint, and build to v25.1.3
1 parent 8b5290b commit 41f7b3b

12 files changed

+6705
-4940
lines changed

Angular/package-lock.json

Lines changed: 6515 additions & 4702 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Angular/src/app/app.component.html

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
<div class="default-style">
2-
<dx-button [text]="buttonText" (onClick)="onClick($event)"></dx-button>
3-
</div>
1+
<dx-data-grid
2+
[dataSource]="employees"
3+
(onEditorPreparing)="onEditorPreparing($event)">
4+
<dxo-editing
5+
[allowUpdating]="true"
6+
[allowAdding]="true">
7+
</dxo-editing>
8+
9+
<dxi-column
10+
caption="Name"
11+
dataField="CustomerID"
12+
[setCellValue]="setCellValue">
13+
<dxo-lookup
14+
[dataSource]="customers"
15+
valueExpr="CustomerID"
16+
displayExpr="CustomerName">
17+
</dxo-lookup>
18+
</dxi-column>
19+
<dxi-column dataField="Address"></dxi-column>
20+
<dxi-column dataField="Phone"></dxi-column>
21+
</dx-data-grid>

Angular/src/app/app.component.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
1-
import { Component } from '@angular/core';
2-
import { ClickEvent } from 'devextreme/ui/button';
1+
import { Component, OnInit, ViewChild } from '@angular/core';
2+
import type { Customer, Employee } from './types';
3+
import { DxDataGridComponent, type DxDataGridTypes } from 'devextreme-angular/ui/data-grid';
4+
import type { ValueChangedEvent } from 'devextreme/ui/lookup';
5+
import { AppService } from './app.service';
36

47
@Component({
58
selector: 'app-root',
69
templateUrl: './app.component.html',
7-
styleUrls: ['./app.component.scss'],
10+
styleUrls: ['./app.component.scss']
811
})
9-
export class AppComponent {
10-
title = 'Angular';
12+
export class AppComponent implements OnInit {
13+
@ViewChild(DxDataGridComponent) dataGrid!: DxDataGridComponent<Employee, number>;
14+
employees: Employee[] = [];
15+
customers: Customer[] = [];
1116

12-
counter = 0;
17+
constructor(private service: AppService) {}
1318

14-
buttonText = 'Click count: 0';
19+
ngOnInit(): void {
20+
this.employees = this.service.getEmployees();
21+
this.customers = this.service.getCustomers();
22+
}
23+
24+
onEditorPreparing(e: DxDataGridTypes.EditorPreparingEvent<Employee, number>): void {
25+
if (e.parentType === 'dataRow' && e.dataField === 'CustomerID') {
26+
e.editorOptions.onValueChanged = (ev: ValueChangedEvent): void => {
27+
const selectedItem = ev.component.option('selectedItem') as Customer;
28+
if (!selectedItem || !e.setValue) return;
29+
e.setValue(selectedItem);
30+
};
31+
}
32+
}
1533

16-
onClick(e: ClickEvent): void {
17-
this.counter++;
18-
this.buttonText = `Click count: ${this.counter}`;
34+
setCellValue(rowData: Employee, value: Customer): void {
35+
if (!rowData || !value) return;
36+
rowData.CustomerID = value.CustomerID;
37+
rowData.Address = value.Address;
38+
rowData.Phone = value.Phone;
1939
}
2040
}

Angular/src/app/app.module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { DxButtonModule } from 'devextreme-angular/ui/button';
3+
import { DxDataGridModule } from 'devextreme-angular/ui/data-grid';
44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
6+
import { AppService } from './app.service';
67

78
@NgModule({
89
declarations: [
@@ -11,9 +12,9 @@ import { AppComponent } from './app.component';
1112
imports: [
1213
BrowserModule,
1314
AppRoutingModule,
14-
DxButtonModule,
15+
DxDataGridModule,
1516
],
16-
providers: [],
17+
providers: [AppService],
1718
bootstrap: [AppComponent],
1819
})
1920
export class AppModule { }

Angular/src/app/app.service.ts

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { Injectable } from '@angular/core';
2+
import type { Customer, Employee } from './types';
3+
4+
@Injectable({
5+
providedIn: 'root'
6+
})
7+
export class AppService {
8+
getEmployees(): Employee[] {
9+
return [
10+
{ ID: 1, CustomerID: 1, Address: "Markušica", Phone: "+385 674 958 1641" },
11+
{ ID: 2, CustomerID: 2, Address: "Itaberaí", Phone: "+55 491 329 4084" },
12+
{ ID: 3, CustomerID: 3, Address: "Volgograd", Phone: "+7 745 619 7799" },
13+
{ ID: 4, CustomerID: 4, Address: "Shuiyin", Phone: "+86 774 746 9874" },
14+
{ ID: 5, CustomerID: 5, Address: "Baturaden", Phone: "+62 113 149 9397" },
15+
{ ID: 6, CustomerID: 6, Address: "New York City", Phone: "+1 917 528 7751" },
16+
{ ID: 7, CustomerID: 7, Address: "Adolfo Lopez Mateos", Phone: "+52 626 244 6757"},
17+
{ ID: 8, CustomerID: 8, Address: "Nong Khae", Phone: "+66 326 375 8694" },
18+
{ ID: 9, CustomerID: 9, Address: "Znamenskoye", Phone: "+7 926 141 2517" },
19+
{ ID: 10, CustomerID: 10, Address: "Patpata Segundo", Phone: "+63 428 750 7737" },
20+
{ ID: 11, CustomerID: 11, Address: "Fontanka", Phone: "+380 557 509 4191" },
21+
{ ID: 12, CustomerID: 12, Address: "Novosil'", Phone: "+7 493 632 2768" },
22+
{ ID: 13, CustomerID: 13, Address: "Ubinskoye", Phone: "+7 954 353 8930" },
23+
{ ID: 14, CustomerID: 14, Address: "Protvino", Phone: "+7 386 362 2407" },
24+
{ ID: 15, CustomerID: 15, Address: "Santa Fé do Sul", Phone: "+55 867 691 7097" }
25+
];
26+
}
27+
28+
getCustomers(): Customer[] {
29+
return [
30+
{
31+
CustomerID: 1,
32+
CustomerName: "Kaela Phonix",
33+
Address: "Markušica",
34+
Phone: "+385 674 958 1641"
35+
},
36+
{
37+
CustomerID: 2,
38+
CustomerName: "Dotty Hearnden",
39+
Address: "Itaberaí",
40+
Phone: "+55 491 329 4084"
41+
},
42+
{
43+
CustomerID: 3,
44+
CustomerName: "Alasdair Greenin",
45+
Address: "Volgograd",
46+
Phone: "+7 657 495 7659"
47+
},
48+
{
49+
CustomerID: 4,
50+
CustomerName: "Stoddard Laidlaw",
51+
Address: "Shuiyin",
52+
Phone: "+86 774 746 9874"
53+
},
54+
{
55+
CustomerID: 5,
56+
CustomerName: "Damiano Gencke",
57+
Address: "Baturaden",
58+
Phone: "+62 113 149 9397"
59+
},
60+
{
61+
CustomerID: 6,
62+
CustomerName: "Aura Bavidge",
63+
Address: "New York City",
64+
Phone: "+1 917 528 7751"
65+
},
66+
{
67+
CustomerID: 7,
68+
CustomerName: "Emmanuel Chedgey",
69+
Address: "Adolfo Lopez Mateos",
70+
Phone: "+52 626 244 6757"
71+
},
72+
{
73+
CustomerID: 8,
74+
CustomerName: "Clerkclaude Pargeter",
75+
Address: "Nong Khae",
76+
Phone: "+66 326 375 8694"
77+
},
78+
{
79+
CustomerID: 9,
80+
CustomerName: "Onfroi Cinnamond",
81+
Address: "Znamenskoye",
82+
Phone: "+7 926 141 2517"
83+
},
84+
{
85+
CustomerID: 10,
86+
CustomerName: "Madlin Kopke",
87+
Address: "Patpata Segundo",
88+
Phone: "+63 428 750 7737"
89+
},
90+
{
91+
CustomerID: 11,
92+
CustomerName: "Mortie Feary",
93+
Address: "Fontanka",
94+
Phone: "+380 557 509 4191"
95+
},
96+
{
97+
CustomerID: 12,
98+
CustomerName: "Colet Haitlie",
99+
Address: "Novosil'",
100+
Phone: "+7 493 632 2768"
101+
},
102+
{
103+
CustomerID: 13,
104+
CustomerName: "Pippy Carnell",
105+
Address: "Ubinskoye",
106+
Phone: "+7 954 353 8930"
107+
},
108+
{
109+
CustomerID: 14,
110+
CustomerName: "Arvie Midden",
111+
Address: "Protvino",
112+
Phone: "+7 386 362 2407"
113+
},
114+
{
115+
CustomerID: 15,
116+
CustomerName: "Brook Kamena",
117+
Address: "Santa Fé do Sul",
118+
Phone: "+55 867 691 7097"
119+
}
120+
];
121+
}
122+
}

Angular/src/app/orig_app.component.html

Lines changed: 0 additions & 25 deletions
This file was deleted.

Angular/src/app/orig_app.component.scss

Whitespace-only changes.

Angular/src/app/orig_app.component.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)