vikunja-frontend/src/main.ts

114 lines
2.8 KiB
TypeScript
Raw Normal View History

2018-08-28 22:50:22 +02:00
import Vue from 'vue'
import App from './App.vue'
import router from './router'
2018-08-28 22:50:22 +02:00
declare global {
interface Window {
API_URL: string;
}
}
import {formatDate, formatDateSince} from '@/helpers/time/formatDate'
// @ts-ignore
import {VERSION} from './version.json'
2021-04-22 14:26:48 +02:00
// Register the modal
// @ts-ignore
import Modal from './components/modal/modal'
// Add CSS
import './styles/vikunja.scss'
// Notifications
import Notifications from 'vue-notification'
// PWA
import './registerServiceWorker'
// Shortcuts
// @ts-ignore - no types available
import vueShortkey from 'vue-shortkey'
// Mixins
import message from './message'
import {colorIsDark} from './helpers/color/colorIsDark'
import {setTitle} from './helpers/setTitle'
import {getNamespaceTitle} from './helpers/getNamespaceTitle'
import {getListTitle} from './helpers/getListTitle'
// Vuex
import {store} from './store'
// i18n
import VueI18n from 'vue-i18n' // types
import {i18n} from './i18n/setup'
console.info(`Vikunja frontend version ${VERSION}`)
// Check if we have an api url in local storage and use it if that's the case
const apiUrlFromStorage = localStorage.getItem('API_URL')
if (apiUrlFromStorage !== null) {
window.API_URL = apiUrlFromStorage
}
// Make sure the api url does not contain a / at the end
if (window.API_URL.substr(window.API_URL.length - 1, window.API_URL.length) === '/') {
window.API_URL = window.API_URL.substr(0, window.API_URL.length - 1)
}
2018-09-12 08:22:17 +02:00
Vue.component('modal', Modal)
2018-08-28 22:50:22 +02:00
Vue.config.productionTip = false
2018-09-08 21:43:16 +02:00
Vue.use(Notifications)
import FontAwesomeIcon from './icons'
2018-09-09 17:23:06 +02:00
Vue.component('icon', FontAwesomeIcon)
Vue.use(vueShortkey, {prevent: ['input', 'textarea', '.input']})
import focus from './directives/focus'
2020-11-02 21:52:07 +01:00
Vue.directive('focus', focus)
2018-12-25 16:03:51 +01:00
import tooltip from './directives/tooltip'
2021-04-22 14:26:48 +02:00
// @ts-ignore
Vue.directive('tooltip', tooltip)
Better reminders (#308) Fix setting the new reminder component to null after adding a new date Add "close on change" event which only fires if the component closed and the value actually changed Hide the "today" option after 21:00 Add "confirm" button to close the component Use disabled in reminders Add a disabled property to the datepicker Cleanup workarounds for flatpickr Use the new datepicker for end dates Use the new datepicker for start date Use the new datepicker for due dates Mobile styling Format Sync flatpickr when clicking on choose a date Make sure to only hide the popup when not clicked something inside of it Make flatpickr dates work Use datepicker component for reminders Merge branch 'master' into feature/better-reminders Fix bottom padding of inline flatpickr Set time Add method to calculate the neares time Move time helpers in separate folder Remove separate flatpickr date Cleanup Set the flatpickr date when setting changing the date Better formatting of the chosen date Bubble Set date when choosing one Fix test Show correct weekday in preview Change hover background color Make label to show if selected date is null configurable Use a different icon for weekend Ignore test files when linting Add tests to dron Move day interval calculation to separate file and test it Add next date calculation Add basic date picker component Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/308 Co-Authored-By: konrad <konrad@kola-entertainments.de> Co-Committed-By: konrad <konrad@kola-entertainments.de>
2020-11-28 14:59:27 +01:00
// @ts-ignore
import Button from './components/input/button'
Vue.component('x-button', Button)
// @ts-ignore
import Card from './components/misc/card'
Vue.component('card', Card)
Vue.mixin({
methods: {
formatDateSince(date) {
return formatDateSince(date, (p: VueI18n.Path, params?: VueI18n.Values) => this.$t(p, params))
},
formatDate(date) {
return formatDate(date, 'PPPPpppp', this.$t('date.locale'))
},
formatDateShort(date) {
return formatDate(date, 'PPpp', this.$t('date.locale'))
},
getNamespaceTitle(n) {
return getNamespaceTitle(n, (p: VueI18n.Path) => this.$t(p))
},
getListTitle(l) {
return getListTitle(l, (p: VueI18n.Path) => this.$t(p))
},
2021-06-22 22:07:57 +02:00
error(e, actions = []) {
return message.error(e, this, (p: VueI18n.Path) => this.$t(p), actions)
2021-06-22 22:07:57 +02:00
},
success(s, actions = []) {
return message.success(s, this, (p: VueI18n.Path) => this.$t(p), actions)
2021-06-22 22:07:57 +02:00
},
colorIsDark: colorIsDark,
setTitle: setTitle,
},
})
2018-08-28 22:50:22 +02:00
new Vue({
router,
store,
i18n,
render: h => h(App),
2018-08-28 22:50:22 +02:00
}).$mount('#app')