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
6 changes: 3 additions & 3 deletions .github/workflows/visual-tests-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,9 @@ jobs:
working-directory: apps/demos
run: pnpm run ts-check-vue

# - name: Run check TS for Angular
# working-directory: apps/demos
# run: pnpm run ts-check-ng
- name: Run check TS for Angular
working-directory: apps/demos
run: pnpm run ts-check-ng

- name: Demos - Check React TS
id: ts_react
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Appointment {
export interface Appointment {
text: string;

startDate: Date;
Expand All @@ -14,7 +14,7 @@ export class Appointment {
priorityId?: number[];
}

export class Resource {
export interface Resource {
text: string;

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

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

text: string;
Expand All @@ -18,15 +18,15 @@ export class Appointment {
recurrenceRule?: string;
}

export class Assignee {
export interface Assignee {
text: string;

id: number;

color: string;
}

export class Priority {
export interface Priority {
text: string;

id: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
} from '@angular/core';
import { DxSchedulerModule, DxRadioGroupModule } from 'devextreme-angular';
import type { DxRadioGroupTypes } from 'devextreme-angular/ui/radio-group';
import type { DxSchedulerTypes } from 'devextreme-angular/ui/scheduler';
import { Service } from './app.service';

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

readonly allDayPanelMode = signal('allDay');
readonly allDayPanelMode = signal<DxSchedulerTypes.AllDayPanelMode>('allDay');

readonly allDayPanelModes = ['all', 'allDay', 'hidden'];
readonly allDayPanelModes: DxSchedulerTypes.AllDayPanelMode[] = ['all', 'allDay', 'hidden'];

onChangeAllDayPanelMode(e: DxRadioGroupTypes.ValueChangedEvent) {
this.allDayPanelMode.set(e.value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Appointment {
export interface Appointment {
text: string;

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

export class Appointment {
export interface Appointment {
text: string;

roomId: number;
Expand All @@ -10,7 +10,7 @@ export class Appointment {
endDate: Date;
}

export class Resource {
export interface Resource {
text: string;

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

export class Appointment {
export interface Appointment {
text: string;

startDate: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class AppComponent {
};

readonly onAppointmentFormOpening = (e: DxSchedulerTypes.AppointmentFormOpeningEvent) => {
const startDate = e.appointmentData.startDate as Date;
const startDate = e.appointmentData?.startDate as Date;
if (!this.isValidAppointmentDate(startDate)) {
e.cancel = true;
this.notifyDisableDate();
Expand Down Expand Up @@ -147,10 +147,13 @@ export class AppComponent {
};

private readonly isValidAppointment = (component: DxSchedulerComponent['instance'], appointmentData: DxSchedulerTypes.Appointment) => {
const startDate = new Date(appointmentData.startDate);
const endDate = new Date(appointmentData.endDate);
const cellDuration = component.option('cellDuration');
return this.isValidAppointmentInterval(startDate, endDate, cellDuration);
const { startDate, endDate } = appointmentData;
if (!startDate || !endDate) {
return true;
Comment on lines +151 to +152
}

const cellDuration = component.option('cellDuration') ?? 30;
return this.isValidAppointmentInterval(new Date(startDate), new Date(endDate), cellDuration);
};

private readonly isValidAppointmentInterval = (startDate: Date, endDate: Date, cellDuration: number) => {
Expand All @@ -177,14 +180,11 @@ export class AppComponent {

private readonly applyDisableDatesToDateEditors = (form: DxFormComponent['instance']) => {
const holidays = this.dataService.getHolidays();
const startDateEditor = form.getEditor('startDate');
startDateEditor.option('disabledDates', holidays);

const endDateEditor = form.getEditor('endDate');
endDateEditor.option('disabledDates', holidays);
form.getEditor('startDate')?.option('disabledDates', holidays);
form.getEditor('endDate')?.option('disabledDates', holidays);
};

private setComponentAria(element): void {
private setComponentAria(element: ReturnType<DxSchedulerComponent['instance']['$element']> | undefined): void {
const prevAria = element?.attr('aria-label') || '';
const description = this.ariaDescription();
const nextAria = `${prevAria}${description ? ` ${description}` : ''}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Data {
export interface Data {
text: string;

startDate: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from 'devextreme-angular/ui/scheduler';
import { DxContextMenuModule, type DxContextMenuTypes } from 'devextreme-angular/ui/context-menu';

import { Service, type Resource, type ContextMenuItem } from './app.service';
import { Service, type ContextMenuItem } from './app.service';

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand Down Expand Up @@ -44,7 +44,7 @@ export class AppComponent {
readonly contextMenuItems = signal<ContextMenuItem[]>([]);

onContextMenuItemClick(e: DxContextMenuTypes.ItemClickEvent<ContextMenuItem>) {
e.itemData.onItemClick(e);
e.itemData?.onItemClick?.(e);
}

onAppointmentContextMenu(e: DxSchedulerTypes.AppointmentContextMenuEvent) {
Expand Down Expand Up @@ -82,7 +82,7 @@ export class AppComponent {
beginGroup: true,
onItemClick: () => scheduler.updateAppointment(appointment, {
...appointment,
startDate: targetedAppointment.startDate,
startDate: targetedAppointment?.startDate,
recurrenceRule: 'FREQ=WEEKLY',
}),
},
Expand All @@ -93,9 +93,9 @@ export class AppComponent {
},
...this.resourcesData.map((item) => ({
...item,
onItemClick: ({ itemData }: DxContextMenuTypes.ItemClickEvent<Resource>) => scheduler.updateAppointment(appointment, {
onItemClick: () => scheduler.updateAppointment(appointment, {
...appointment,
roomId: [itemData.id],
roomId: [item.id],
}),
})),
];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, enableProdMode, inject } from '@angular/core';
import { DxSchedulerModule } from 'devextreme-angular';
import type { DxSchedulerTypes } from 'devextreme-angular/ui/scheduler';
import { Service } from './app.service';

if (!/localhost/.test(document.location.host)) {
Expand All @@ -24,7 +25,7 @@ export class AppComponent {

readonly prioritiesData = this.service.getPriorities();

onSelectionEnd(e) {
onSelectionEnd(e: DxSchedulerTypes.SelectionEndEvent) {
const cells = e.selectedCellData;
if (cells.length <= 1) {
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Appointment {
export interface Appointment {
text: string;

priorityId: number;
Expand All @@ -10,7 +10,7 @@ export class Appointment {
endDate: Date;
}

export class Priority {
export interface Priority {
text: string;

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

export class Appointment {
export interface Appointment {
startDate: Date;

endDate: Date;
Expand All @@ -10,7 +10,7 @@ export class Appointment {
recurrenceRule?: string;
}

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

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

export class Appointment {
export interface Appointment {
text: string;

startDate: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ export class AppComponent {

readonly currentDate = new Date(2021, 3, 26);

onAppointmentRemove = (e: DxSchedulerTypes.AppointmentDraggingRemoveEvent) => {
onAppointmentRemove = (e: Pick<DxSchedulerTypes.AppointmentDraggingRemoveEvent, 'itemData'>) => {
if (this.appointments().includes(e.itemData)) {
this.appointments.update((items) => items.filter((item) => item !== e.itemData));
this.tasks.update((items) => [...items, e.itemData]);
}
};

onAppointmentAdd = (e: DxSchedulerTypes.AppointmentDraggingAddEvent) => {
onAppointmentAdd = (e: Pick<DxSchedulerTypes.AppointmentDraggingAddEvent, 'itemData' | 'fromData'>) => {
if (this.tasks().includes(e.fromData)) {
this.tasks.update((items) => items.filter((item) => item !== e.fromData));
this.appointments.update((items) => [...items, e.itemData]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Appointment {
export interface Appointment {
text: string;

startDate: Date;
Expand All @@ -10,7 +10,7 @@ export class Appointment {
allDay?: boolean;
}

export class Task {
export interface Task {
text: string;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class AppComponent {

readonly currentDate = new Date(2021, 3, 29);

private showToast(event: string, value: string, type: string) {
private showToast(event: string, value: string | undefined, type: string) {
notify(`${event} "${value}" task`, type, 800);
}

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

export class Appointment {
export interface Appointment {
text: string;

startDate: Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class AppComponent {

readonly currentDate = new Date(2017, 4, 25);

private getData(requestOptions: Record<string, unknown>) {
private getData(params: Record<string, boolean>) {
const PUBLIC_KEY = 'AIzaSyBnNAISIUKe6xdhq1_rjor2rxoI3UlMY7k';
const CALENDAR_ID = 'f7jnetm22dsjc3npc2lu3buvu4@group.calendar.google.com';
const dataUrl = [
Expand All @@ -38,8 +38,8 @@ export class AppComponent {
PUBLIC_KEY,
].join('');

return lastValueFrom(this.http.get(dataUrl, requestOptions))
.then(({ items }: Record<string, unknown>) => items);
return lastValueFrom(this.http.get<{ items: unknown[] }>(dataUrl, { params }))
.then(({ items }) => items);
}
}

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

export class Appointment {
export interface Appointment {
text: string;

priorityId: number;
Expand All @@ -12,7 +12,7 @@ export class Appointment {
recurrenceRule?: string;
}

export class Priority {
export interface Priority {
text: string;

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

export class Appointment {
export interface Appointment {
text: string;

priorityId: number;
Expand All @@ -10,7 +10,7 @@ export class Appointment {
endDate: Date;
}

export class Priority {
export interface Priority {
text: string;

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

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

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

export class Data {
export interface Data {
text: string;

priorityId: number;
Expand All @@ -14,15 +14,15 @@ export class Data {
recurrenceRule?: string;
}

export class PriorityData {
export interface PriorityData {
text: string;

id: number;

color: string;
}

export class TypeData {
export interface TypeData {
text: string;

id: number;
Expand Down
Loading
Loading