Skip to content

Commit 2371a23

Browse files
Fix: Angular implementation, lint, and build
1 parent 83b491c commit 2371a23

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

Angular/angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"builder": "@angular-devkit/build-angular:browser",
1919
"options": {
2020
"allowedCommonJsDependencies": [
21+
"devextreme-aspnet-data-nojquery",
2122
"devextreme-quill",
2223
"jszip",
2324
"devexpress-diagram",

Angular/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
99
"test": "ng test",
10-
"lint-html": "prettier --write .",
11-
"lint-ts": "eslint --ext .ts . --fix",
12-
"lint-css": "stylelint src/**/*.{css,scss} --allow-empty-input --fix",
10+
"lint-html": "prettier --check .",
11+
"lint-ts": "eslint --ext .ts .",
12+
"lint-css": "stylelint src/**/*.{css,scss} --allow-empty-input",
1313
"lint": "npm-run-all -p -c lint-ts lint-css lint-html"
1414
},
1515
"private": true,

Angular/src/app/app.component.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ <h3>DataGrid - Select multiple items and drag'n'drop between grids</h3>
1717
<dxo-data-grid-row-dragging
1818
[data]="status"
1919
group="tasksGroup"
20-
[onAdd]="onAdd"
21-
[onDragStart]="onDragStart"
20+
[onAdd]="$any(onAdd)"
21+
[onDragStart]="$any(onDragStart)"
2222
dragTemplate="drag-template"
2323
></dxo-data-grid-row-dragging>
2424

@@ -32,10 +32,12 @@ <h3>DataGrid - Select multiple items and drag'n'drop between grids</h3>
3232
</table>
3333
</div>
3434

35-
<dxo-selection mode="multiple"></dxo-selection>
35+
<dxo-data-grid-selection mode="multiple"></dxo-data-grid-selection>
3636

3737
<dxo-scrolling mode="virtual"></dxo-scrolling>
3838

39+
<dxo-data-grid-scrolling mode="virtual"></dxo-data-grid-scrolling>
40+
3941
<dxi-data-grid-column
4042
dataField="Subject"
4143
dataType="string"
@@ -45,11 +47,11 @@ <h3>DataGrid - Select multiple items and drag'n'drop between grids</h3>
4547
dataType="number"
4648
[width]="80"
4749
>
48-
<dxo-lookup
50+
<dxo-data-grid-lookup
4951
[dataSource]="priorities"
5052
valueExpr="id"
5153
displayExpr="text"
52-
></dxo-lookup>
54+
></dxo-data-grid-lookup>
5355
</dxi-data-grid-column>
5456
<dxi-data-grid-column
5557
dataField="Status"

Angular/src/app/app.component.ts

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import { Component } from '@angular/core';
22
import { KeyValue } from '@angular/common';
33
import { Task, Priority, GridDataService } from 'src/app/services/grid-data.service';
44
import * as AspNetData from 'devextreme-aspnet-data-nojquery';
5-
import DxDataGrid, {
6-
RowDraggingStartEvent, RowDraggingAddEvent, Column, Row,
7-
} from 'devextreme/ui/data_grid';
5+
import dxDataGrid from 'devextreme/ui/data_grid';
6+
import type { DxDataGridTypes } from 'devextreme-angular/ui/data-grid';
87
import CustomStore from 'devextreme/data/custom_store';
98
import { DataSourceOptions } from 'devextreme/data/data_source';
109
import notify from 'devextreme/ui/notify';
1110

11+
type CellValue = Task[keyof Task] | string | undefined;
12+
1213
@Component({
1314
selector: 'app-root',
1415
templateUrl: './app.component.html',
@@ -36,7 +37,7 @@ export class AppComponent {
3637
key: 'ID',
3738
loadUrl: `${url}/Tasks`,
3839
updateUrl: `${url}/UpdateTask`,
39-
onBeforeSend(method, ajaxOptions) {
40+
onBeforeSend(_method, ajaxOptions) {
4041
ajaxOptions.xhrFields = { withCredentials: true };
4142
},
4243
});
@@ -50,15 +51,15 @@ export class AppComponent {
5051
this.canDrag = this.canDrag.bind(this);
5152
}
5253

53-
onDragStart(e: any): void {
54+
onDragStart(e: DxDataGridTypes.RowDraggingStartEvent): void {
5455
const selectedData: Task[] = e.component.getSelectedRowsData();
5556
e.itemData = this.getVisibleRowValues(selectedData, e.component);
5657
e.cancel = !this.canDrag(e);
5758
}
5859

59-
async onAdd(e: any): Promise<void> {
60-
const fromGrid = e.fromComponent as DxDataGrid;
61-
const toGrid = e.toComponent as DxDataGrid;
60+
async onAdd(e: DxDataGridTypes.RowDraggingAddEvent): Promise<void> {
61+
const fromGrid = e.fromComponent as dxDataGrid;
62+
const toGrid = e.toComponent as dxDataGrid;
6263
const selectedRowKeys: (keyof Task)[] = fromGrid.getSelectedRowKeys();
6364
const updateProcess: Promise<any>[] = [];
6465
const changes: any[] = [];
@@ -80,7 +81,6 @@ export class AppComponent {
8081

8182
try {
8283
await Promise.all(updateProcess);
83-
8484
this.tasksStore.push(changes);
8585
fromGrid.endCustomLoading();
8686
toGrid.endCustomLoading();
@@ -95,11 +95,11 @@ export class AppComponent {
9595
}
9696
}
9797

98-
getVisibleRowValues(rowsData: Task[], grid: DxDataGrid): Record<string, Task[keyof Task] | string | undefined>[] {
98+
getVisibleRowValues(rowsData: Task[], grid: dxDataGrid): Record<string, CellValue>[] {
9999
const visibleColumns = grid.getVisibleColumns();
100100
const selectedData = rowsData.map((rowData: Task) => {
101-
const visibleValues: Record<string, Task[keyof Task] | string | undefined> = {};
102-
visibleColumns.forEach((column: Column) => {
101+
const visibleValues: Record<string, CellValue> = {};
102+
visibleColumns.forEach((column: DxDataGridTypes.Column) => {
103103
if (column.dataField) {
104104
visibleValues[column.dataField] = this.getVisibleCellValue(column, rowData);
105105
}
@@ -109,22 +109,17 @@ export class AppComponent {
109109
return selectedData;
110110
}
111111

112-
getVisibleCellValue(column: Column, rowData: Task): Task[keyof Task] | string | undefined {
113-
if (column.dataField) {
114-
const propKey = column.dataField as keyof Task;
115-
const cellValue = rowData[propKey];
116-
117-
return column.lookup?.calculateCellValue
118-
? String(column.lookup.calculateCellValue(cellValue))
119-
: cellValue;
120-
}
121-
return undefined;
112+
getVisibleCellValue(column: DxDataGridTypes.Column, rowData: Task): CellValue {
113+
const cellValue = rowData[column.dataField as keyof Task];
114+
return column.lookup?.calculateCellValue
115+
? String(column.lookup.calculateCellValue(cellValue))
116+
: cellValue;
122117
}
123118

124-
canDrag(e: RowDraggingStartEvent): Row | Boolean {
119+
canDrag(e: DxDataGridTypes.RowDraggingStartEvent): DxDataGridTypes.Row | Boolean {
125120
if (this.updateInProgress) return false;
126121
const visibleRows = e.component.getVisibleRows();
127-
return visibleRows.some((r: Row) => r.isSelected && r.rowIndex === e.fromIndex);
122+
return visibleRows.some((r: DxDataGridTypes.Row) => r.isSelected && r.rowIndex === e.fromIndex);
128123
}
129124

130125
originalOrder(a: KeyValue<number, string>, b: KeyValue<number, string>): number {

0 commit comments

Comments
 (0)