Skip to content

Commit f1628ca

Browse files
Fix TS in Vue demos. Localization, Diagram, Gantt, File Manager (#30912)
1 parent b4e8097 commit f1628ca

File tree

20 files changed

+90
-65
lines changed

20 files changed

+90
-65
lines changed

apps/demos/Demos/Diagram/AdvancedDataBinding/Vue/App.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,32 @@ const orgLinksDataSource = new ArrayStore({
5050
const linkStyleExpr = () => ({ stroke: '#444444' });
5151
const linkFromLineEndExpr = () => 'none';
5252
const linkToLineEndExpr = () => 'none';
53-
const itemTextStyleExpr = (obj) => (obj.level === 'senior'
53+
const itemTextStyleExpr = (obj: any) => (obj.level === 'senior'
5454
? { 'font-weight': 'bold', 'text-decoration': 'underline' }
5555
: {}
5656
);
57-
const itemStyleExpr = ({ type }) => ({
57+
const itemStyleExpr = ({ type }: { type: string }) => ({
5858
stroke: '#444444',
5959
...(type === 'group' ? { fill: '#f3f3f3' } : {}),
6060
});
6161
62-
function itemTypeExpr(obj, value) {
62+
function itemTypeExpr(obj: any, value: any) {
6363
if (value) {
6464
obj.type = (value === 'rectangle') ? undefined : 'group';
6565
} else {
6666
return obj.type === 'group' ? 'ellipse' : 'rectangle';
6767
}
6868
return null;
6969
}
70-
function itemWidthExpr(obj, value) {
70+
function itemWidthExpr(obj: any, value: any) {
7171
if (value) {
7272
obj.width = value;
7373
} else {
7474
return obj.width || (obj.type === 'group' && 1.5) || 1;
7575
}
7676
return null;
7777
}
78-
function itemHeightExpr(obj, value) {
78+
function itemHeightExpr(obj: any, value: any) {
7979
if (value) {
8080
obj.height = value;
8181
} else {

apps/demos/Demos/Diagram/CustomShapesWithTemplates/Vue/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ const dataSource = new ArrayStore({
6767
});
6868
const currentEmployee = ref({} as Record<string, any>);
6969
const popupVisible = ref(false);
70-
const itemTypeExpr = ({ ID }) => `employee${ID}`;
70+
const itemTypeExpr = ({ ID }: any) => `employee${ID}`;
7171
72-
function showInfo(employee) {
72+
function showInfo(employee: any) {
7373
currentEmployee.value = employee;
7474
popupVisible.value = true;
7575
}

apps/demos/Demos/Diagram/CustomShapesWithTemplatesWithEditing/Vue/App.vue

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,20 +163,21 @@ import {
163163
DxGroup,
164164
DxTab,
165165
DxToolbox,
166+
type DxDiagramTypes,
166167
} from 'devextreme-vue/diagram';
167168
import { DxPopup } from 'devextreme-vue/popup';
168169
import DxTextBox from 'devextreme-vue/text-box';
169170
import DxButton from 'devextreme-vue/button';
170171
import { ArrayStore } from 'devextreme-vue/common/data';
171172
import CustomShapeTemplate from './CustomShapeTemplate.vue';
172173
import CustomShapeToolboxTemplate from './CustomShapeToolboxTemplate.vue';
173-
import service from './data.ts';
174+
import service, { type Employee } from './data.ts';
174175
175176
let generatedID = 100;
176177
const dataSource = new ArrayStore({
177178
key: 'ID',
178179
data: service.getEmployees(),
179-
onInserting(values) {
180+
onInserting(values: Employee) {
180181
values.ID = values.ID || (generatedID += 1);
181182
values.Full_Name = values.Full_Name || "Employee's Name";
182183
values.Title = values.Title || "Employee's Title";
@@ -186,14 +187,14 @@ const currentEmployee = ref({} as Record<string, any>);
186187
const popupVisible = ref(false);
187188
188189
const itemTypeExpr = () => 'employee';
189-
function itemCustomDataExpr(obj, value) {
190+
function itemCustomDataExpr(obj: any, value: any) {
190191
if (value === undefined) {
191192
return { ...obj };
192193
}
193194
Object.assign(obj, value);
194195
return null;
195196
}
196-
function onRequestLayoutUpdate(e) {
197+
function onRequestLayoutUpdate(e: DxDiagramTypes.RequestLayoutUpdateEvent) {
197198
for (let i = 0; i < e.changes.length; i += 1) {
198199
if (e.changes[i].type === 'remove') {
199200
e.allowed = true;
@@ -202,21 +203,13 @@ function onRequestLayoutUpdate(e) {
202203
}
203204
}
204205
}
205-
function editEmployee(employee) {
206+
function editEmployee(employee: Employee) {
206207
currentEmployee.value = {
207-
Full_Name: '',
208-
Prefix: '',
209-
Title: '',
210-
City: '',
211-
State: '',
212-
Email: '',
213-
Skype: '',
214-
Mobile_Phone: '',
215208
...employee,
216209
};
217210
popupVisible.value = true;
218211
}
219-
function deleteEmployee(employee) {
212+
function deleteEmployee(employee: Employee) {
220213
dataSource.push([{ type: 'remove', key: employee.ID }]);
221214
}
222215
function updateEmployee() {

apps/demos/Demos/Diagram/CustomShapesWithTemplatesWithEditing/Vue/data.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,19 @@
1-
const employees = [{
1+
export interface Employee {
2+
ID: number,
3+
Head_ID: number,
4+
Full_Name: string,
5+
Prefix: string,
6+
Title: string,
7+
City: string,
8+
State: string,
9+
Email: string,
10+
Skype: string,
11+
Mobile_Phone: string,
12+
Birth_Date: string,
13+
Hire_Date: string,
14+
}
15+
16+
const employees: Employee[] = [{
217
ID: 1,
318
Head_ID: 0,
419
Full_Name: 'John Heart',

apps/demos/Demos/Diagram/ItemSelection/Vue/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ function onContentReady(e: DxDiagramTypes.ContentReadyEvent) {
5353
diagram.focus();
5454
}
5555
}
56-
function onSelectionChanged({ items }) {
56+
function onSelectionChanged({ items }: DxDiagramTypes.SelectionChangedEvent) {
5757
selectedItemNames.value = 'Nobody has been selected';
5858
const filteredItems = items
5959
.filter((item) => item.itemType === 'shape')
60-
.map((item) => item.text);
60+
.map(({text}: Record<string, any>) => text);
6161
if (filteredItems.length > 0) {
6262
selectedItemNames.value = filteredItems.join(', ');
6363
}

apps/demos/Demos/Diagram/OperationRestrictions/Vue/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ const orgItemsDataSource = new ArrayStore({
7676
});
7777
const shapes = ['team', 'employee'] as unknown as DxDiagramTypes.ShapeType[];
7878
79-
const itemStyleExpr = ({ Type }) => ({
79+
const itemStyleExpr = ({ Type }: Record<string, string>) => ({
8080
fill: {
8181
root: '#ffcfc3',
8282
team: '#b7e3fe',
8383
}[Type] || '#bbefcb',
8484
}
8585
);
86-
function showToast(text) {
86+
function showToast(text: string) {
8787
notify({
8888
position: {
8989
at: 'top', my: 'top', of: '#diagram', offset: '0 4',
@@ -93,7 +93,7 @@ function showToast(text) {
9393
delayTime: 2000,
9494
});
9595
}
96-
function onRequestLayoutUpdate(e) {
96+
function onRequestLayoutUpdate(e: DxDiagramTypes.RequestLayoutUpdateEvent) {
9797
for (let i = 0; i < e.changes.length; i += 1) {
9898
if (e.changes[i].type === 'remove') {
9999
e.allowed = true;
@@ -103,7 +103,7 @@ function onRequestLayoutUpdate(e) {
103103
}
104104
}
105105
}
106-
function onRequestEditOperation(e) {
106+
function onRequestEditOperation(e: Record<string, any>) {
107107
let i;
108108
109109
if (e.operation === 'addShape') {

apps/demos/Demos/Diagram/UICustomization/Vue/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ import {
113113
DxMainToolbar,
114114
DxCommand,
115115
DxToolbox,
116+
type DxDiagramTypes,
116117
} from 'devextreme-vue/diagram';
117118
import { confirm } from 'devextreme/ui/dialog';
118119
import 'whatwg-fetch';
@@ -131,7 +132,7 @@ watch(diagram,
131132
});
132133
});
133134
134-
function onCustomCommand(e) {
135+
function onCustomCommand(e: DxDiagramTypes.CustomCommandEvent) {
135136
if (e.name === 'clear') {
136137
const result = confirm('Are you sure you want to clear the diagram? This action cannot be undone.', 'Warning');
137138
result.then(

apps/demos/Demos/FileManager/BindingToEF/Vue/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,5 @@ import RemoteFileSystemProvider from 'devextreme/file_management/remote_provider
4444
const remoteProvider = new RemoteFileSystemProvider({
4545
endpointUrl: 'https://js.devexpress.com/Demos/NetCore/api/file-manager-db',
4646
});
47-
const allowedFileExtensions = [];
47+
const allowedFileExtensions: string[] = [];
4848
</script>

apps/demos/Demos/FileManager/CustomThumbnails/Vue/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
<script setup lang="ts">
2121
import { DxFileManager, DxPermissions, DxItemView } from 'devextreme-vue/file-manager';
22+
import FileSystemItem from "devextreme/file_management/file_system_item";
2223
import { fileItems } from './data.ts';
2324
24-
function customizeIcon(fileSystemItem) {
25+
function customizeIcon(fileSystemItem: FileSystemItem) {
2526
if (fileSystemItem.isDirectory) {
2627
return '../../../../images/thumbnails/folder.svg';
2728
}

apps/demos/Demos/FileManager/Overview/Vue/App.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
<script setup lang="ts">
3636
import { ref } from 'vue';
37-
import { DxFileManager, DxPermissions } from 'devextreme-vue/file-manager';
37+
import { DxFileManager, DxPermissions, type DxFileManagerTypes } from 'devextreme-vue/file-manager';
3838
import { DxPopup } from 'devextreme-vue/popup';
3939
import RemoteFileSystemProvider from 'devextreme/file_management/remote_provider';
4040
@@ -44,7 +44,7 @@ const imageItemToDisplay = ref({} as Record<string, any>);
4444
const remoteProvider = new RemoteFileSystemProvider({
4545
endpointUrl: 'https://js.devexpress.com/Demos/NetCore/api/file-manager-file-system-images',
4646
});
47-
function displayImagePopup(e) {
47+
function displayImagePopup(e: DxFileManagerTypes.SelectedFileOpenedEvent) {
4848
imageItemToDisplay.value = {
4949
name: e.file.name,
5050
url: e.file.dataItem.url,

0 commit comments

Comments
 (0)