From 916f0f61f2ae766a6880022d2a5290425da88a39 Mon Sep 17 00:00:00 2001 From: bnitsch Date: Wed, 26 Jun 2024 10:29:22 +0200 Subject: [PATCH] #470: Add ESLint "explicit-function-return-type". * To better know what value is returned by a function, without looking into the function body logic. --- .eslintrc.json | 1 + src/components/IntegrationList.vue | 34 ++++++------ src/components/InterventionsList.vue | 55 +++++++++++++------ src/components/ObservationList.vue | 38 +++++++------ src/components/ParticipantList.vue | 24 ++++---- src/components/ParticipationDataList.vue | 4 +- src/components/StudyCollaboratorList.vue | 31 ++++++----- src/components/StudyGroupList.vue | 7 ++- src/components/StudyList.vue | 43 +++++++++------ src/components/TimelineList.vue | 32 ++++++----- .../dialog/ChangeStudyStatusDialog.vue | 4 +- src/components/dialog/CopyTokenDialog.vue | 4 +- .../dialog/DeleteMoreTableRowDialog.vue | 4 +- .../dialog/DeleteParticipantDialog.vue | 4 +- src/components/dialog/DeleteStudyDialog.vue | 4 +- .../dialog/DistributeParticipantsDialog.vue | 4 +- src/components/dialog/InfoDialog.vue | 2 +- src/components/dialog/IntegrationDialog.vue | 6 +- src/components/dialog/InterventionDialog.vue | 34 ++++++------ src/components/dialog/ObservationDialog.vue | 19 +++---- .../dialog/StudyCollaboratorDialog.vue | 4 +- src/components/dialog/StudyDialog.vue | 6 +- .../dialog/shared/ActionProperty.vue | 2 +- .../dialog/shared/StringListPropertyInput.vue | 2 +- .../forms/CronSchedulerConfiguration.vue | 6 +- .../InterventionTriggerConditionTable.vue | 24 ++++---- .../forms/InterventionTriggerConditions.vue | 22 ++++---- src/components/forms/Overview-EditDetails.vue | 8 +-- src/components/forms/StudyStatusChange.vue | 4 +- src/components/shared/AlertMsg.vue | 2 +- src/components/shared/Header.vue | 4 +- src/components/shared/MoreTabNav.vue | 8 +-- src/components/shared/MoreTable.vue | 37 ++++++++----- src/components/shared/RelativeScheduler.vue | 8 +-- src/components/shared/Scheduler.vue | 24 ++++---- .../AbsoluteSchedulerRepetition.vue | 10 ++-- .../subComponents/CronScheduleInfo.vue | 4 +- .../subComponents/DatapointList.vue | 8 +-- .../subComponents/SchedulerInfoBlock.vue | 6 +- src/composable/useErrorHandling.ts | 14 ++++- src/composable/useLoader.ts | 26 ++++++--- src/models/ComponentModels.ts | 13 +++++ src/router/index.ts | 2 +- src/service/AuthService.ts | 2 +- src/stores/studyGroupStore.ts | 12 ++-- src/stores/studyStore.ts | 10 ++-- src/types/vue-cal/index.d.ts | 2 +- src/utils/dateUtils.ts | 2 +- src/views/Dashboard.vue | 2 +- src/views/Participants.vue | 2 +- src/views/StudyOverview.vue | 8 +-- 51 files changed, 360 insertions(+), 278 deletions(-) create mode 100644 src/models/ComponentModels.ts diff --git a/.eslintrc.json b/.eslintrc.json index 55b09517..de3563d9 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -22,6 +22,7 @@ "@typescript-eslint/no-explicit-any": "off", "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-non-null-assertion": "off", + "@typescript-eslint/explicit-function-return-type": "error", "vue/no-mutating-props": "off", "vue/attribute-hyphenation": [ "error", diff --git a/src/components/IntegrationList.vue b/src/components/IntegrationList.vue index 912ebc29..5a6f4ccd 100644 --- a/src/components/IntegrationList.vue +++ b/src/components/IntegrationList.vue @@ -137,7 +137,7 @@ Licensed under the Elastic License 2.0. */ }); } - async function getFactories() { + async function getFactories(): Promise { return componentsApi .listComponents('observation') .then((response: any) => response.data); @@ -195,20 +195,24 @@ Licensed under the Elastic License 2.0. */ }, ]; - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { const row = action.row as MoreIntegrationTableMap; switch (action.id) { case 'delete': - return deleteIntegration(row); + deleteIntegration(row); + break; case 'clone': - return createIntegration({ + createIntegration({ observationId: row.observationId, tokenLabel: row.tokenLabel, } as MoreIntegrationLink); + break; } } - async function updateIntegration(integration: MoreIntegrationTableMap) { + async function updateIntegration( + integration: MoreIntegrationTableMap, + ): Promise { await observationsApi .updateTokenLabel( props.studyId, @@ -230,7 +234,7 @@ Licensed under the Elastic License 2.0. */ ); } - async function openIntegrationDialog(headerText: string) { + async function openIntegrationDialog(headerText: string): Promise { dialog.open(IntegrationDialog, { data: { observationList: observationList, @@ -257,7 +261,9 @@ Licensed under the Elastic License 2.0. */ }); } - async function deleteIntegration(integration: MoreIntegrationTableMap) { + async function deleteIntegration( + integration: MoreIntegrationTableMap, + ): Promise { await observationsApi .deleteToken( props.studyId, @@ -273,15 +279,9 @@ Licensed under the Elastic License 2.0. */ }); } - // eslint-disable-next-line @typescript-eslint/no-unused-vars - async function getObservationTokens(studyId: number, observationId: number) { - await observationsApi.getTokens(studyId, observationId).then((request) => { - return request; - }); - } - getObservationTokens(props.studyId, 1); - - async function createIntegration(integrationCreate: MoreIntegrationLink) { + async function createIntegration( + integrationCreate: MoreIntegrationLink, + ): Promise { await observationsApi .createToken(props.studyId, integrationCreate.observationId, { tokenId: 0, @@ -301,7 +301,7 @@ Licensed under the Elastic License 2.0. */ }); } - function openInfoDialog(token: EndpointToken) { + function openInfoDialog(token: EndpointToken): void { dialog.open(CopyTokenDialog, { data: { title: `${token.tokenLabel} (Id: ${token.tokenId})`, diff --git a/src/components/InterventionsList.vue b/src/components/InterventionsList.vue index df25c895..21bb921f 100644 --- a/src/components/InterventionsList.vue +++ b/src/components/InterventionsList.vue @@ -183,7 +183,9 @@ Licensed under the Elastic License 2.0. */ }); } - async function listActions(interventionId?: number) { + async function listActions( + interventionId?: number, + ): Promise { if (interventionId) { return interventionsApi .listActions(props.studyId, interventionId) @@ -192,7 +194,10 @@ Licensed under the Elastic License 2.0. */ return undefined; } } - async function getTrigger(interventionId?: number) { + + async function getTrigger( + interventionId?: number, + ): Promise { if (interventionId) { return interventionsApi .getTrigger(props.studyId, interventionId) @@ -202,25 +207,28 @@ Licensed under the Elastic License 2.0. */ } } - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { const row = action.row as Intervention; switch (action.id) { case 'delete': - return deleteIntervention(row); + deleteIntervention(row); + break; case 'clone': - return openInterventionDialog( + openInterventionDialog( t('intervention.dialog.header.clone'), row, true, ); + break; case 'edit': - return openEditIntervention(row.interventionId); + openEditIntervention(row.interventionId); + break; default: console.error('no handler for action', action); } } - async function changeValue(intervention: Intervention) { + async function changeValue(intervention: Intervention): Promise { await interventionsApi .updateIntervention( props.studyId, @@ -236,7 +244,9 @@ Licensed under the Elastic License 2.0. */ ); } - async function deleteIntervention(requestIntervention: Intervention) { + async function deleteIntervention( + requestIntervention: Intervention, + ): Promise { await interventionsApi .deleteIntervention( props.studyId, @@ -251,7 +261,7 @@ Licensed under the Elastic License 2.0. */ ); } - async function createIntervention(object: any) { + async function createIntervention(object: any): Promise { const interventionId: number | undefined = await addIntervention( object.intervention, ); @@ -266,7 +276,7 @@ Licensed under the Elastic License 2.0. */ } } - async function addIntervention(intervention: Intervention) { + async function addIntervention(intervention: Intervention): Promise { return interventionsApi .addIntervention(props.studyId, intervention) .then((response: AxiosResponse) => response.data.interventionId) @@ -275,7 +285,10 @@ Licensed under the Elastic License 2.0. */ ); } - async function createAction(interventionId: number, action: Action) { + async function createAction( + interventionId: number, + action: Action, + ): Promise { await interventionsApi .createAction(props.studyId, interventionId, action) .then(listInterventions) @@ -288,7 +301,7 @@ Licensed under the Elastic License 2.0. */ interventionId: number, actionId: number, action: Action, - ) { + ): Promise { await interventionsApi .updateAction(props.studyId, interventionId, actionId, action) .catch((e: AxiosError) => @@ -296,7 +309,10 @@ Licensed under the Elastic License 2.0. */ ); } - async function deleteAction(interventionId: number, actionId: number) { + async function deleteAction( + interventionId: number, + actionId: number, + ): Promise { await interventionsApi .deleteAction(props.studyId, interventionId, actionId) .catch((e: AxiosError) => @@ -304,7 +320,10 @@ Licensed under the Elastic License 2.0. */ ); } - async function updateTrigger(interventionId: number, trigger: Trigger) { + async function updateTrigger( + interventionId: number, + trigger: Trigger, + ): Promise { await interventionsApi .updateTrigger(props.studyId, interventionId, trigger) .catch((e: AxiosError) => @@ -312,7 +331,7 @@ Licensed under the Elastic License 2.0. */ ); } - async function updateInterventionData(object: any) { + async function updateInterventionData(object: any): Promise { await updateIntervention(object.intervention); if (object.intervention.interventionId) { @@ -340,7 +359,7 @@ Licensed under the Elastic License 2.0. */ } } - async function updateIntervention(intervention: Intervention) { + async function updateIntervention(intervention: Intervention): Promise { await interventionsApi .updateIntervention( props.studyId, @@ -356,7 +375,7 @@ Licensed under the Elastic License 2.0. */ ); } - function openEditIntervention(interventionId: number | undefined) { + function openEditIntervention(interventionId: number | undefined): void { const intervention = interventionList.value.find( (i) => i.interventionId === interventionId, ); @@ -376,7 +395,7 @@ Licensed under the Elastic License 2.0. */ headerText: string, intervention?: Intervention, clone?: boolean, - ) { + ): void { Promise.all([ listActions(intervention?.interventionId), getTrigger(intervention?.interventionId), diff --git a/src/components/ObservationList.vue b/src/components/ObservationList.vue index c0f9aa4b..e92b9f0d 100644 --- a/src/components/ObservationList.vue +++ b/src/components/ObservationList.vue @@ -75,7 +75,7 @@ Licensed under the Elastic License 2.0. */ value: null, } as MoreTableChoice); - async function getFactories() { + async function getFactories(): Promise { return componentsApi .listComponents('observation') .then((response: any) => response.data); @@ -85,7 +85,7 @@ Licensed under the Elastic License 2.0. */ const observationTypes: any[] = factories.map((cf: ComponentFactory) => ({ label: cf.title ? t(cf.title) : '', value: cf.componentId, - command: () => { + command: (): void => { openObservationDialog(t('observation.dialog.header.create'), { type: cf.componentId, }); @@ -223,7 +223,7 @@ Licensed under the Elastic License 2.0. */ }, ]; - function getObservationTypeString(observationType: string) { + function getObservationTypeString(observationType: string): string { return t( factories.find((f) => f.componentId === observationType)?.title as string, ); @@ -326,25 +326,24 @@ Licensed under the Elastic License 2.0. */ return ''; } - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { const row = action.row as Observation; switch (action.id) { case 'delete': - return deleteObservation(row); + deleteObservation(row); + break; case 'clone': - return openObservationDialog( - t('observation.dialog.header.clone'), - row, - true, - ); + openObservationDialog(t('observation.dialog.header.clone'), row, true); + break; case 'edit': - return openEditObservation(row.observationId); + openEditObservation(row.observationId); + break; default: console.error('no handler for action', action); } } - async function updateObservation(observation: Observation) { + async function updateObservation(observation: Observation): Promise { await observationsApi .updateObservation( props.studyId, @@ -360,7 +359,9 @@ Licensed under the Elastic License 2.0. */ ); } - async function deleteObservation(requestObservation: Observation) { + async function deleteObservation( + requestObservation: Observation, + ): Promise { await observationsApi .deleteObservation( props.studyId, @@ -375,7 +376,7 @@ Licensed under the Elastic License 2.0. */ ); } - function factoryForType(type?: string) { + function factoryForType(type?: string): ComponentFactory | undefined { return factories.find((f) => f.componentId === type); } @@ -383,7 +384,7 @@ Licensed under the Elastic License 2.0. */ headerText: string, observation?: Observation, clone?: boolean, - ) { + ): void { dialog.open(ObservationDialog, { data: { groupStates: groupStatuses, @@ -421,7 +422,7 @@ Licensed under the Elastic License 2.0. */ }); } - function createObservation(newObservation: Observation) { + function createObservation(newObservation: Observation): void { observationsApi .addObservation(props.studyId, newObservation) .then(listObservations) @@ -430,7 +431,7 @@ Licensed under the Elastic License 2.0. */ ); } - function openEditObservation(observationId: number | undefined) { + function openEditObservation(observationId: number | undefined): void { const observation = observationList.value.find( (observation) => observation.observationId === observationId, ); @@ -445,10 +446,11 @@ Licensed under the Elastic License 2.0. */ openObservationDialog(dialogTitle, observation); } } + listObservations(); const menu = ref(); - function toggleButtonMenu(event: MouseEvent) { + function toggleButtonMenu(event: MouseEvent): void { menu.value.toggle(event); } diff --git a/src/components/ParticipantList.vue b/src/components/ParticipantList.vue index 77a10bc5..a978e18d 100644 --- a/src/components/ParticipantList.vue +++ b/src/components/ParticipantList.vue @@ -35,6 +35,7 @@ Licensed under the Elastic License 2.0. */ import Menu from 'primevue/menu'; import Button from 'primevue/button'; import FileUpload, { FileUploadUploaderEvent } from 'primevue/fileupload'; + import { MenuOptions } from '../models/ComponentModels'; const { participantsApi } = useParticipantsApi(); const { importExportApi } = useImportExportApi(); @@ -160,31 +161,31 @@ Licensed under the Elastic License 2.0. */ }, ]; - const addParticipantOptions: any[] = [ + const addParticipantOptions: MenuOptions[] = [ { label: t('participants.participantsList.labels.add1'), value: 1, - command: () => createParticipant(1), + command: (): void => createParticipant(1), }, { label: t('participants.participantsList.labels.add3'), value: 3, - command: () => createParticipant(3), + command: (): void => createParticipant(3), }, { label: t('participants.participantsList.labels.add10'), value: 10, - command: () => createParticipant(10), + command: (): void => createParticipant(10), }, { label: t('participants.participantsList.labels.add25'), value: 25, - command: () => createParticipant(25), + command: (): void => createParticipant(25), }, { label: t('participants.participantsList.labels.add50'), value: 50, - command: () => createParticipant(50), + command: (): void => createParticipant(50), }, ]; @@ -245,7 +246,7 @@ Licensed under the Elastic License 2.0. */ } // https://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm - function shuffleArray(a: Participant[]) { + function shuffleArray(a: Participant[]): Participant[] { let j, x, i; for (i = a.length - 1; i > 0; i--) { j = Math.floor(Math.random() * (i + 1)); @@ -256,7 +257,10 @@ Licensed under the Elastic License 2.0. */ return a; } - function executeAction(action: MoreTableRowActionResult, withData?: boolean) { + function executeAction( + action: MoreTableRowActionResult, + withData?: boolean, + ): void { switch (action.id) { case 'delete': deleteParticipant(action.row as Participant, !!withData); @@ -266,7 +270,7 @@ Licensed under the Elastic License 2.0. */ } } - function createParticipant(amount: number) { + function createParticipant(amount: number): void { const i = amount || 1; const participants = starWarsNames .random(i) @@ -360,7 +364,7 @@ Licensed under the Elastic License 2.0. */ } const menu = ref(); - function toggleButtonMenu(event: MouseEvent) { + function toggleButtonMenu(event: MouseEvent): void { menu.value.toggle(event); } diff --git a/src/components/ParticipationDataList.vue b/src/components/ParticipationDataList.vue index 61bf133d..aaa48c2f 100644 --- a/src/components/ParticipationDataList.vue +++ b/src/components/ParticipationDataList.vue @@ -46,7 +46,7 @@ Licensed under the Elastic License 2.0. */ let timer: NodeJS.Timeout | number; - function loadData() { + function loadData(): void { timer ??= setInterval(function () { listParticipationData().then(setObservationGroups); }, 10000); @@ -145,7 +145,7 @@ Licensed under the Elastic License 2.0. */ }, ]; - function setObservationGroups(data: ParticipationDataMapping[]) { + function setObservationGroups(data: ParticipationDataMapping[]): void { groupedParticipantData.value = data.reduce(function (prev, curr) { prev[curr.observationId] = prev[curr.observationId] || []; prev[curr.observationId].push(curr); diff --git a/src/components/StudyCollaboratorList.vue b/src/components/StudyCollaboratorList.vue index 65aa948a..f4b1f0d8 100644 --- a/src/components/StudyCollaboratorList.vue +++ b/src/components/StudyCollaboratorList.vue @@ -113,7 +113,7 @@ Licensed under the Elastic License 2.0. */ label: t('global.labels.delete'), icon: 'pi pi-trash', tooltip: t('tooltips.moreTable.deleteCollaborator'), - visible: (data: MoreTableCollaboratorItem) => { + visible: (data: MoreTableCollaboratorItem): boolean => { return data.uid !== userStore.user?.uid && editAccess; }, confirmDeleteDialog: { @@ -170,16 +170,17 @@ Licensed under the Elastic License 2.0. */ return rolesString; } - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { switch (action.id) { case 'delete': - return deleteStudyCollaborator(action.row as MoreTableCollaboratorItem); + deleteStudyCollaborator(action.row as MoreTableCollaboratorItem); + break; default: console.error('no handler for action', action); } } - async function listCollaborators() { + async function listCollaborators(): Promise { await collaboratorsApi .listStudyCollaborators(props.studyId) .then((response: AxiosResponse) => { @@ -196,7 +197,7 @@ Licensed under the Elastic License 2.0. */ ); } - function addStudyCollaborator(collaborator: MoreTableCollaboratorItem) { + function addStudyCollaborator(collaborator: MoreTableCollaboratorItem): void { collaboratorsApi .setStudyCollaboratorRoles( props.studyId, @@ -206,32 +207,32 @@ Licensed under the Elastic License 2.0. */ .then(listCollaborators); } - function getRoleChoices(roles: StudyRole[]) { + function getRoleChoices(roles: StudyRole[]): MoreTableChoice[] { const roleChoices: MoreTableChoice[] = []; roles.forEach((item) => { if (item === StudyRole.Admin) { roleChoices.push({ label: t('study.roles.admin'), value: StudyRole.Admin, - }); + } as MoreTableChoice); } if (item === StudyRole.Operator) { roleChoices.push({ label: t('study.roles.operator'), value: StudyRole.Operator, - }); + } as MoreTableChoice); } if (item === StudyRole.Viewer) { roleChoices.push({ label: t('study.roles.viewer'), value: StudyRole.Viewer, - }); + } as MoreTableChoice); } }); return roleChoices; } - function changeValue(collabListItem: MoreTableCollaboratorItem) { + function changeValue(collabListItem: MoreTableCollaboratorItem): void { const collaborator: Collaborator = { roles: collabListItem.roles.map( (c: MoreTableChoice) => c.value as StudyRole, @@ -257,13 +258,17 @@ Licensed under the Elastic License 2.0. */ } } - function deleteStudyCollaborator(collaborator: MoreTableCollaboratorItem) { + function deleteStudyCollaborator( + collaborator: MoreTableCollaboratorItem, + ): void { collaboratorsApi .clearStudyCollaboratorRoles(props.studyId, collaborator.uid) .then(listCollaborators); } - function openAddCollaboratorDialog(options: MoreTableCollaboratorItemOption) { + function openAddCollaboratorDialog( + options: MoreTableCollaboratorItemOption, + ): void { dialog.open(StudyCollaboratorDialog, { data: { collaborator: { @@ -295,7 +300,7 @@ Licensed under the Elastic License 2.0. */ } const collaboratorList: Ref = ref([]); - async function filterActionHandler(query: string) { + async function filterActionHandler(query: string): Promise { if (query) { collaboratorList.value = await getUsers(query); } diff --git a/src/components/StudyGroupList.vue b/src/components/StudyGroupList.vue index 2d8a69ae..e2bc36ff 100644 --- a/src/components/StudyGroupList.vue +++ b/src/components/StudyGroupList.vue @@ -154,19 +154,20 @@ Licensed under the Elastic License 2.0. */ (props.userRoles.some((r) => editableRoles.includes(r)) && props.studyStatus === StudyStatus.PausedPreview); - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { const row: StudyGroup = action.row ? studyGroupStore.toStudyGroup(action.row as StudyGroup) : action.row; switch (action.id) { case 'delete': - return studyGroupStore.deleteStudyGroup(row); + studyGroupStore.deleteStudyGroup(row); + break; default: console.error('no handler for action', action); } } - function changeValueInPlace(studyGroupMap: MoreStudyGroupTableMap) { + function changeValueInPlace(studyGroupMap: MoreStudyGroupTableMap): void { studyGroupStore.updateStudyGroup( studyGroupStore.toStudyGroup(studyGroupMap), ); diff --git a/src/components/StudyList.vue b/src/components/StudyList.vue index 31a7164c..6139d60f 100644 --- a/src/components/StudyList.vue +++ b/src/components/StudyList.vue @@ -42,11 +42,11 @@ Licensed under the Elastic License 2.0. */ message: '', showMessage: false, }); - function setAlertMessage(message: string) { + function setAlertMessage(message: string): void { alert.message = message; alert.showMessage = true; } - function clearAlertMessage() { + function clearAlertMessage(): void { alert.message = ''; alert.showMessage = false; } @@ -192,38 +192,44 @@ Licensed under the Elastic License 2.0. */ ]; const editableRoles: StudyRole[] = [StudyRole.Admin, StudyRole.Operator]; - function goToStudy(id: string) { + function goToStudy(id: string): void { router.push({ name: t('studyNavigation.tabLink.overview'), params: { studyId: id }, }); } - function executeAction(action: MoreTableRowActionResult) { + function executeAction(action: MoreTableRowActionResult): void { const row = action.row as Study; switch (action.id) { case 'delete': - return studyStore.deleteStudy(row.studyId); + studyStore.deleteStudy(row.studyId); + break; case 'exportConfig': - return onExportStudyConfig(row.studyId as number); + onExportStudyConfig(row.studyId as number); + break; case 'exportData': - return onExportStudyData(row.studyId as number); + onExportStudyData(row.studyId as number); + break; case 'exportCalendar': - return onExportStudyCalendar(row.studyId as number); + onExportStudyCalendar(row.studyId as number); + break; case 'copyId': - return onCopyId(row.studyId, row.title); + onCopyId(row.studyId, row.title); + break; case 'goToStudy': - return goToStudy((row.studyId as number).toString()); + goToStudy((row.studyId as number).toString()); + break; default: console.error('no handler for action', action); } } - function updateStudyInPlace(study: Study) { + function updateStudyInPlace(study: Study): void { studyStore.updateStudyInStudies(study); } - function openCreateDialog() { + function openCreateDialog(): void { dialog.open(StudyDialog, { data: { study: undefined, @@ -248,7 +254,10 @@ Licensed under the Elastic License 2.0. */ }); } - function onCopyId(studyId: number | undefined, title: string | undefined) { + function onCopyId( + studyId: number | undefined, + title: string | undefined, + ): void { if (studyId) { const studyUrl = `${location.host}/studies/${studyId}`; navigator.clipboard.writeText(studyUrl); @@ -256,19 +265,19 @@ Licensed under the Elastic License 2.0. */ } } - function onExportStudyConfig(studyId: number) { + function onExportStudyConfig(studyId: number): void { studyStore.exportStudyConfig(studyId); } - function onExportStudyData(studyId: number) { + function onExportStudyData(studyId: number): void { studyStore.exportStudyData(studyId); } - function onExportStudyCalendar(studyId: number) { + function onExportStudyCalendar(studyId: number): void { studyStore.exportStudyCalendar(studyId); } - function onImportStudy(event: FileUploadUploaderEvent) { + function onImportStudy(event: FileUploadUploaderEvent): void { const file: File = Array.isArray(event.files) ? event.files[0] : event.files; diff --git a/src/components/TimelineList.vue b/src/components/TimelineList.vue index 712159a3..7311d934 100644 --- a/src/components/TimelineList.vue +++ b/src/components/TimelineList.vue @@ -114,7 +114,7 @@ Licensed under the Elastic License 2.0. */ return eventToEventDetailMapper[cId]; } - function setupEventsList(rsData: StudyTimeline) { + function setupEventsList(rsData: StudyTimeline): void { timelineEventsList.value = []; addStudyStartEvent(); @@ -125,7 +125,7 @@ Licensed under the Elastic License 2.0. */ addStudyEndEvent(); } - function addStudyStartEvent() { + function addStudyStartEvent(): void { const studyStartEvent: Event = { start: new Date(studyStartDate as string), end: new Date(studyStartDate as string), @@ -143,7 +143,7 @@ Licensed under the Elastic License 2.0. */ timelineEventsList.value.push(studyStartEvent); } - function addStudyDurationEvent(rsData: StudyTimeline) { + function addStudyDurationEvent(rsData: StudyTimeline): void { if (rsData.studyDuration) { const studyDurationEvent: Event = { start: new Date(rsData.studyDuration.from as string), @@ -161,7 +161,7 @@ Licensed under the Elastic License 2.0. */ } } - function addParticipantJoinedEvent(rsData: StudyTimeline) { + function addParticipantJoinedEvent(rsData: StudyTimeline): void { if (rsData.participantSignup) { const participantJoinedEvent = { start: new Date(rsData.participantSignup as string), @@ -183,7 +183,7 @@ Licensed under the Elastic License 2.0. */ } } - function addObservationEvents(rsData: StudyTimeline) { + function addObservationEvents(rsData: StudyTimeline): void { rsData.observations?.forEach( (observation: ObservationTimelineEvent, idx: number) => { const observationsEvent: Event = { @@ -215,7 +215,7 @@ Licensed under the Elastic License 2.0. */ ); } - function addInterventionEvents(rsData: StudyTimeline) { + function addInterventionEvents(rsData: StudyTimeline): void { rsData.interventions?.forEach( (intervention: InterventionTimelineEvent, idx: number) => { const interventionEvent: Event = { @@ -244,7 +244,7 @@ Licensed under the Elastic License 2.0. */ ); } - function addStudyEndEvent() { + function addStudyEndEvent(): void { const studyEndEvent: Event = { start: new Date(studyEndDate as string), end: new Date(studyEndDate as string), @@ -278,7 +278,7 @@ Licensed under the Elastic License 2.0. */ return translation; } - function onStudyGroupFilterChange(e: DropdownChangeEvent) { + function onStudyGroupFilterChange(e: DropdownChangeEvent): void { const filteredOptions: DropdownOption[] = []; const filteredParticipants: Participant[] = []; @@ -311,12 +311,12 @@ Licensed under the Elastic License 2.0. */ listTimeline(); } - function onParticipantFilterChange(e: DropdownChangeEvent) { + function onParticipantFilterChange(e: DropdownChangeEvent): void { filterStudyGroup.value = getStudyGroupIdByParticipantId(parseInt(e.value)); listTimeline(); } - function onEventClick(vueCalEvent: VueCalEvent, e: MouseEvent) { + function onEventClick(vueCalEvent: VueCalEvent, e: MouseEvent): void { const eventDetail: EventDetail | undefined = getEventDetailByEventCid( vueCalEvent.cId, ); @@ -353,7 +353,7 @@ Licensed under the Elastic License 2.0. */ return foundParticipant?.studyGroupId?.toString(); } - function clearAllFilters() { + function clearAllFilters(): void { filterRelativeStartDate.value = undefined; filterStudyGroup.value = undefined; filterParticipant.value = undefined; @@ -361,7 +361,9 @@ Licensed under the Elastic License 2.0. */ listTimeline(); } - function setupObservationAndInterventionFilterOptions(rsData: StudyTimeline) { + function setupObservationAndInterventionFilterOptions( + rsData: StudyTimeline, + ): void { observationAndInterventionOptions.value = []; const observationOptions: DropdownOption[] = []; const interventionOptions: DropdownOption[] = []; @@ -458,12 +460,12 @@ Licensed under the Elastic License 2.0. */ }); } - async function getFactories() { - const observationTypes = await componentsApi + async function getFactories(): Promise { + const observationTypes: ComponentFactory[] = await componentsApi .listComponents('observation') .then((response: any) => response.data); - const interventionTypes = await componentsApi + const interventionTypes: ComponentFactory[] = await componentsApi .listComponents(ListComponentsComponentTypeEnum.Trigger) .then((response: any) => response.data); diff --git a/src/components/dialog/ChangeStudyStatusDialog.vue b/src/components/dialog/ChangeStudyStatusDialog.vue index aa47328e..983ba7fa 100644 --- a/src/components/dialog/ChangeStudyStatusDialog.vue +++ b/src/components/dialog/ChangeStudyStatusDialog.vue @@ -15,10 +15,10 @@ Licensed under the Elastic License 2.0. */ const study: Study = dialogRef.value.data.study; const changedStatus: StudyStatus = dialogRef.value.data.changedStatus; - function setStudyStatus() { + function setStudyStatus(): void { dialogRef.value.close(changedStatus); } - function closeDialog() { + function closeDialog(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/CopyTokenDialog.vue b/src/components/dialog/CopyTokenDialog.vue index 8ea3c90d..48076c02 100644 --- a/src/components/dialog/CopyTokenDialog.vue +++ b/src/components/dialog/CopyTokenDialog.vue @@ -18,12 +18,12 @@ Licensed under the Elastic License 2.0. */ const { t } = useI18n(); const showMessage: Ref = ref(false); - function copyToken() { + function copyToken(): void { navigator.clipboard.writeText(token); showMessage.value = true; } - function closeDialog() { + function closeDialog(): void { infoDialogRef.value.close(); } diff --git a/src/components/dialog/DeleteMoreTableRowDialog.vue b/src/components/dialog/DeleteMoreTableRowDialog.vue index c3590330..23c0c643 100644 --- a/src/components/dialog/DeleteMoreTableRowDialog.vue +++ b/src/components/dialog/DeleteMoreTableRowDialog.vue @@ -17,11 +17,11 @@ Licensed under the Elastic License 2.0. */ const elInfoTitle: string = dialogRef?.value?.data?.elInfoTitle; const elInfoDesc: string = dialogRef?.value?.data?.elInfoDesc; - function deleteRowEl() { + function deleteRowEl(): void { dialogRef.value.close(row); } - function closeDialog() { + function closeDialog(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/DeleteParticipantDialog.vue b/src/components/dialog/DeleteParticipantDialog.vue index 81368d4a..811e5ddf 100644 --- a/src/components/dialog/DeleteParticipantDialog.vue +++ b/src/components/dialog/DeleteParticipantDialog.vue @@ -15,11 +15,11 @@ Licensed under the Elastic License 2.0. */ const confirmMsg: string = dialogRef?.value?.data?.confirmMsg; const participant: Participant = dialogRef?.value?.data?.participant; - function deleteParticipant(withData: boolean) { + function deleteParticipant(withData: boolean): void { dialogRef.value.close({ participant, withData }); } - function closeDialog() { + function closeDialog(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/DeleteStudyDialog.vue b/src/components/dialog/DeleteStudyDialog.vue index ad73d1e0..59a5edcb 100644 --- a/src/components/dialog/DeleteStudyDialog.vue +++ b/src/components/dialog/DeleteStudyDialog.vue @@ -19,11 +19,11 @@ Licensed under the Elastic License 2.0. */ const confirmMsg: string = infoDialogRef?.value?.data?.confirmMsg; const study: Study = infoDialogRef?.value?.data?.study; - function deleteStudy() { + function deleteStudy(): void { studyStore.deleteStudy(study.studyId); infoDialogRef.value.close(); } - function closeDialog() { + function closeDialog(): void { infoDialogRef.value.close(); } diff --git a/src/components/dialog/DistributeParticipantsDialog.vue b/src/components/dialog/DistributeParticipantsDialog.vue index 0ef82675..ba1052ba 100644 --- a/src/components/dialog/DistributeParticipantsDialog.vue +++ b/src/components/dialog/DistributeParticipantsDialog.vue @@ -18,10 +18,10 @@ Licensed under the Elastic License 2.0. */ const studyGroups: Array = dialogRef.value.data?.studyGroups || []; - function closeDialog() { + function closeDialog(): void { dialogRef.value.close(); } - function distribute() { + function distribute(): void { dialogRef.value.close(true); } diff --git a/src/components/dialog/InfoDialog.vue b/src/components/dialog/InfoDialog.vue index 62dcd362..327b145a 100644 --- a/src/components/dialog/InfoDialog.vue +++ b/src/components/dialog/InfoDialog.vue @@ -10,7 +10,7 @@ Licensed under the Elastic License 2.0. */ const infoDialogRef: any = inject('dialogRef'); const message: number = infoDialogRef?.value?.data?.message; - function closeDialog() { + function closeDialog(): void { infoDialogRef.value.close(); } diff --git a/src/components/dialog/IntegrationDialog.vue b/src/components/dialog/IntegrationDialog.vue index 2531d8ff..1d918d71 100644 --- a/src/components/dialog/IntegrationDialog.vue +++ b/src/components/dialog/IntegrationDialog.vue @@ -45,7 +45,7 @@ Licensed under the Elastic License 2.0. */ const errors: Ref> = ref([]); - function checkErrors() { + function checkErrors(): void { errors.value = []; if (!tokenLabel.value) { errors.value.push({ @@ -65,14 +65,14 @@ Licensed under the Elastic License 2.0. */ return errors.value.find((el) => el.label === label)?.value; } - function save() { + function save(): void { dialogRef.value.close({ observationId: selectedObservation.value, tokenLabel: tokenLabel.value, }); } - function cancel() { + function cancel(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/InterventionDialog.vue b/src/components/dialog/InterventionDialog.vue index cd887b21..82e035f7 100644 --- a/src/components/dialog/InterventionDialog.vue +++ b/src/components/dialog/InterventionDialog.vue @@ -128,7 +128,7 @@ Licensed under the Elastic License 2.0. */ actionFactories.map((cf: ComponentFactory) => ({ label: cf.title ? t(cf.title) : '', value: cf.componentId, - command: () => { + command: (): void => { actionsArray.value.push({ type: cf.componentId, properties: cf.defaultProperties, @@ -142,7 +142,7 @@ Licensed under the Elastic License 2.0. */ componentType: string, props: any, i?: number, - ) { + ): Promise { return new Promise((resolve, reject) => { let parsedProps: any; try { @@ -176,7 +176,7 @@ Licensed under the Elastic License 2.0. */ }); } - function save() { + function save(): void { if (errors.length === 0) { Promise.all( [ @@ -262,31 +262,31 @@ Licensed under the Elastic License 2.0. */ let errors: MoreTableChoice[] = []; - function checkErrors() { + function checkErrors(): void { errors = []; if (!title.value) { errors.push({ label: 'title', value: t('intervention.error.addTitle'), - }); + } as MoreTableChoice); } if (typeof triggerProperties.value === 'undefined') { errors.push({ label: ListComponentsComponentTypeEnum.Trigger, value: t('intervention.error.addTriggerTypeConfig'), - }); + } as MoreTableChoice); } if (!actionsArray.value.length) { errors.push({ label: ListComponentsComponentTypeEnum.Action, value: t('intervention.error.addAction'), - }); + } as MoreTableChoice); } if (propInputError) { errors.push({ label: 'propInputError', value: t('intervention.error.triggerProp'), - }); + } as MoreTableChoice); } } @@ -294,21 +294,23 @@ Licensed under the Elastic License 2.0. */ return errors.find((el) => el.label === label)?.value; } - function cancel() { + function cancel(): void { dialogRef.value.close(); } - function deleteAction(actionId: number, index: number) { + function deleteAction(actionId: number, index: number): void { removeActions.push(actionId); actionsArray.value.splice(index, 1); } - function nameForActionType(actionType?: string) { + function nameForActionType( + actionType?: string, + ): ComponentFactory | undefined { return actionFactories.find( (cf: ComponentFactory) => cf.componentId === actionType, )?.label; } - function setTriggerConfig(tType: string) { + function setTriggerConfig(tType: string): void { const cronValue = triggerProperties.value?.find( (tp) => tp.id === 'cronSchedule', )?.value; @@ -326,21 +328,21 @@ Licensed under the Elastic License 2.0. */ } const actionMenu = ref(); - function actionToggle(event: MouseEvent) { + function actionToggle(event: MouseEvent): void { actionMenu.value.toggle(event); } - function updateActionProps(action: Action, index: number) { + function updateActionProps(action: Action, index: number): void { actionsArray.value[index] = action; } - function updateProperty(item: PropertyEmit) { + function updateProperty(item: PropertyEmit): void { if (triggerProperties.value) { triggerProperties.value[item.index].value = item.value; } } - function propertyError(item: StringEmit) { + function propertyError(item: StringEmit): void { propInputError = item.value; checkErrors(); } diff --git a/src/components/dialog/ObservationDialog.vue b/src/components/dialog/ObservationDialog.vue index 986b7d58..8d740c33 100644 --- a/src/components/dialog/ObservationDialog.vue +++ b/src/components/dialog/ObservationDialog.vue @@ -47,7 +47,6 @@ Licensed under the Elastic License 2.0. */ const title = ref(observation.title); const purpose = ref(observation.purpose); const participantInfo = ref(observation.participantInfo); - // properties = configuration const properties: Ref[]> = ref( factory.properties .map((json: any) => Property.fromJson(json)) @@ -79,7 +78,7 @@ Licensed under the Elastic License 2.0. */ return undefined; } - function openScheduler(schedulerType: string) { + function openScheduler(schedulerType: string): void { dialog.open( schedulerType === 'relative' ? RelativeScheduler : AbsoluteScheduler, { @@ -110,7 +109,7 @@ Licensed under the Elastic License 2.0. */ }, ); } - function validate() { + function validate(): void { let parsedProps: any; try { parsedProps = Property.toJson(properties.value); @@ -139,7 +138,7 @@ Licensed under the Elastic License 2.0. */ } } - function save(props: any) { + function save(props: any): void { if (isObjectEmpty(scheduler.value)) { if (studyStore.study.plannedStart && studyStore.study.plannedEnd) { scheduler.value = { @@ -174,19 +173,19 @@ Licensed under the Elastic License 2.0. */ let errors: MoreTableChoice[] = []; - function checkRequiredFields() { + function checkRequiredFields(): void { errors = []; if (!title.value) { errors.push({ label: 'title', value: t('observation.error.addTitle'), - }); + } as MoreTableChoice); } if (!participantInfo.value) { errors.push({ label: 'participantInfo', value: t('observation.error.addParticipantInfo'), - }); + } as MoreTableChoice); } } @@ -194,17 +193,17 @@ Licensed under the Elastic License 2.0. */ return errors.find((el) => el.label === label)?.value; } - function cancel() { + function cancel(): void { dialogRef.value.close(); } - function removeScheduler() { + function removeScheduler(): void { if (scheduler.value) { scheduler.value = {}; } } - function updateProperty(item: PropertyEmit) { + function updateProperty(item: PropertyEmit): void { properties.value[item.index].value = item.value; } diff --git a/src/components/dialog/StudyCollaboratorDialog.vue b/src/components/dialog/StudyCollaboratorDialog.vue index f1cdef8e..cd65735b 100644 --- a/src/components/dialog/StudyCollaboratorDialog.vue +++ b/src/components/dialog/StudyCollaboratorDialog.vue @@ -22,7 +22,7 @@ Licensed under the Elastic License 2.0. */ const roleValue: Ref = ref(); const warning: Ref = ref(undefined); - function save() { + function save(): void { if (!roleValue.value) { warning.value = t('studyCollaborator.dialog.addRole'); } else { @@ -37,7 +37,7 @@ Licensed under the Elastic License 2.0. */ } } - function cancel() { + function cancel(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/StudyDialog.vue b/src/components/dialog/StudyDialog.vue index a369238f..7c7f65c9 100644 --- a/src/components/dialog/StudyDialog.vue +++ b/src/components/dialog/StudyDialog.vue @@ -95,7 +95,7 @@ Licensed under the Elastic License 2.0. */ ); const contactPhoneNumber: Ref = ref(study.contact?.phoneNumber ?? ''); - function save() { + function save(): void { returnStudy.plannedStart = dateToDateString(start.value); returnStudy.plannedEnd = dateToDateString(end.value); returnStudy.duration = @@ -114,7 +114,7 @@ Licensed under the Elastic License 2.0. */ let errors: MoreTableChoice[] = []; - function checkRequiredFields() { + function checkRequiredFields(): void { errors = []; if (!returnStudy.title) { errors.push({ label: 'title', value: t('study.error.addTitle') }); @@ -168,7 +168,7 @@ Licensed under the Elastic License 2.0. */ } }); - function cancel() { + function cancel(): void { dialogRef.value.close(); } diff --git a/src/components/dialog/shared/ActionProperty.vue b/src/components/dialog/shared/ActionProperty.vue index 2faba2b8..16a32970 100644 --- a/src/components/dialog/shared/ActionProperty.vue +++ b/src/components/dialog/shared/ActionProperty.vue @@ -76,7 +76,7 @@ Licensed under the Elastic License 2.0. */ return Property.toJson(actionProps); } - function updateProperty(prop: Property, i: number) { + function updateProperty(prop: Property, i: number): void { actionProperties.value[i].value = prop; if (actionProperties.value) { diff --git a/src/components/dialog/shared/StringListPropertyInput.vue b/src/components/dialog/shared/StringListPropertyInput.vue index 74ae7e8e..32dc68e4 100644 --- a/src/components/dialog/shared/StringListPropertyInput.vue +++ b/src/components/dialog/shared/StringListPropertyInput.vue @@ -22,7 +22,7 @@ Licensed under the Elastic License 2.0. */ }, }); - const update = (event: KeyboardEvent, index: number) => { + const update = (event: KeyboardEvent, index: number): void => { if (props.property.value) { props.property.value[index] = (event.target as HTMLInputElement).value; } diff --git a/src/components/forms/CronSchedulerConfiguration.vue b/src/components/forms/CronSchedulerConfiguration.vue index 4a4ecf91..ea878e24 100644 --- a/src/components/forms/CronSchedulerConfiguration.vue +++ b/src/components/forms/CronSchedulerConfiguration.vue @@ -98,11 +98,11 @@ Licensed under the Elastic License 2.0. */ message: '', hasError: false, }); - function setCronError(message: string) { + function setCronError(message: string): void { cronError.message = message; cronError.hasError = true; } - function clearCronError() { + function clearCronError(): void { cronError.message = ''; cronError.hasError = false; } @@ -112,7 +112,7 @@ Licensed under the Elastic License 2.0. */ (e: 'onError', errorMessage?: string): string; }>(); - function validate() { + function validate(): void { let parsedTriggerSchedule = ''; tempCronSchedule.value.forEach((item, index) => { diff --git a/src/components/forms/InterventionTriggerConditionTable.vue b/src/components/forms/InterventionTriggerConditionTable.vue index 530b6de9..37d50e08 100644 --- a/src/components/forms/InterventionTriggerConditionTable.vue +++ b/src/components/forms/InterventionTriggerConditionTable.vue @@ -136,7 +136,7 @@ Licensed under the Elastic License 2.0. */ { label: '!=', value: '!=' }, ]; - async function getFactories() { + async function getFactories(): Promise { return componentsApi .listComponents('observation') .then((response: any) => response.data); @@ -167,7 +167,9 @@ Licensed under the Elastic License 2.0. */ return []; } - function getOperatorOptions(trigger: InterventionTriggerConfig) { + function getOperatorOptions( + trigger: InterventionTriggerConfig, + ): MoreTableChoice[] { const operator: ComponentFactoryMeasurementsInner = getOperator(trigger); return (operator && operator.type === 'DOUBLE') || (operator && operator.type === 'INTEGER') @@ -184,7 +186,7 @@ Licensed under the Elastic License 2.0. */ ) as ComponentFactoryMeasurementsInner; } - function updateEditRows() { + function updateEditRows(): void { props.rows.forEach((item: InterventionTriggerConfig) => { if (item.editMode) { editingRows.value.push(item); @@ -192,7 +194,7 @@ Licensed under the Elastic License 2.0. */ }); } - function changeObservationType(trigger: InterventionTriggerConfig) { + function changeObservationType(trigger: InterventionTriggerConfig): void { if (trigger.observationId) { const observation = findObservationById( trigger.observationId, @@ -231,14 +233,14 @@ Licensed under the Elastic License 2.0. */ ); } - function changeNextGroupCondition() { + function changeNextGroupCondition(): void { emit('onChangeGroupCondition', { groupIndex: props.groupIndex, value: conditionValue.value, }); } - function edit(trigger: InterventionTriggerConfig, index: number) { + function edit(trigger: InterventionTriggerConfig, index: number): void { rowOpenError.value = t('intervention.error.interventionRowIsOpen'); emit('onRowOpen', rowOpenError.value); emit('onToggleRowEdit', { @@ -250,7 +252,7 @@ Licensed under the Elastic License 2.0. */ editingRows.value.push(trigger); } - function cancel(trigger: InterventionTriggerConfig, index: number) { + function cancel(trigger: InterventionTriggerConfig, index: number): void { rowOpenError.value = ''; emit('onRowOpen', rowOpenError.value); emit('onToggleRowEdit', { @@ -262,7 +264,7 @@ Licensed under the Elastic License 2.0. */ editingRows.value = []; } - function save(trigger: QueryObjectInner, index: number) { + function save(trigger: QueryObjectInner, index: number): void { const returnTrigger: QueryObjectInner = trigger; if ( @@ -282,7 +284,7 @@ Licensed under the Elastic License 2.0. */ }); } - function addRow(index: number) { + function addRow(index: number): void { rowOpenError.value = t('intervention.error.interventionRowIsOpen'); emit('onRowOpen', rowOpenError.value); emit('onAddRow', { @@ -291,14 +293,14 @@ Licensed under the Elastic License 2.0. */ }); } - function deleteRow(index: number) { + function deleteRow(index: number): void { emit('onDeleteRow', { groupIndex: props.groupIndex, rowIndex: index, }); } - function addTriggerGroup() { + function addTriggerGroup(): void { emit('onAddTriggerGroup', props.groupIndex); updateEditRows(); } diff --git a/src/components/forms/InterventionTriggerConditions.vue b/src/components/forms/InterventionTriggerConditions.vue index 4311641f..c87bbfbc 100644 --- a/src/components/forms/InterventionTriggerConditions.vue +++ b/src/components/forms/InterventionTriggerConditions.vue @@ -74,7 +74,7 @@ Licensed under the Elastic License 2.0. */ const rowOpenError: Ref = ref(''); - function setRowOpenError(error: boolean | string) { + function setRowOpenError(error: boolean | string): void { if (error) { rowOpenError.value = t('intervention.error.interventionRowIsOpen'); emit('onError', rowOpenError.value); @@ -83,11 +83,11 @@ Licensed under the Elastic License 2.0. */ emit('onError', rowOpenError.value); } } - function setTriggerConditionError(triggerTableE?: string) { + function setTriggerConditionError(triggerTableE?: string): void { emit('onError', triggerTableE ? triggerTableE : ''); } - function emitTriggerConditions() { + function emitTriggerConditions(): void { if ( !rowOpenError.value && typeof triggerConditionObj.value.value !== 'undefined' @@ -99,7 +99,7 @@ Licensed under the Elastic License 2.0. */ } } - function addTriggerGroup(groupIndex?: number) { + function addTriggerGroup(groupIndex?: number): void { setRowOpenError(true); if ( (groupIndex as number) >= 0 && @@ -128,7 +128,7 @@ Licensed under the Elastic License 2.0. */ checkTriggerConditionErrors(); } - function setEditModeFalse() { + function setEditModeFalse(): void { if (typeof triggerConditionObj.value.value !== 'undefined') { triggerConditionObj.value.value.forEach((item: QueryObject) => item.parameter.forEach((param) => (param.editMode = false)), @@ -138,7 +138,7 @@ Licensed under the Elastic License 2.0. */ checkTriggerConditionErrors(); } - function toggleRowEdit(item: InterventionTriggerUpdateItem) { + function toggleRowEdit(item: InterventionTriggerUpdateItem): void { if (typeof triggerConditionObj.value.value !== 'undefined') { triggerConditionObj.value.value[item.groupIndex].parameter[ item.rowIndex @@ -191,7 +191,7 @@ Licensed under the Elastic License 2.0. */ ); } - function updateRowData(item: InterventionTriggerUpdateData) { + function updateRowData(item: InterventionTriggerUpdateData): void { if (!validateEditedRow(item.data)) { return; } @@ -222,7 +222,7 @@ Licensed under the Elastic License 2.0. */ emitTriggerConditions(); } - function addRow(item: InterventionTriggerUpdateItem) { + function addRow(item: InterventionTriggerUpdateItem): void { if (typeof triggerConditionObj.value.value !== 'undefined') { setEditModeFalse(); triggerConditionObj.value.value[item.groupIndex].parameter.push({ @@ -237,7 +237,7 @@ Licensed under the Elastic License 2.0. */ } checkTriggerConditionErrors(); } - function deleteRow(item: InterventionTriggerUpdateItem) { + function deleteRow(item: InterventionTriggerUpdateItem): void { if (typeof triggerConditionObj.value.value !== 'undefined') { triggerConditionObj.value.value[item.groupIndex].parameter.splice( item.rowIndex, @@ -255,7 +255,7 @@ Licensed under the Elastic License 2.0. */ checkTriggerConditionErrors(); } - function changeGroupCondition(item: GroupConditionChange) { + function changeGroupCondition(item: GroupConditionChange): void { if (typeof triggerConditionObj.value.value !== 'undefined') { triggerConditionObj.value.value[item.groupIndex].nextGroupCondition = item.value; @@ -263,7 +263,7 @@ Licensed under the Elastic License 2.0. */ } } - function checkTriggerConditionErrors() { + function checkTriggerConditionErrors(): void { const hasErrors = triggerConditionObj.value?.value?.some( (item: QueryObject) => item.parameter.some((p) => p.error), ); diff --git a/src/components/forms/Overview-EditDetails.vue b/src/components/forms/Overview-EditDetails.vue index 62605d78..a6615ab7 100644 --- a/src/components/forms/Overview-EditDetails.vue +++ b/src/components/forms/Overview-EditDetails.vue @@ -32,11 +32,11 @@ Licensed under the Elastic License 2.0. */ (e: 'onUpdateStudyStatus', status: StudyStatus): void; }>(); - function updateStudy(study: Study) { + function updateStudy(study: Study): void { emit('onUpdateStudy', study); } - function updateStudyStatus(status: StudyStatus) { + function updateStudyStatus(status: StudyStatus): void { dialog.open(ChangeStudyStatusDialog, { data: { study: props.study, @@ -62,7 +62,7 @@ Licensed under the Elastic License 2.0. */ }); } - function openEditDialog() { + function openEditDialog(): void { dialog.open(StudyDialog, { data: { study: props.study, @@ -168,7 +168,7 @@ Licensed under the Elastic License 2.0. */ diff --git a/src/components/shared/AlertMsg.vue b/src/components/shared/AlertMsg.vue index 70e16dc3..6a96426d 100644 --- a/src/components/shared/AlertMsg.vue +++ b/src/components/shared/AlertMsg.vue @@ -42,7 +42,7 @@ Licensed under the Elastic License 2.0. */ (e: 'onMsgChange'): boolean; }>(); - function showMessage() { + function showMessage(): void { setTimeout(() => { emit('onMsgChange'); }, 3000); diff --git a/src/components/shared/Header.vue b/src/components/shared/Header.vue index 2ed9b937..859f87ff 100644 --- a/src/components/shared/Header.vue +++ b/src/components/shared/Header.vue @@ -14,11 +14,11 @@ Licensed under the Elastic License 2.0. */ const auth = inject('authService') as AuthService; const loading = useLoader().isLoading; - function logout() { + function logout(): void { auth.logout(); } - function checkRoute(routeName: string) { + function checkRoute(routeName: string): boolean { return routeName === route.meta.title; } diff --git a/src/components/shared/MoreTabNav.vue b/src/components/shared/MoreTabNav.vue index f9dafd86..5bea8594 100644 --- a/src/components/shared/MoreTabNav.vue +++ b/src/components/shared/MoreTabNav.vue @@ -95,7 +95,7 @@ Licensed under the Elastic License 2.0. */ access.value = props.studyRoles.some((r) => activeTab.access.includes(r)); } - function getAccess() { + function getAccess(): void { if (!activeTab) { return; } @@ -126,7 +126,7 @@ Licensed under the Elastic License 2.0. */ } } - function getDialogMsg(activeTab: Tab) { + function getDialogMsg(activeTab: Tab): string { let msg: string = activeTab.name + t('studyNavigation.accessDialog.accessInformation'); @@ -146,11 +146,11 @@ Licensed under the Elastic License 2.0. */ return msg; } - function getVisible(accessRoles: StudyRole[]) { + function getVisible(accessRoles: StudyRole[]): boolean { return props.studyRoles.some((r) => accessRoles.includes(r)); } - function setActiveTab() { + function setActiveTab(): void { tabs.forEach((tab: Tab) => { tab.active = tab.name === route.name; }); diff --git a/src/components/shared/MoreTable.vue b/src/components/shared/MoreTable.vue index 6188bc0d..3845ec48 100644 --- a/src/components/shared/MoreTable.vue +++ b/src/components/shared/MoreTable.vue @@ -33,6 +33,7 @@ Licensed under the Elastic License 2.0. */ ComponentFactory, StudyRole, StudyStatus, + Visibility, } from '../../generated-sources/openapi'; import { shortenText } from '../../utils/commonUtils'; import { useGlobalStore } from '../../stores/globalStore'; @@ -101,7 +102,7 @@ Licensed under the Elastic License 2.0. */ const enableEditMode = ref(false); updateEditableStatus(); - function updateEditableStatus() { + function updateEditableStatus(): void { if (props.editableAccess) { enableEditMode.value = props.columns.some((c) => c.editable); } else { @@ -115,7 +116,7 @@ Licensed under the Elastic License 2.0. */ }, ); - function rowActionHandler(action: MoreTableAction, row: any) { + function rowActionHandler(action: MoreTableAction, row: any): void { if (action.confirmDeleteDialog) { action.confirmDeleteDialog.dialog(row); } else { @@ -123,19 +124,20 @@ Licensed under the Elastic License 2.0. */ } } - function isVisible(action: MoreTableAction, row: any = undefined) { + function isVisible(action: MoreTableAction, row: any = undefined): boolean { return action.visible === undefined || action.visible(row); } const rowIDsInEditMode: Ref = ref([]); - function isRowInEditMode(row: any) { + function isRowInEditMode(row: any): boolean { if (row[props.rowId]) { return rowIDsInEditMode.value.includes(row[props.rowId]); } + return false; } const editingRows: Ref = ref([]); - function setRowToEditMode(row: any) { + function setRowToEditMode(row: any): void { rowIDsInEditMode.value = []; editingRows.value = []; @@ -146,7 +148,7 @@ Licensed under the Elastic License 2.0. */ editingRows.value.push(row); } - function cancelEditMode(row: any) { + function cancelEditMode(row: any): void { editingRows.value.splice( editingRows.value.findIndex((r) => r[props.rowId] === row[props.rowId]), ); @@ -155,12 +157,12 @@ Licensed under the Elastic License 2.0. */ ); } - function saveEditChanges(row: any) { + function saveEditChanges(row: any): void { emit('onChange', cleanRow(row)); cancelEditMode(row); } - function isRowEditable(row: any) { + function isRowEditable(row: any): boolean { if (!props.editableAccess) { return false; } @@ -181,13 +183,13 @@ Licensed under the Elastic License 2.0. */ return props.editable(row); } - function onRowClick(event: DataTableRowClickEvent) { + function onRowClick(event: DataTableRowClickEvent): void { if (rowIDsInEditMode.value.length === 0) { emit('onSelect', event.data[props.rowId]); } } - function prepareRows(rows: any) { + function prepareRows(rows: any): any { return rows.map((row: any) => { props.columns.forEach((column) => { if (column.type === MoreTableFieldType.calendar) { @@ -200,7 +202,7 @@ Licensed under the Elastic License 2.0. */ }); } - function cleanRow(row: any) { + function cleanRow(row: any): any { props.columns.forEach((column) => { if (column.type === MoreTableFieldType.calendar) { const date = row[`__internalValue_${column.field}`]; @@ -211,7 +213,10 @@ Licensed under the Elastic License 2.0. */ return row; } - function getLabelForChoiceValue(value: any, values: MoreTableChoice[]) { + function getLabelForChoiceValue( + value: any, + values: MoreTableChoice[], + ): string { return ( values.find((s: any) => s.value === value?.toString())?.label || value ); @@ -220,7 +225,7 @@ Licensed under the Elastic License 2.0. */ function getLabelForMultiSelectValue( setValues: any, valueChoices?: MoreTableChoice[], - ) { + ): string[] { if (valueChoices) { const labels: string[] = []; setValues.forEach((v: StudyRole) => { @@ -243,13 +248,15 @@ Licensed under the Elastic License 2.0. */ return editable.values; } - function isColumnEditable(editable: boolean | MoreTableEditable | undefined): boolean { + function isColumnEditable( + editable: boolean | MoreTableEditable | undefined, + ): boolean { if (editable === undefined) return false; if (typeof editable === 'boolean') return editable; return editable.enabled; } - function getObservationVisibility(type: string) { + function getObservationVisibility(type: string): Visibility | undefined { return props.componentFactory?.find((cf) => cf.componentId === type) ?.visibility; } diff --git a/src/components/shared/RelativeScheduler.vue b/src/components/shared/RelativeScheduler.vue index 0ed7fdc8..9eeaa6b4 100644 --- a/src/components/shared/RelativeScheduler.vue +++ b/src/components/shared/RelativeScheduler.vue @@ -125,7 +125,7 @@ return errors.find((el) => el.label === label)?.value; } - function checkErrors() { + function checkErrors(): void { errors = []; if ( !returnSchedule.dtstart.offset?.value || @@ -199,7 +199,7 @@ } } - function calculatedRepeat() { + function calculatedRepeat(): void { if (!repeatChecked.value) { return; } @@ -253,11 +253,11 @@ } } - function cancel() { + function cancel(): void { dialogRef.value.close(); } - function save() { + function save(): void { returnSchedule.dtstart.time = startTime.value ?.toTimeString() .substring(0, 5); diff --git a/src/components/shared/Scheduler.vue b/src/components/shared/Scheduler.vue index c5fa2a41..b779bb8a 100644 --- a/src/components/shared/Scheduler.vue +++ b/src/components/shared/Scheduler.vue @@ -73,7 +73,7 @@ Licensed under the Elastic License 2.0. */ const hasRruleValue: Ref = ref(!!returnSchedule.value.rrule); // Repeat Event Checkbox let rruleErrors: MoreTableChoice[] = []; - function onChangeSingleDayEventCheckbox() { + function onChangeSingleDayEventCheckbox(): void { if ( singleDayEventCheckbox.value && calendarStart.value && @@ -93,7 +93,7 @@ Licensed under the Elastic License 2.0. */ } } - function onChangeEntireDayCheckbox() { + function onChangeEntireDayCheckbox(): void { if (entireDayCheckbox.value) { calendarStart.value.setHours(0, 0, 0); calendarEndChangedWithStart = true; @@ -126,11 +126,15 @@ Licensed under the Elastic License 2.0. */ } } - function validateDate(dateType: string, newValue: Date, oldValue: Date) { + function validateDate( + dateType: string, + newValue: Date, + oldValue: Date, + ): void { errors = []; warnings = []; - const updateHours = (targetDate: Ref, sourceDate: Date) => { + const updateHours = (targetDate: Ref, sourceDate: Date): void => { targetDate.value.setHours( sourceDate.getHours(), sourceDate.getMinutes(), @@ -171,26 +175,26 @@ Licensed under the Elastic License 2.0. */ } } - function toggleHasRruleValue(rruleCheckbox: boolean) { + function toggleHasRruleValue(rruleCheckbox: boolean): void { hasRruleValue.value = rruleCheckbox; } - function onRruleUpdate(schedulerRrule: RecurrenceRule) { + function onRruleUpdate(schedulerRrule: RecurrenceRule): void { if (hasRruleValue.value) { returnSchedule.value.rrule = schedulerRrule; } } - function onRruleErrorUpdate(updatedRruleErrors: MoreTableChoice[]) { + function onRruleErrorUpdate(updatedRruleErrors: MoreTableChoice[]): void { rruleErrors = updatedRruleErrors; } - function save() { + function save(): void { // setCalendarStart and calendarEnd into returnSchedule object returnSchedule.value.dtstart = calendarStart.value.toISOString(); returnSchedule.value.dtend = calendarEnd.value.toISOString(); - // check if repeateChecked is on -> if not set rrule: undefined, if it is save rrule with close + // check if repeatedChecked is on -> if not set rrule: undefined, if it is safe rrule with close if (!hasRruleValue.value) { returnSchedule.value.rrule = undefined; } @@ -204,7 +208,7 @@ Licensed under the Elastic License 2.0. */ } } - function cancel() { + function cancel(): void { dialogRef.value.close(); } diff --git a/src/components/subComponents/AbsoluteSchedulerRepetition.vue b/src/components/subComponents/AbsoluteSchedulerRepetition.vue index ae122dfd..778c11cf 100644 --- a/src/components/subComponents/AbsoluteSchedulerRepetition.vue +++ b/src/components/subComponents/AbsoluteSchedulerRepetition.vue @@ -53,7 +53,7 @@ let rruleErrors: MoreTableChoice[] = []; - function checkErrors() { + function checkErrors(): void { rruleErrors = []; if (rruleEventCheckbox.value) { if (typeof returnRrule.freq === 'undefined') { @@ -159,7 +159,7 @@ rruleEndOptionValue.value = RRuleEndOptions.after; } - function setRruleCountLabel(rruleFreq: string | undefined) { + function setRruleCountLabel(rruleFreq: string | undefined): void { if (rruleFreq) { rruleCountLabel.value = rruleFrequencyOptions.find( (f: any) => f.value === rruleFreq, @@ -167,12 +167,12 @@ } } - function toggleRruleCheckbox() { + function toggleRruleCheckbox(): void { checkErrors(); emit('onRruleCheckboxChange', rruleEventCheckbox.value); } - function setRepetitionEnd(type: string | undefined) { + function setRepetitionEnd(type: string | undefined): void { switch (type) { case RRuleEndOptions.after: { @@ -205,7 +205,7 @@ } }); - function onChangeRrule(type?: string, eventValue?: any) { + function onChangeRrule(type?: string, eventValue?: any): void { if (type === 'byday' && previewCount.value && returnRrule.byday?.length) { returnRrule.count = previewCount.value * returnRrule.byday.length; } diff --git a/src/components/subComponents/CronScheduleInfo.vue b/src/components/subComponents/CronScheduleInfo.vue index 89d5fb16..e055c750 100644 --- a/src/components/subComponents/CronScheduleInfo.vue +++ b/src/components/subComponents/CronScheduleInfo.vue @@ -15,7 +15,7 @@ Licensed under the Elastic License 2.0. */ const isDialogOpen = ref(false); - function openDialog() { + function toggleDialog(): void { isDialogOpen.value = !isDialogOpen.value; } @@ -38,7 +38,7 @@ Licensed under the Elastic License 2.0. */
{ clearInterval(timer); }); - function listDataPoints() { + function listDataPoints(): void { dataApi .getDataPoints( props.studyId, @@ -81,7 +81,7 @@ Licensed under the Elastic License 2.0. */ return string; } - function listObservations() { + function listObservations(): void { observationsApi .listObservations(props.studyId) .then((observation) => @@ -96,7 +96,7 @@ Licensed under the Elastic License 2.0. */ .then((options) => (observations.value = [emptyOption, ...options])); } - function listParticipants() { + function listParticipants(): void { participantsApi .listParticipants(props.studyId) .then((participant) => diff --git a/src/components/subComponents/SchedulerInfoBlock.vue b/src/components/subComponents/SchedulerInfoBlock.vue index 3a4af737..a0d21182 100644 --- a/src/components/subComponents/SchedulerInfoBlock.vue +++ b/src/components/subComponents/SchedulerInfoBlock.vue @@ -38,7 +38,7 @@ Licensed under the Elastic License 2.0. */ (e: 'removeScheduler'): void; }>(); - function getSchedulerDescription() { + function getSchedulerDescription(): string { switch (props.scheduler.type) { case ScheduleType.Event: return t('scheduler.dialog.absoluteSchedule.description'); @@ -49,7 +49,7 @@ Licensed under the Elastic License 2.0. */ } } - function getDateValues(prop: string) { + function getDateValues(prop: string): string | undefined { switch (props.scheduler.type) { case ScheduleType.Event: { const schedule = props.scheduler as Event; @@ -93,7 +93,7 @@ Licensed under the Elastic License 2.0. */ } } - function getRepetitionValue(prop: string) { + function getRepetitionValue(prop: string): string | undefined { switch (props.scheduler.type) { case ScheduleType.Event: { diff --git a/src/composable/useErrorHandling.ts b/src/composable/useErrorHandling.ts index 73f8144e..9bbcf71b 100644 --- a/src/composable/useErrorHandling.ts +++ b/src/composable/useErrorHandling.ts @@ -9,12 +9,20 @@ import axios, { AxiosError } from 'axios'; import useLoader from './useLoader'; -export function useErrorHandling() { +type UseErrorHandlingReturnType = { + handleIndividualError: ( + error: AxiosError & { globallyHandled?: boolean }, + messageKey?: string, + ) => void; + activateGlobalErrorHandlingInterceptor: () => void; +}; + +export function useErrorHandling(): UseErrorHandlingReturnType { const loader = useLoader(); const handleIndividualError = ( error: AxiosError & { globallyHandled?: boolean }, messageKey?: string, - ) => { + ): void => { if (!error.globallyHandled) { console.error( error.config?.url @@ -24,7 +32,7 @@ export function useErrorHandling() { loader.reset(); } }; - const activateGlobalErrorHandlingInterceptor = () => { + const activateGlobalErrorHandlingInterceptor = (): void => { axios.interceptors.response.use( (response) => response, (error: AxiosError) => { diff --git a/src/composable/useLoader.ts b/src/composable/useLoader.ts index 3ddded23..b4dec86d 100644 --- a/src/composable/useLoader.ts +++ b/src/composable/useLoader.ts @@ -6,28 +6,36 @@ Foerderung der wissenschaftlichen Forschung). Licensed under the Elastic License 2.0. */ -import { readonly, ref } from 'vue'; +import { readonly, Ref, ref } from 'vue'; import axios from 'axios'; -const loaderSemaphore = ref(0); -const loaderValue = ref(false); +const loaderSemaphore: Ref = ref(0); +const loaderValue: Ref = ref(false); -const loader = { - enable: () => { +interface Loader { + enable: () => void; + disable: () => void; + reset: () => void; + isLoading: Readonly>; + activateLoadingInterceptor: () => void; +} + +const loader: Loader = { + enable: (): void => { loaderSemaphore.value += 1; loaderValue.value = loaderSemaphore.value > 0; }, - disable: () => { + disable: (): void => { loaderSemaphore.value = loaderSemaphore.value < 2 ? 0 : loaderSemaphore.value - 1; loaderValue.value = loaderSemaphore.value > 0; }, - reset: () => { + reset: (): void => { loaderSemaphore.value = 0; loaderValue.value = false; }, isLoading: readonly(loaderValue), - activateLoadingInterceptor: () => { + activateLoadingInterceptor: (): void => { axios.interceptors.request.use( (config) => { return { @@ -84,6 +92,6 @@ const loader = { ); }, }; -export default () => { +export default (): Loader => { return loader; }; diff --git a/src/models/ComponentModels.ts b/src/models/ComponentModels.ts new file mode 100644 index 00000000..614fe904 --- /dev/null +++ b/src/models/ComponentModels.ts @@ -0,0 +1,13 @@ +/* + Copyright LBI-DHP and/or licensed to LBI-DHP under one or more + contributor license agreements (LBI-DHP: Ludwig Boltzmann Institute + for Digital Health and Prevention -- A research institute of the + Ludwig Boltzmann Gesellschaft, Oesterreichische Vereinigung zur + Foerderung der wissenschaftlichen Forschung). + Licensed under the Elastic License 2.0. + */ +export interface MenuOptions { + label: string; + value: string | number; + command: () => any; +} diff --git a/src/router/index.ts b/src/router/index.ts index ec4830a2..c4027aac 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -21,7 +21,7 @@ import { useStudyGroupStore } from '../stores/studyGroupStore'; import Integrations from '../views/Integrations.vue'; import Timeline from '../views/Timeline.vue'; -const studyResolver = async (to: any, from: any, next: any) => { +const studyResolver = async (to: any, from: any, next: any): Promise => { const studyStore = useStudyStore(); const studyGroupStore = useStudyGroupStore(); if ( diff --git a/src/service/AuthService.ts b/src/service/AuthService.ts index 2c974e49..dd95b35a 100644 --- a/src/service/AuthService.ts +++ b/src/service/AuthService.ts @@ -15,7 +15,7 @@ export default class AuthService { this.keycloak = new Keycloak(options); } - public async init() { + public async init(): Promise { const loggedIn = await this.keycloak.init({ onLoad: 'login-required' }); if (loggedIn) { setInterval(() => { diff --git a/src/stores/studyGroupStore.ts b/src/stores/studyGroupStore.ts index 6d6a31d5..0ef24006 100644 --- a/src/stores/studyGroupStore.ts +++ b/src/stores/studyGroupStore.ts @@ -23,7 +23,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { const studyGroups: Ref = ref([]); // Actions - async function getStudyGroups(studyId: number) { + async function getStudyGroups(studyId: number): Promise { studyGroups.value = await studyGroupsApi .listStudyGroups(studyId) .then((response) => response.data) @@ -32,7 +32,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { return studyGroups.value; }); } - async function createStudyGroup(studyId: number) { + async function createStudyGroup(studyId: number): Promise { let title; let count = studyGroups.value.length; while (title === undefined) { @@ -53,7 +53,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { ); } - function deleteStudyGroup(studyGroup: StudyGroup) { + function deleteStudyGroup(studyGroup: StudyGroup): void { studyGroupsApi .deleteStudyGroup( studyGroup.studyId as number, @@ -71,7 +71,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { handleIndividualError(e, 'cannot delete study group'), ); } - async function updateStudyGroup(studyGroup: StudyGroup) { + async function updateStudyGroup(studyGroup: StudyGroup): Promise { const position = studyGroups.value.findIndex( (studyGroupsItem) => studyGroupsItem.studyGroupId === studyGroup.studyGroupId, @@ -90,7 +90,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { } } - function toStudyGroupMap() { + function toStudyGroupMap(): MoreStudyGroupTableMap[] { return studyGroups.value.map((studyGroup: StudyGroup) => { return { studyId: studyGroup.studyId, @@ -124,7 +124,7 @@ export const useStudyGroupStore = defineStore('studyGroup', () => { duration: d, numberOfParticipants: row.numberOfParticipants, created: row.created, - modiefied: row.modified, + modified: row.modified, } as StudyGroup; } diff --git a/src/stores/studyStore.ts b/src/stores/studyStore.ts index 1683b5f2..ee9d2de9 100644 --- a/src/stores/studyStore.ts +++ b/src/stores/studyStore.ts @@ -34,7 +34,7 @@ export const useStudyStore = defineStore('study', () => { return study.value; }); } - async function updateStudy(studyResponse: Study) { + async function updateStudy(studyResponse: Study): Promise { if (study.value.studyId) { study.value = await studiesApi .updateStudy(study.value.studyId, studyResponse) @@ -49,7 +49,7 @@ export const useStudyStore = defineStore('study', () => { } } - async function updateStudyStatus(status: StudyStatus) { + async function updateStudyStatus(status: StudyStatus): Promise { if (study.value.studyId) { await studiesApi .setStatus(study.value.studyId, { status }) @@ -82,7 +82,7 @@ export const useStudyStore = defineStore('study', () => { ); } - async function deleteStudy(studyId: number | undefined) { + async function deleteStudy(studyId: number | undefined): Promise { if (studyId) { await studiesApi .deleteStudy(studyId) @@ -106,7 +106,7 @@ export const useStudyStore = defineStore('study', () => { return studies.value; }); } - async function updateStudyInStudies(changedStudy: Study) { + async function updateStudyInStudies(changedStudy: Study): Promise { const i = studies.value.findIndex( (studyItem) => studyItem.studyId === changedStudy.studyId, ); @@ -120,7 +120,7 @@ export const useStudyStore = defineStore('study', () => { } } - async function importStudy(importedStudy: File) { + async function importStudy(importedStudy: File): Promise { await importExportApi .importStudy(importedStudy, { headers: { diff --git a/src/types/vue-cal/index.d.ts b/src/types/vue-cal/index.d.ts index f03a3e34..bdb15a53 100644 --- a/src/types/vue-cal/index.d.ts +++ b/src/types/vue-cal/index.d.ts @@ -263,7 +263,7 @@ declare module 'vue-cal' { export type VueCal = Props; export class VueCal extends Vue { - $on(event: T, callback: EventListeners[T]) { + $on(event: T, callback: EventListeners[T]): void { return super.$on(event, callback); } diff --git a/src/utils/dateUtils.ts b/src/utils/dateUtils.ts index 938ef7c5..853e8d2c 100644 --- a/src/utils/dateUtils.ts +++ b/src/utils/dateUtils.ts @@ -6,7 +6,7 @@ Foerderung der wissenschaftlichen Forschung). Licensed under the Elastic License 2.0. */ -export function dateToDateString(date: Date) { +export function dateToDateString(date: Date): string | undefined { return dateToDateTimeString(date)?.substring(0, 10); } diff --git a/src/views/Dashboard.vue b/src/views/Dashboard.vue index ea410a0f..59e31e8b 100644 --- a/src/views/Dashboard.vue +++ b/src/views/Dashboard.vue @@ -17,7 +17,7 @@ Licensed under the Elastic License 2.0. */ userStore.getUser().then(() => openWelcomeMessage()); - function openWelcomeMessage() { + function openWelcomeMessage(): void { const storageItem = localStorage.getItem('welcomeMsg'); if (userStore.user?.uid && !storageItem) { dialog.open(InfoDialog, { diff --git a/src/views/Participants.vue b/src/views/Participants.vue index 54595df4..1c87e4d2 100644 --- a/src/views/Participants.vue +++ b/src/views/Participants.vue @@ -29,7 +29,7 @@ Licensed under the Elastic License 2.0. */ >
diff --git a/src/views/StudyOverview.vue b/src/views/StudyOverview.vue index f4c8924c..acfc9113 100644 --- a/src/views/StudyOverview.vue +++ b/src/views/StudyOverview.vue @@ -20,7 +20,7 @@ Licensed under the Elastic License 2.0. */ const studyGroupStore = useStudyGroupStore(); const studyId = parseInt(route.params.studyId as string); - async function processUpdatedStudyStatus(status: StudyStatus) { + async function processUpdatedStudyStatus(status: StudyStatus): Promise { await studyStore.updateStudyStatus(status).then(() => { if (status === StudyStatus.Active || status === StudyStatus.Preview) { studyStore.study.start = dateToDateString(new Date()); @@ -32,12 +32,8 @@ Licensed under the Elastic License 2.0. */ }); } - async function getStudyGroups() { - await studyGroupStore.getStudyGroups(studyId); - } - studyStore.getStudy(studyId); - getStudyGroups(); + studyGroupStore.getStudyGroups(studyId);