vikunja-frontend/src/main.js

192 lines
6.2 KiB
JavaScript
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
import {VERSION} from './version.json'
console.info(`Vikunja frontend version ${VERSION}`)
// 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
// Register the modal
2020-06-17 22:15:59 +02:00
import Modal from './components/modal/modal'
2018-09-12 08:22:17 +02:00
Vue.component('modal', Modal)
// Add CSS
2019-12-19 23:09:23 +01:00
import './styles/vikunja.scss'
2018-09-06 19:56:44 +02:00
2018-08-28 22:50:22 +02:00
Vue.config.productionTip = false
2018-09-08 21:43:16 +02:00
// Notifications
import Notifications from 'vue-notification'
Vue.use(Notifications)
2018-09-09 17:23:06 +02:00
// Icons
import { library } from '@fortawesome/fontawesome-svg-core'
import { faSignOutAlt } from '@fortawesome/free-solid-svg-icons'
2018-09-09 19:09:46 +02:00
import { faPlus } from '@fortawesome/free-solid-svg-icons'
import { faListOl } from '@fortawesome/free-solid-svg-icons'
import { faTasks } from '@fortawesome/free-solid-svg-icons'
2018-09-10 21:06:39 +02:00
import { faCog } from '@fortawesome/free-solid-svg-icons'
import { faAngleRight } from '@fortawesome/free-solid-svg-icons'
2018-09-11 19:20:07 +02:00
import { faLayerGroup } from '@fortawesome/free-solid-svg-icons'
2018-09-11 20:16:08 +02:00
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons'
import { faUsers } from '@fortawesome/free-solid-svg-icons'
import { faUser } from '@fortawesome/free-solid-svg-icons'
import { faLock } from '@fortawesome/free-solid-svg-icons'
import { faPen } from '@fortawesome/free-solid-svg-icons'
2018-11-25 22:02:22 +01:00
import { faTimes } from '@fortawesome/free-solid-svg-icons'
2018-12-25 16:03:51 +01:00
import { faTachometerAlt } from '@fortawesome/free-solid-svg-icons'
import { faCalendar } from '@fortawesome/free-solid-svg-icons'
import { faBars } from '@fortawesome/free-solid-svg-icons'
import { faPowerOff } from '@fortawesome/free-solid-svg-icons'
import { faCalendarWeek } from '@fortawesome/free-solid-svg-icons'
2019-03-03 16:03:08 +01:00
import { faExclamation } from '@fortawesome/free-solid-svg-icons'
2019-03-07 20:48:40 +01:00
import { faTags } from '@fortawesome/free-solid-svg-icons'
2019-04-23 21:50:37 +02:00
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'
2019-04-29 23:41:39 +02:00
import { faCheck } from '@fortawesome/free-solid-svg-icons'
2019-09-09 19:55:43 +02:00
import { faPaste } from '@fortawesome/free-solid-svg-icons'
2019-10-19 21:41:23 +02:00
import { faPencilAlt } from '@fortawesome/free-solid-svg-icons'
2018-12-25 16:03:51 +01:00
import { faTimesCircle } from '@fortawesome/free-regular-svg-icons'
import { faCalendarAlt } from '@fortawesome/free-regular-svg-icons'
2019-11-24 14:16:24 +01:00
import { faCloudDownloadAlt } from '@fortawesome/free-solid-svg-icons'
import { faCloudUploadAlt } from '@fortawesome/free-solid-svg-icons'
import { faPercent } from '@fortawesome/free-solid-svg-icons'
import { faStar } from '@fortawesome/free-regular-svg-icons'
import { faAlignLeft } from '@fortawesome/free-solid-svg-icons'
import { faPaperclip } from '@fortawesome/free-solid-svg-icons'
import { faClock } from '@fortawesome/free-regular-svg-icons'
import { faHistory } from '@fortawesome/free-solid-svg-icons'
import { faSearch } from '@fortawesome/free-solid-svg-icons'
import { faCheckDouble } from '@fortawesome/free-solid-svg-icons'
import { faTh } from '@fortawesome/free-solid-svg-icons'
import { faSort } from '@fortawesome/free-solid-svg-icons'
import { faSortUp } from '@fortawesome/free-solid-svg-icons'
2020-04-18 14:39:56 +02:00
import { faList } from '@fortawesome/free-solid-svg-icons'
Kanban (#118) Add error message when trying to create an invalid new task in a bucket Prevent creation of new buckets if the bucket title is empty Disable deleting a bucket if it's the last one Disable dragging tasks when they are being updated Fix transition when opening tasks Send the user to list view by default Show loading spinner when updating multiple tasks Add loading spinner when moving tasks Add loading animation when bucket is loading / updating etc Add bucket title edit Fix creating new buckets Add loading animation Add removing buckets Fix creating a new bucket after tasks were moved Fix warning about labels on tasks Fix labels on tasks not updating after retrieval from api Fix property width Add closing and mobile design Make the task detail popup look good Move list views Move task detail view in a popup Add link to tasks Add saving the new task position after it was moved Fix creating new bucket Fix creating a new task Cleanup Disable user selection for task cards Fix drag placeholder Add dragging style to task Add placeholder + change animation duration More cleanup Cleanup / docs Working of dragging and dropping tasks Adjust markup and styling for new library Change kanban library to something that works Add basic calculation of new positions Don't try to create empty tasks Add indicator if a task is done Add moving tasks between buckets Make empty buckets a little smaller Add gimmick for button description Fix color Fix scrolling bucket layout Add creating a new bucket Add hiding the task input field Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/118
2020-04-26 01:11:34 +02:00
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons'
import { faFilter } from '@fortawesome/free-solid-svg-icons'
import { faFillDrip } from '@fortawesome/free-solid-svg-icons'
import { faKeyboard } from '@fortawesome/free-solid-svg-icons'
import { faComments } from '@fortawesome/free-regular-svg-icons'
2018-09-09 17:23:06 +02:00
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
library.add(faSignOutAlt)
2018-09-09 19:09:46 +02:00
library.add(faPlus)
library.add(faListOl)
library.add(faTasks)
2018-09-10 21:06:39 +02:00
library.add(faCog)
library.add(faAngleRight)
2018-09-11 19:20:07 +02:00
library.add(faLayerGroup)
2018-09-11 20:16:08 +02:00
library.add(faTrashAlt)
library.add(faUsers)
library.add(faUser)
library.add(faLock)
library.add(faPen)
2018-11-25 22:02:22 +01:00
library.add(faTimes)
2018-12-25 16:03:51 +01:00
library.add(faTachometerAlt)
library.add(faCalendar)
library.add(faTimesCircle)
library.add(faBars)
library.add(faPowerOff)
library.add(faCalendarWeek)
library.add(faCalendarAlt)
2019-03-03 16:03:08 +01:00
library.add(faExclamation)
2019-03-07 20:48:40 +01:00
library.add(faTags)
2019-04-23 21:50:37 +02:00
library.add(faChevronDown)
2019-04-29 23:41:39 +02:00
library.add(faCheck)
2019-09-09 19:55:43 +02:00
library.add(faPaste)
2019-10-19 21:41:23 +02:00
library.add(faPencilAlt)
2019-11-24 14:16:24 +01:00
library.add(faCloudDownloadAlt)
library.add(faCloudUploadAlt)
library.add(faPercent)
library.add(faStar)
library.add(faAlignLeft)
library.add(faPaperclip)
library.add(faClock)
library.add(faHistory)
library.add(faSearch)
library.add(faCheckDouble)
library.add(faComments)
library.add(faTh)
library.add(faSort)
library.add(faSortUp)
2020-04-18 14:39:56 +02:00
library.add(faList)
Kanban (#118) Add error message when trying to create an invalid new task in a bucket Prevent creation of new buckets if the bucket title is empty Disable deleting a bucket if it's the last one Disable dragging tasks when they are being updated Fix transition when opening tasks Send the user to list view by default Show loading spinner when updating multiple tasks Add loading spinner when moving tasks Add loading animation when bucket is loading / updating etc Add bucket title edit Fix creating new buckets Add loading animation Add removing buckets Fix creating a new bucket after tasks were moved Fix warning about labels on tasks Fix labels on tasks not updating after retrieval from api Fix property width Add closing and mobile design Make the task detail popup look good Move list views Move task detail view in a popup Add link to tasks Add saving the new task position after it was moved Fix creating new bucket Fix creating a new task Cleanup Disable user selection for task cards Fix drag placeholder Add dragging style to task Add placeholder + change animation duration More cleanup Cleanup / docs Working of dragging and dropping tasks Adjust markup and styling for new library Change kanban library to something that works Add basic calculation of new positions Don't try to create empty tasks Add indicator if a task is done Add moving tasks between buckets Make empty buckets a little smaller Add gimmick for button description Fix color Fix scrolling bucket layout Add creating a new bucket Add hiding the task input field Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/118
2020-04-26 01:11:34 +02:00
library.add(faEllipsisV)
library.add(faFilter)
library.add(faFillDrip)
library.add(faKeyboard)
2018-09-09 17:23:06 +02:00
Vue.component('icon', FontAwesomeIcon)
2018-12-25 16:03:51 +01:00
// Tooltip
import VTooltip from 'v-tooltip'
Vue.use(VTooltip)
2019-10-16 20:25:10 +02:00
// PWA
import './registerServiceWorker'
// Shortcuts
import vueShortkey from 'vue-shortkey'
Vue.use(vueShortkey)
2018-12-25 16:03:51 +01:00
// Set focus
Vue.directive('focus', {
// When the bound element is inserted into the DOM...
inserted: el => {
// Focus the element only if the viewport is big enough
// auto focusing elements on mobile can be annoying since in these cases the
// keyboard always pops up and takes half of the available space on the screen.
// The threshhold is the same as the breakpoints in css.
if (window.innerWidth > 769) {
el.focus()
}
2018-12-25 16:03:51 +01:00
}
})
// Mixins
import message from './message'
2020-03-02 21:55:22 +01:00
import {format, formatDistance} from 'date-fns'
import {colorIsDark} from './helpers/colorIsDark'
import {setTitle} from './helpers/setTitle'
Vue.mixin({
methods: {
formatDateSince: date => {
Add easymde & markdown preview for editing descriptions and comments (#183) Make sure no text from previous mounts is left in the editor text field Make preview not the default when rendering descrition settings Add option to show editor by default while still having the option to show preview Add option to show editor by default while still having the option to show preview Use editor component for edit labels Use editor component for edit team Use editor component for edit namespace Use editor component for edit list Use editor component for edit task Make sure we find all checkboxes Fix checking wrong checkbox Make finding and replacing checkboxes in a function actually work Add upading text with checked checkboxes Lazy load editor Remove preview since we have a better one Make easymde smaller by default Add image upload from comments Rename easymde component to editor Only show preview button if editing is currently active Make editor tabs look better when commenting Make comments meta look better Don't try to update if the value was initially set Use editor to render and edit comments Make preview optional Make tabs look better Don't switch to preview after editing Centralize attachment state Render markdown by default Fix title being "null" Fix loading attachment images Add standalone preview Fix callback url Add onsuccess callback Add file upload Fix date parsing once and for all Add more props for upload and such Fix editor border color Fix changing text after mounting Add link to guide Fix sizing of icons Add timeout for changes Add all easymde icons Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/183
2020-07-14 21:26:05 +02:00
if (typeof date === 'string') {
date = new Date(date)
}
const currentDate = new Date()
let formatted = '';
if (date > currentDate) {
formatted += 'in '
}
formatted += formatDistance(date, currentDate)
if(date < currentDate) {
formatted += ' ago'
}
return formatted;
},
Add easymde & markdown preview for editing descriptions and comments (#183) Make sure no text from previous mounts is left in the editor text field Make preview not the default when rendering descrition settings Add option to show editor by default while still having the option to show preview Add option to show editor by default while still having the option to show preview Use editor component for edit labels Use editor component for edit team Use editor component for edit namespace Use editor component for edit list Use editor component for edit task Make sure we find all checkboxes Fix checking wrong checkbox Make finding and replacing checkboxes in a function actually work Add upading text with checked checkboxes Lazy load editor Remove preview since we have a better one Make easymde smaller by default Add image upload from comments Rename easymde component to editor Only show preview button if editing is currently active Make editor tabs look better when commenting Make comments meta look better Don't try to update if the value was initially set Use editor to render and edit comments Make preview optional Make tabs look better Don't switch to preview after editing Centralize attachment state Render markdown by default Fix title being "null" Fix loading attachment images Add standalone preview Fix callback url Add onsuccess callback Add file upload Fix date parsing once and for all Add more props for upload and such Fix editor border color Fix changing text after mounting Add link to guide Fix sizing of icons Add timeout for changes Add all easymde icons Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/frontend/pulls/183
2020-07-14 21:26:05 +02:00
formatDate: date => {
if (typeof date === 'string') {
date = new Date(date)
}
return date ? format(date, 'PPPPpppp'): ''
},
error: (e, context, actions = []) => message.error(e, context, actions),
success: (s, context, actions = []) => message.success(s, context, actions),
colorIsDark: colorIsDark,
setTitle: setTitle,
}
})
// Vuex
import {store} from './store'
2018-08-28 22:50:22 +02:00
new Vue({
router,
store,
render: h => h(App)
2018-08-28 22:50:22 +02:00
}).$mount('#app')