1
0

feat: improve types (#2368)

Reviewed-on: https://kolaente.dev/vikunja/vikunja/pulls/2368
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Co-committed-by: Dominik Pschenitschni <mail@celement.de>
This commit is contained in:
Dominik Pschenitschni 2024-06-12 10:04:26 +00:00 committed by konrad
parent 50d698794b
commit bc897a4503
8 changed files with 30 additions and 31 deletions

View File

@ -28,28 +28,23 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
// the logic of this component is loosly based on this article // the logic of this component is loosely based on this article
// https://gomakethings.com/how-to-add-transition-animations-to-vanilla-javascript-show-and-hide-methods/#putting-it-all-together // https://gomakethings.com/how-to-add-transition-animations-to-vanilla-javascript-show-and-hide-methods/#putting-it-all-together
import {computed, ref} from 'vue' import {computed, ref} from 'vue'
import {getInheritedBackgroundColor} from '@/helpers/getInheritedBackgroundColor' import {getInheritedBackgroundColor} from '@/helpers/getInheritedBackgroundColor'
const props = defineProps({ const props = withDefaults(defineProps<{
/** Whether the Expandable is open or not */ /** Whether the Expandable is open or not */
open: { open?: boolean,
type: Boolean,
default: false,
},
/** If there is too much content, content will be cut of here. */ /** If there is too much content, content will be cut of here. */
initialHeight: { initialHeight?: number
type: Number,
default: undefined,
},
/** The hidden content is indicated by a gradient. This is the color that the gradient fades to. /** The hidden content is indicated by a gradient. This is the color that the gradient fades to.
* Makes only sense if `initialHeight` is set. */ * Makes only sense if `initialHeight` is set. */
backgroundColor: { backgroundColor: string
type: String, }>(), {
}, open: false,
initialHeight: undefined,
}) })
const wrapper = ref<HTMLElement | null>(null) const wrapper = ref<HTMLElement | null>(null)
@ -82,7 +77,7 @@ function forceLayout(el: HTMLElement) {
/* ###################################################################### /* ######################################################################
# The following functions are called by the js hooks of the transitions. # The following functions are called by the js hooks of the transitions.
# They follow the orignal hook order of the vue transition component # They follow the original hook order of the vue transition component
# see: https://vuejs.org/guide/built-ins/transition.html#javascript-hooks # see: https://vuejs.org/guide/built-ins/transition.html#javascript-hooks
###################################################################### */ ###################################################################### */

View File

@ -1,4 +1,4 @@
export const DATEFNS_DATE_FORMAT_KEBAB = 'yyyy-LL-dd' export const DATEFNS_DATE_FORMAT_KEBAB = 'yyyy-LL-dd' as const
export const SECONDS_A_MINUTE = 60 export const SECONDS_A_MINUTE = 60
export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60 export const SECONDS_A_HOUR = SECONDS_A_MINUTE * 60

View File

@ -4,11 +4,11 @@ import type {IAttachment} from '@/modelTypes/IAttachment'
import AttachmentService from '@/services/attachment' import AttachmentService from '@/services/attachment'
import {useTaskStore} from '@/stores/tasks' import {useTaskStore} from '@/stores/tasks'
export function uploadFile(taskId: number, file: File, onSuccess?: (url: string) => void) { export async function uploadFile(taskId: number, file: File, onSuccess?: (url: string) => void) {
const attachmentService = new AttachmentService() const attachmentService = new AttachmentService()
const files = [file] const files = [file]
return uploadFiles(attachmentService, taskId, files, onSuccess) return await uploadFiles(attachmentService, taskId, files, onSuccess)
} }
export async function uploadFiles( export async function uploadFiles(

View File

@ -37,7 +37,7 @@ if (window.API_URL.endsWith('/')) {
// directives // directives
import focus from '@/directives/focus' import focus from '@/directives/focus'
import {VTooltip} from 'floating-vue' import {vTooltip} from 'floating-vue'
import 'floating-vue/dist/style.css' import 'floating-vue/dist/style.css'
import shortcut from '@/directives/shortcut' import shortcut from '@/directives/shortcut'
import cypress from '@/directives/cypress' import cypress from '@/directives/cypress'
@ -57,7 +57,7 @@ setLanguage(browserLanguage).then(() => {
app.use(Notifications) app.use(Notifications)
app.directive('focus', focus) app.directive('focus', focus)
app.directive('tooltip', VTooltip) app.directive('tooltip', vTooltip)
app.directive('shortcut', shortcut) app.directive('shortcut', shortcut)
app.directive('cy', cypress) app.directive('cy', cypress)

View File

@ -2,12 +2,13 @@ import AbstractModel from './abstractModel'
import TaskModel from '@/models/task' import TaskModel from '@/models/task'
import UserModel from '@/models/user' import UserModel from '@/models/user'
import SubscriptionModel from '@/models/subscription' import SubscriptionModel from '@/models/subscription'
import ProjectViewModel from '@/models/projectView'
import type {IProject} from '@/modelTypes/IProject' import type {IProject} from '@/modelTypes/IProject'
import type {IUser} from '@/modelTypes/IUser' import type {IUser} from '@/modelTypes/IUser'
import type {ITask} from '@/modelTypes/ITask' import type {ITask} from '@/modelTypes/ITask'
import type {ISubscription} from '@/modelTypes/ISubscription' import type {ISubscription} from '@/modelTypes/ISubscription'
import ProjectViewModel from '@/models/projectView' import type { IProjectView } from '@/modelTypes/IProjectView'
export default class ProjectModel extends AbstractModel<IProject> implements IProject { export default class ProjectModel extends AbstractModel<IProject> implements IProject {
id = 0 id = 0
@ -24,7 +25,7 @@ export default class ProjectModel extends AbstractModel<IProject> implements IPr
position = 0 position = 0
backgroundBlurHash = '' backgroundBlurHash = ''
parentProjectId = 0 parentProjectId = 0
views = [] views: IProjectView[] = []
created: Date = null created: Date = null
updated: Date = null updated: Date = null

View File

@ -1,3 +1,5 @@
import type { FunctionalComponent } from 'vue'
import type { Notifications } from '@kyvg/vue3-notification'
// import FontAwesomeIcon from '@/components/misc/Icon' // import FontAwesomeIcon from '@/components/misc/Icon'
import type { FontAwesomeIcon as FontAwesomeIconFixedTypes } from './vue-fontawesome' import type { FontAwesomeIcon as FontAwesomeIconFixedTypes } from './vue-fontawesome'
import type XButton from '@/components/input/button.vue' import type XButton from '@/components/input/button.vue'
@ -12,6 +14,7 @@ import type Card from '@/components/misc/card.vue'
declare module '@vue/runtime-core' { declare module '@vue/runtime-core' {
export interface GlobalComponents { export interface GlobalComponents {
Icon: FontAwesomeIconFixedTypes Icon: FontAwesomeIconFixedTypes
Notifications: FunctionalComponent<Notifications>
XButton: typeof XButton, XButton: typeof XButton,
Modal: typeof Modal, Modal: typeof Modal,
Card: typeof Card, Card: typeof Card,

View File

@ -23,10 +23,10 @@ const router = useRouter()
const projectStore = useProjectStore() const projectStore = useProjectStore()
const authStore = useAuthStore() const authStore = useAuthStore()
const currentView = computed(() => { const currentProject = computed(() => projectStore.projects[projectId])
const project = projectStore.projects[projectId]
return project?.views.find(v => v.id === viewId) const currentView = computed(() => {
return currentProject.value?.views.find(v => v.id === viewId)
}) })
function redirectToDefaultViewIfNecessary() { function redirectToDefaultViewIfNecessary() {

View File

@ -17,12 +17,12 @@
class="teams box" class="teams box"
> >
<li <li
v-for="t in teams" v-for="team in teams"
:key="t.id" :key="team.id"
> >
<router-link :to="{name: 'teams.edit', params: {id: t.id}}"> <router-link :to="{name: 'teams.edit', params: {id: team.id}}">
<p> <p>
{{ t.name }} {{ team.name }}
</p> </p>
</router-link> </router-link>
</li> </li>