Skip to content

Commit 02b7c6c

Browse files
Fix lint errors
1 parent 7aa6ee8 commit 02b7c6c

File tree

4 files changed

+35
-30
lines changed

4 files changed

+35
-30
lines changed

Angular/src/app/app.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ export class AppComponent {
4444
}
4545

4646
onEditingStart(e: DxDataGridTypes.EditingStartEvent): void {
47-
this.subjects = [...e.data.Subjects || []];
47+
this.subjects = [...e.data.Subjects ?? []];
4848
}
4949

5050
onEditorPreparing(e: DxDataGridTypes.EditorPreparingEvent): void {
51-
this.canBeSaved = e.row?.isNewRow || false;
51+
this.canBeSaved = e.row?.isNewRow ?? false;
5252
this.key = e.row?.key;
5353
}
5454

React/src/components/Home.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, {
44
import DataGrid, {
55
Column, Editing, Popup, Form, ToolbarItem, ValidationRule,
66
type DataGridRef,
7-
type DataGridTypes
7+
type DataGridTypes,
88
} from 'devextreme-react/data-grid';
99
import Button from 'devextreme-react/button';
1010
import { getStudentRows, getStudents } from '../sevices/employee';
@@ -56,7 +56,7 @@ export function HomeComponent(): JSX.Element {
5656
setSaveDisabled(copy.length === 0 && !e.data?.ID);
5757
}, []);
5858

59-
const onInitNewRow = useCallback((_e: DataGridTypes.InitNewRowEvent) => {
59+
const onInitNewRow = useCallback(() => {
6060
setEditingKey(null);
6161
editingSubjectsRef.current = [];
6262
setSaveDisabled(true);
@@ -74,7 +74,7 @@ export function HomeComponent(): JSX.Element {
7474
gridRef,
7575
}), [setSubjectsRefCallback, saveDisabled, setSaveDisabled]);
7676

77-
const onSaved = useCallback((_e: DataGridTypes.SavedEvent) => {
77+
const onSaved = useCallback(() => {
7878
const gridWidget = gridRef.current?.instance?.();
7979
const dsItems = gridWidget?.option('dataSource');
8080
if (Array.isArray(dsItems)) {
@@ -172,7 +172,7 @@ function SubjectsEditCell(): JSX.Element | null {
172172
setSaveDisabled(shouldDisable);
173173
}, [setSaveDisabled, isEditing]);
174174

175-
const onEditingStart = useCallback((_e: DataGridTypes.EditingStartEvent) => {
175+
const onEditingStart = useCallback(() => {
176176
setIsEditing(true);
177177
setSaveDisabled(true);
178178
}, [setSaveDisabled]);

React/src/utils.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@ interface StateShape {
88
isValid?: boolean;
99
}
1010

11-
type Action =
11+
interface RowData {
12+
data: {
13+
[key: string]: any;
14+
Name?: string;
15+
Subjects?: any[];
16+
};
17+
type?: 'insert' | 'update' | 'remove';
18+
isNewRow?: boolean;
19+
}
20+
21+
type Action =
1222
| { type: 'Saving'; payload: { data?: any; key?: string } }
1323
| { type: 'Set_Changes'; payload: { changes: any[]; isValid: boolean } }
1424
| { type: 'Set_Key'; payload: string | number | null }
1525
| { type: 'Set_Valid'; payload: boolean };
1626

1727
function reducer(state: StateShape, action: Action): StateShape {
1828
switch (action.type) {
19-
case 'Saving':
29+
case 'Saving': {
2030
if (!action.payload.data) action.payload.data = {};
2131

2232
const newData = applyChanges(state.data, [action.payload.data], { keyExpr: action.payload.key });
@@ -28,6 +38,7 @@ function reducer(state: StateShape, action: Action): StateShape {
2838
changes: [],
2939
editRowKey: null,
3040
};
41+
}
3142
case 'Set_Changes':
3243
return {
3344
...state,
@@ -49,16 +60,6 @@ function reducer(state: StateShape, action: Action): StateShape {
4960
}
5061
}
5162

52-
interface RowData {
53-
type?: 'insert' | 'update' | 'remove';
54-
isNewRow?: boolean;
55-
data: {
56-
Name?: string;
57-
Subjects?: any[];
58-
[key: string]: any;
59-
};
60-
}
61-
6263
function checkIsValid(row: RowData): boolean {
6364
let result = true;
6465
if (row.type === 'insert' || row.isNewRow === true) {
@@ -70,7 +71,4 @@ function checkIsValid(row: RowData): boolean {
7071
return result;
7172
}
7273

73-
export {
74-
reducer,
75-
checkIsValid,
76-
};
74+
export { reducer, checkIsValid };

Vue/src/App.vue

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ import SubjectsEditorComponent from './components/SubjectsEditorComponent.vue';
100100
const dataSource = ref<StudentSubject[]>(studentSubjects);
101101
const studentsData = ref<Student[]>(students);
102102
const currentSubjects = ref<Subject[]>([]);
103-
const popupInstance = ref<any>(null); // DevExtreme popup component instance - keeping as any due to complex DX component typing
103+
// DevExtreme popup component instance - keeping as any due to complex DX component typing
104+
const popupInstance = ref<any>(null);
104105
const canBeSaved = ref<boolean>(false);
105106
const editingKey = ref<string | number | null>(null);
106-
const mainGrid = ref<any>(null); // DevExtreme DataGrid component instance - keeping as any due to complex DX component typing
107+
// DevExtreme DataGrid component instance - keeping as any due to complex DX component typing
108+
const mainGrid = ref<any>(null);
107109
108110
const saveButtonOptions = reactive({
109111
text: 'Save',
@@ -117,23 +119,26 @@ const cancelButtonOptions = reactive({
117119
onClick: () => cancelMainGrid()
118120
});
119121
120-
const subjectsCellTemplate = (container: HTMLElement, options: { value?: Subject[]; target?: string }) => {
122+
const subjectsCellTemplate = (
123+
container: HTMLElement,
124+
options: { value?: Subject[]; target?: string }
125+
) => {
121126
if (options.value && options.value.length > 0) {
122127
const text = options.value.map((subject: Subject) => subject.Name).join(', ');
123128
container.textContent = text;
124129
}
125130
};
126131
127132
const onEditingStart = (e: DxDataGridTypes.EditingStartEvent) => {
128-
currentSubjects.value = [...(e.data.Subjects || [])];
133+
currentSubjects.value = [...(e.data.Subjects ?? [])];
129134
};
130135
131136
const onEditorPreparing = (e: DxDataGridTypes.EditorPreparingEvent) => {
132-
canBeSaved.value = e.row?.isNewRow || false;
137+
canBeSaved.value = e.row?.isNewRow ?? false;
133138
editingKey.value = e.row?.key;
134139
};
135140
136-
const onInitNewRow = (_e: DxDataGridTypes.InitNewRowEvent) => {
141+
const onInitNewRow = () => {
137142
currentSubjects.value = [];
138143
};
139144
@@ -149,15 +154,17 @@ const onSubjectsChange = (subjects: Subject[]) => {
149154
currentSubjects.value = subjects;
150155
};
151156
152-
const onNestedEditingStart = (_e: DxDataGridTypes.EditingStartEvent) => {
157+
const onNestedEditingStart = () => {
153158
updateSaveButtonState(true);
154159
};
155160
156161
const onNestedRowValidating = (e: { isValid: boolean }) => {
157162
updateSaveButtonState(!e.isValid);
158163
};
159164
160-
const onNestedSaved = (e: { component: { getDataSource: () => { items: () => Subject[] } } }) => {
165+
const onNestedSaved = (
166+
e: { component: { getDataSource: () => { items: () => Subject[] } } }
167+
) => {
161168
currentSubjects.value = e.component.getDataSource().items();
162169
const hasSubjects = currentSubjects.value.length > 0;
163170
updateSaveButtonState(!hasSubjects);

0 commit comments

Comments
 (0)