Merge pull request 'vue3' (#815) from vue3 into main

Reviewed-on: vikunja/frontend#815
This commit is contained in:
dpschen 2021-10-17 21:17:04 +00:00
commit ee2c56156b
159 changed files with 4197 additions and 4825 deletions

View File

@ -5,6 +5,7 @@ trigger:
branch: branch:
include: include:
- main - main
- vue3
event: event:
include: include:
- push - push

View File

@ -11,7 +11,7 @@ export class UserFactory extends Factory {
return { return {
id: '{increment}', id: '{increment}',
username: faker.lorem.word(10) + faker.random.uuid(), username: faker.lorem.word(10) + faker.datatype.uuid(),
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.', // 1234 password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.', // 1234
status: 0, status: 0,
created: formatISO(now), created: formatISO(now),

View File

@ -38,8 +38,7 @@ describe('Lists', () => {
.contains('Create') .contains('Create')
.click() .click()
cy.wait(1000) // Waiting until the request to create the new list is done cy.get('.global-notification', { timeout: 1000 }) // Waiting until the request to create the new list is done
cy.get('.global-notification')
.should('contain', 'Success') .should('contain', 'Success')
cy.url() cy.url()
.should('contain', '/lists/') .should('contain', '/lists/')
@ -446,7 +445,7 @@ describe('Lists', () => {
cy.get('.kanban .bucket .tasks .task') cy.get('.kanban .bucket .tasks .task')
.contains(tasks[0].title) .contains(tasks[0].title)
.first() .first()
.drag('.kanban .bucket:nth-child(2) .tasks .dropper div') .drag('.kanban .bucket:nth-child(2) .tasks .dropper')
cy.get('.kanban .bucket:nth-child(2) .tasks') cy.get('.kanban .bucket:nth-child(2) .tasks')
.should('contain', tasks[0].title) .should('contain', tasks[0].title)
@ -501,7 +500,7 @@ describe('Lists', () => {
.first() .first()
.click() .click()
cy.get('.global-notification') cy.get('.global-notification', { timeout: 1000 })
.should('contain', 'Success') .should('contain', 'Success')
cy.go('back') cy.go('back')
cy.get('.kanban .bucket') cy.get('.kanban .bucket')

View File

@ -67,7 +67,7 @@ describe('Namepaces', () => {
.contains('Save') .contains('Save')
.click() .click()
cy.get('.global-notification') cy.get('.global-notification', { timeout: 1000 })
.should('contain', 'Success') .should('contain', 'Success')
cy.get('.namespace-container .menu.namespaces-lists') cy.get('.namespace-container .menu.namespaces-lists')
.should('contain', newNamespaceName) .should('contain', newNamespaceName)

View File

@ -12,7 +12,7 @@ describe('User Settings', () => {
cy.get('input[name=avatarProvider][value=upload]') cy.get('input[name=avatarProvider][value=upload]')
.click() .click()
cy.get('input[type=file]') cy.get('input[type=file]', { timeout: 1000 })
.attachFile('image.jpg') .attachFile('image.jpg')
cy.get('.vue-handler-wrapper.vue-handler-wrapper--south .vue-simple-handler.vue-simple-handler--south') cy.get('.vue-handler-wrapper.vue-handler-wrapper--south .vue-simple-handler.vue-simple-handler--south')
.trigger('mousedown', {which: 1}) .trigger('mousedown', {which: 1})

View File

@ -16,27 +16,32 @@
"browserslist:update": "npx browserslist@latest --update-db" "browserslist:update": "npx browserslist@latest --update-db"
}, },
"dependencies": { "dependencies": {
"@kyvg/vue3-notification": "2.3.4",
"@vue/compat": "3.2.20",
"bulma": "0.9.3", "bulma": "0.9.3",
"camel-case": "4.1.2", "camel-case": "4.1.2",
"codemirror": "^5.63.3",
"copy-to-clipboard": "3.3.1", "copy-to-clipboard": "3.3.1",
"date-fns": "2.25.0", "date-fns": "2.25.0",
"dompurify": "2.3.3", "dompurify": "2.3.3",
"flatpickr": "4.6.9", "easymde": "^2.15.0",
"flatpickr": "^4.6.9",
"highlight.js": "11.3.0", "highlight.js": "11.3.0",
"is-touch-device": "1.0.1", "is-touch-device": "1.0.1",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"marked": "3.0.7", "marked": "3.0.7",
"register-service-worker": "1.7.2", "register-service-worker": "1.7.2",
"snake-case": "3.0.4", "snake-case": "3.0.4",
"ufo": "0.7.9", "ufo": "0.7.9",
"verte": "0.0.12", "vue": "3.2.20",
"vue": "2.6.14", "vue-advanced-cropper": "^2.6.3",
"vue-advanced-cropper": "1.8.2", "vue-drag-resize": "^2.0.3",
"vue-drag-resize": "1.5.4", "vue-flatpickr-component": "9.0.5",
"vue-easymde": "1.4.0", "vue-i18n": "9.2.0-beta.11",
"vue-i18n": "8.26.5", "vue-router": "4.0.12",
"vue-shortkey": "3.1.7", "vuedraggable": "4.0.1",
"vuedraggable": "2.24.3", "vuex": "4.0.2",
"vuex": "3.6.2",
"workbox-precaching": "6.3.0" "workbox-precaching": "6.3.0"
}, },
"devDependencies": { "devDependencies": {
@ -44,13 +49,13 @@
"@fortawesome/fontawesome-svg-core": "1.2.36", "@fortawesome/fontawesome-svg-core": "1.2.36",
"@fortawesome/free-regular-svg-icons": "5.15.4", "@fortawesome/free-regular-svg-icons": "5.15.4",
"@fortawesome/free-solid-svg-icons": "5.15.4", "@fortawesome/free-solid-svg-icons": "5.15.4",
"@fortawesome/vue-fontawesome": "2.0.5", "@fortawesome/vue-fontawesome": "3.0.0-4",
"@types/jest": "27.0.2", "@types/jest": "27.0.2",
"@typescript-eslint/eslint-plugin": "5.0.0", "@typescript-eslint/eslint-plugin": "5.0.0",
"@typescript-eslint/parser": "5.0.0", "@typescript-eslint/parser": "5.0.0",
"@vitejs/plugin-legacy": "1.6.2", "@vitejs/plugin-legacy": "1.6.2",
"@vitejs/plugin-vue": "^1.9.3",
"@vue/eslint-config-typescript": "8.0.0", "@vue/eslint-config-typescript": "8.0.0",
"@vue/runtime-dom": "latest",
"autoprefixer": "10.3.7", "autoprefixer": "10.3.7",
"axios": "0.23.0", "axios": "0.23.0",
"browserslist": "4.17.4", "browserslist": "4.17.4",
@ -70,11 +75,6 @@
"typescript": "4.4.4", "typescript": "4.4.4",
"vite": "2.6.7", "vite": "2.6.7",
"vite-plugin-pwa": "0.11.3", "vite-plugin-pwa": "0.11.3",
"vite-plugin-vue2": "1.9.0",
"vue-flatpickr-component": "8.1.7",
"vue-notification": "1.3.20",
"vue-router": "3.5.2",
"vue-template-compiler": "2.6.14",
"wait-on": "6.0.0", "wait-on": "6.0.0",
"workbox-cli": "6.3.0" "workbox-cli": "6.3.0"
}, },
@ -87,7 +87,7 @@
}, },
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:vue/essential", "plugin:vue/vue3-essential",
"@vue/typescript" "@vue/typescript"
], ],
"rules": { "rules": {

View File

@ -23,6 +23,7 @@
</template> </template>
<script> <script>
import {defineComponent} from 'vue'
import {mapState, mapGetters} from 'vuex' import {mapState, mapGetters} from 'vuex'
import isTouchDevice from 'is-touch-device' import isTouchDevice from 'is-touch-device'
@ -33,10 +34,10 @@ import TopNavigation from './components/home/topNavigation'
import ContentAuth from './components/home/contentAuth' import ContentAuth from './components/home/contentAuth'
import ContentLinkShare from './components/home/contentLinkShare' import ContentLinkShare from './components/home/contentLinkShare'
import ContentNoAuth from './components/home/contentNoAuth' import ContentNoAuth from './components/home/contentNoAuth'
import {setLanguage} from './i18n/setup' import {setLanguage} from './i18n'
import AccountDeleteService from '@/services/accountDelete' import AccountDeleteService from '@/services/accountDelete'
export default { export default defineComponent({
name: 'app', name: 'app',
components: { components: {
ContentNoAuth, ContentNoAuth,
@ -53,6 +54,7 @@ export default {
this.setupAccountDeletionVerification() this.setupAccountDeletionVerification()
}, },
beforeCreate() { beforeCreate() {
// FIXME: async action in beforeCreate, might be not finished when component mounts
this.$store.dispatch('config/update') this.$store.dispatch('config/update')
.then(() => { .then(() => {
this.$store.dispatch('auth/checkAuth') this.$store.dispatch('auth/checkAuth')
@ -87,30 +89,31 @@ export default {
window.addEventListener('offline', () => this.$store.commit(ONLINE, navigator.onLine)) window.addEventListener('offline', () => this.$store.commit(ONLINE, navigator.onLine))
}, },
setupPasswortResetRedirect() { setupPasswortResetRedirect() {
if (typeof this.$route.query.userPasswordReset !== 'undefined') { if (typeof this.$route.query.userPasswordReset === 'undefined') {
localStorage.removeItem('passwordResetToken') // Delete an eventually preexisting old token return
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
this.$router.push({name: 'user.password-reset.reset'})
} }
localStorage.setItem('passwordResetToken', this.$route.query.userPasswordReset)
this.$router.push({name: 'user.password-reset.reset'})
}, },
setupEmailVerificationRedirect() { setupEmailVerificationRedirect() {
if (typeof this.$route.query.userEmailConfirm !== 'undefined') { if (typeof this.$route.query.userEmailConfirm === 'undefined') {
localStorage.removeItem('emailConfirmToken') // Delete an eventually preexisting old token return
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
this.$router.push({name: 'user.login'})
} }
localStorage.setItem('emailConfirmToken', this.$route.query.userEmailConfirm)
this.$router.push({name: 'user.login'})
}, },
setupAccountDeletionVerification() { async setupAccountDeletionVerification() {
if (typeof this.$route.query.accountDeletionConfirm !== 'undefined') { if (typeof this.$route.query.accountDeletionConfirm === 'undefined') {
const accountDeletionService = new AccountDeleteService() return
accountDeletionService.confirm(this.$route.query.accountDeletionConfirm)
.then(() => {
this.$message.success({message: this.$t('user.deletion.confirmSuccess')})
this.$store.dispatch('auth/refreshUserInfo')
})
.catch(e => this.$message.error(e))
} }
const accountDeletionService = new AccountDeleteService()
await accountDeletionService.confirm(this.$route.query.accountDeletionConfirm)
this.$message.success({message: this.$t('user.deletion.confirmSuccess')})
this.$store.dispatch('auth/refreshUserInfo')
}, },
}, },
} })
</script> </script>

View File

@ -22,9 +22,11 @@
<router-view/> <router-view/>
<transition name="modal"> <router-view name="popup" v-slot="{ Component }">
<router-view name="popup"/> <transition name="modal">
</transition> <component :is="Component" />
</transition>
</router-view>
<a <a
class="keyboard-shortcuts-button" class="keyboard-shortcuts-button"
@ -84,7 +86,7 @@ export default {
this.$route.name === 'user.settings' || this.$route.name === 'user.settings' ||
this.$route.name === 'namespaces.index' this.$route.name === 'namespaces.index'
) { ) {
this.$store.commit(CURRENT_LIST, null) return this.$store.dispatch(CURRENT_LIST, null)
} }
}, },
renewTokenOnFocus() { renewTokenOnFocus() {
@ -126,9 +128,6 @@ export default {
}, },
loadLabels() { loadLabels() {
this.$store.dispatch('labels/loadAllLabels') this.$store.dispatch('labels/loadAllLabels')
.catch(e => {
this.$message.error(e)
})
}, },
}, },
} }

View File

@ -40,11 +40,5 @@ export default {
currentList: CURRENT_LIST, currentList: CURRENT_LIST,
background: 'background', background: 'background',
}), }),
methods: {
logout() {
this.$store.dispatch('auth/logout')
this.$router.push({name: 'user.login'})
},
},
} }
</script> </script>

View File

@ -28,12 +28,23 @@ export default {
logoUrl, logoUrl,
} }
}, },
created() { computed: {
this.redirectToHome() routeName() {
return this.$route.name
},
...mapState({
motd: state => state.config.motd,
}),
},
watch: {
routeName: {
handler(routeName) {
if (!routeName) return
this.redirectToHome()
},
immediate: true,
},
}, },
computed: mapState({
motd: state => state.config.motd,
}),
methods: { methods: {
redirectToHome() { redirectToHome() {
// Check if the user is already logged in and redirect them to the home page if not // Check if the user is already logged in and redirect them to the home page if not

View File

@ -49,19 +49,19 @@
</div> </div>
<aside class="menu namespaces-lists loader-container" :class="{'is-loading': loading}"> <aside class="menu namespaces-lists loader-container" :class="{'is-loading': loading}">
<template v-for="(n, nk) in namespaces"> <template v-for="(n, nk) in namespaces" :key="n.id" >
<div :key="n.id" class="namespace-title" :class="{'has-menu': n.id > 0}"> <div class="namespace-title" :class="{'has-menu': n.id > 0}">
<span <span
@click="toggleLists(n.id)" @click="toggleLists(n.id)"
class="menu-label" class="menu-label"
v-tooltip="getNamespaceTitle(n) + ' (' + n.lists.filter(l => !l.isArchived).length + ')'"> v-tooltip="namespaceTitles[nk]">
<span class="name"> <span class="name">
<span <span
:style="{ backgroundColor: n.hexColor }" :style="{ backgroundColor: n.hexColor }"
class="color-bubble" class="color-bubble"
v-if="n.hexColor !== ''"> v-if="n.hexColor !== ''">
</span> </span>
{{ getNamespaceTitle(n) }} ({{ n.lists.filter(l => !l.isArchived).length }}) {{ namespaceTitles[nk] }}
</span> </span>
</span> </span>
<a <a
@ -84,56 +84,65 @@
--> -->
<draggable <draggable
v-bind="dragOptions" v-bind="dragOptions"
:value="activeLists[nk]" :modelValue="activeLists[nk]"
@input="(lists) => updateActiveLists(n, lists)" @update:modelValue="(lists) => updateActiveLists(n, lists)"
:group="`namespace-${n.id}-lists`" :group="`namespace-${n.id}-lists`"
@start="() => drag = true" @start="() => drag = true"
@end="e => saveListPosition(e, nk)" @end="e => saveListPosition(e, nk)"
handle=".handle" handle=".handle"
:disabled="n.id < 0" :disabled="n.id < 0 || null"
:class="{'dragging-disabled': n.id < 0}" tag="transition-group"
item-key="id"
:component-data="{
type: 'transition',
tag: 'ul',
name: !drag ? 'flip-list' : null,
class: [
'menu-list can-be-hidden',
{ 'dragging-disabled': n.id < 0 }
]
}"
> >
<transition-group <template #item="{element: l}">
type="transition"
:name="!drag ? 'flip-list' : null"
tag="ul"
class="menu-list can-be-hidden"
>
<li <li
v-for="l in activeLists[nk]"
:key="l.id"
class="loader-container" class="loader-container"
:class="{'is-loading': listUpdating[l.id]}" :class="{'is-loading': listUpdating[l.id]}"
> >
<router-link <router-link
class="list-menu-link"
:class="{'router-link-exact-active': currentList.id === l.id}"
:to="{ name: 'list.index', params: { listId: l.id} }" :to="{ name: 'list.index', params: { listId: l.id} }"
tag="span" v-slot="{ href, navigate, isActive }"
custom
> >
<span class="icon handle"> <a
<icon icon="grip-lines"/> @click="navigate"
</span> :href="href"
<span class="list-menu-link"
:style="{ backgroundColor: l.hexColor }" :class="{'router-link-exact-active': isActive || currentList?.id === l.id}"
class="color-bubble" >
v-if="l.hexColor !== ''"> <span class="icon handle">
</span> <icon icon="grip-lines"/>
<span class="list-menu-title"> </span>
{{ getListTitle(l) }} <span
</span> :style="{ backgroundColor: l.hexColor }"
<span class="color-bubble"
:class="{'is-favorite': l.isFavorite}" v-if="l.hexColor !== ''">
@click.stop="toggleFavoriteList(l)" </span>
class="favorite"> <span class="list-menu-title">
<icon icon="star" v-if="l.isFavorite"/> {{ getListTitle(l) }}
<icon :icon="['far', 'star']" v-else/> </span>
</span> <span
:class="{'is-favorite': l.isFavorite}"
@click.prevent.stop="toggleFavoriteList(l)"
class="favorite">
<icon icon="star" v-if="l.isFavorite"/>
<icon :icon="['far', 'star']" v-else/>
</span>
</a>
</router-link> </router-link>
<list-settings-dropdown :list="l" v-if="l.id > 0"/> <list-settings-dropdown :list="l" v-if="l.id > 0"/>
<span class="list-setting-spacer" v-else></span> <span class="list-setting-spacer" v-else></span>
</li> </li>
</transition-group> </template>
</draggable> </draggable>
</div> </div>
</template> </template>
@ -182,15 +191,22 @@ export default {
loading: state => state[LOADING] && state[LOADING_MODULE] === 'namespaces', loading: state => state[LOADING] && state[LOADING_MODULE] === 'namespaces',
}), }),
activeLists() { activeLists() {
return this.namespaces.map(({lists}) => lists.filter(item => !item.isArchived)) return this.namespaces.map(({lists}) => lists?.filter(item => !item.isArchived))
},
namespaceTitles() {
return this.namespaces.map((namespace, index) => {
const title = this.getNamespaceTitle(namespace)
return `${title} (${this.activeLists[index]?.length ?? 0})`
})
}, },
}, },
beforeCreate() { beforeCreate() {
// FIXME: async action in beforeCreate, might be unfinished when component mounts
this.$store.dispatch('namespaces/loadNamespaces') this.$store.dispatch('namespaces/loadNamespaces')
.then(namespaces => { .then(namespaces => {
namespaces.forEach(n => { namespaces.forEach(n => {
if (typeof this.listsVisible[n.id] === 'undefined') { if (typeof this.listsVisible[n.id] === 'undefined') {
this.$set(this.listsVisible, n.id, true) this.listsVisible[n.id] = true
} }
}) })
}) })
@ -209,18 +225,13 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.$message.error(e))
}, },
resize() { resize() {
// Hide the menu by default on mobile // Hide the menu by default on mobile
if (window.innerWidth < 770) { this.$store.commit(MENU_ACTIVE, window.innerWidth >= 770)
this.$store.commit(MENU_ACTIVE, false)
} else {
this.$store.commit(MENU_ACTIVE, true)
}
}, },
toggleLists(namespaceId) { toggleLists(namespaceId) {
this.$set(this.listsVisible, namespaceId, !this.listsVisible[namespaceId] ?? false) this.listsVisible[namespaceId] = !this.listsVisible[namespaceId]
}, },
updateActiveLists(namespace, activeLists) { updateActiveLists(namespace, activeLists) {
// this is a bit hacky: since we do have to filter out the archived items from the list // this is a bit hacky: since we do have to filter out the archived items from the list
@ -240,26 +251,25 @@ export default {
this.$store.commit('namespaces/setNamespaceById', newNamespace) this.$store.commit('namespaces/setNamespaceById', newNamespace)
}, },
saveListPosition(e, namespaceIndex) {
async saveListPosition(e, namespaceIndex) {
const listsActive = this.activeLists[namespaceIndex] const listsActive = this.activeLists[namespaceIndex]
const list = listsActive[e.newIndex] const list = listsActive[e.newIndex]
const listBefore = listsActive[e.newIndex - 1] ?? null const listBefore = listsActive[e.newIndex - 1] ?? null
const listAfter = listsActive[e.newIndex + 1] ?? null const listAfter = listsActive[e.newIndex + 1] ?? null
this.$set(this.listUpdating, list.id, true) this.listUpdating[list.id] = true
const position = calculateItemPosition(listBefore !== null ? listBefore.position : null, listAfter !== null ? listAfter.position : null) const position = calculateItemPosition(listBefore !== null ? listBefore.position : null, listAfter !== null ? listAfter.position : null)
// create a copy of the list in order to not violate vuex mutations try {
this.$store.dispatch('lists/updateList', { // create a copy of the list in order to not violate vuex mutations
...list, await this.$store.dispatch('lists/updateList', {
position, ...list,
}) position,
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.$set(this.listUpdating, list.id, false)
}) })
} finally {
this.listUpdating[list.id] = false
}
}, },
}, },
} }

View File

@ -0,0 +1,12 @@
import { defineAsyncComponent } from 'vue'
import ErrorComponent from '@/components/misc/error.vue'
import LoadingComponent from '@/components/misc/loading.vue'
const Editor = () => import('@/components/input/editor.vue')
export default defineAsyncComponent({
loader: Editor,
loadingComponent: LoadingComponent,
errorComponent: ErrorComponent,
timeout: 60000,
})

View File

@ -52,6 +52,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['click'],
computed: { computed: {
showIconOnly() { showIconOnly() {
return this.icon !== '' && typeof this.$slots.default === 'undefined' return this.icon !== '' && typeof this.$slots.default === 'undefined'

View File

@ -1,31 +1,43 @@
<template> <template>
<div class="color-picker-container"> <div class="color-picker-container">
<verte <datalist :id="colorListID">
:showHistory="true" <option v-for="color in defaultColors" :key="color" :value="color" />
:colorHistory="[ </datalist>
'#1973ff',
'#7F23FF', <div class="picker">
'#ff4136', <input
'#ff851b', class="picker__input"
'#ffeb10', type="color"
'#00db60', v-model="color"
]" :list="colorListID"
:enableAlpha="false" :class="{'is-empty': isEmpty}"
:menuPosition="menuPosition" />
:rgbSliders="true" <svg class="picker__pattern" v-show="isEmpty" viewBox="0 0 22 22" fill="fff">
model="hex" <pattern id="checker" width="11" height="11" patternUnits="userSpaceOnUse" fill="FFF">
picker="square" <rect fill="#cccccc" x="0" width="5.5" height="5.5" y="0"></rect>
v-model="color" <rect fill="#cccccc" x="5.5" width="5.5" height="5.5" y="5.5"></rect>
:class="{'is-empty': empty}" </pattern>
/> <rect width="22" height="22" fill="url(#checker)"></rect>
<x-button @click="reset" class="is-small ml-2" :shadow="false" type="secondary"> </svg>
</div>
<x-button :disabled="isEmpty" @click="reset" class="is-small ml-2" :shadow="false" type="secondary">
{{ $t('input.resetColor') }} {{ $t('input.resetColor') }}
</x-button> </x-button>
</div> </div>
</template> </template>
<script> <script>
import verte from 'verte' import {createRandomID} from '@/helpers/randomId'
const DEFAULT_COLORS = [
'#1973ff',
'#7F23FF',
'#ff4136',
'#ff851b',
'#ffeb10',
'#00db60',
]
export default { export default {
name: 'colorPicker', name: 'colorPicker',
@ -33,13 +45,12 @@ export default {
return { return {
color: '', color: '',
lastChangeTimeout: null, lastChangeTimeout: null,
defaultColors: DEFAULT_COLORS,
colorListID: createRandomID(),
} }
}, },
components: {
verte,
},
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
menuPosition: { menuPosition: {
@ -47,10 +58,11 @@ export default {
default: 'top', default: 'top',
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(modelValue) {
this.color = value this.color = modelValue
}, },
immediate: true, immediate: true,
}, },
@ -59,14 +71,14 @@ export default {
}, },
}, },
computed: { computed: {
empty() { isEmpty() {
return this.color === '#000000' || this.color === '' return this.color === '#000000' || this.color === ''
}, },
}, },
methods: { methods: {
update(force = false) { update(force = false) {
if(this.empty && !force) { if(this.isEmpty && !force) {
return return
} }
@ -75,7 +87,7 @@ export default {
} }
this.lastChangeTimeout = setTimeout(() => { this.lastChangeTimeout = setTimeout(() => {
this.$emit('input', this.color) this.$emit('update:modelValue', this.color)
this.$emit('change') this.$emit('change')
}, 500) }, 500)
}, },
@ -87,18 +99,4 @@ export default {
}, },
}, },
} }
</script> </script>
<style lang="scss">
@import 'verte/dist/verte.css';
.verte.is-empty {
.verte__icon {
opacity: 0;
}
.verte__guide {
background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAGklEQVQYlWM4c+bMf3TMgA0MBYWDzDkUKQQAlHCpV9ycHeMAAAAASUVORK5CYII=);
}
}
</style>

View File

@ -112,6 +112,7 @@
<script> <script>
import flatPickr from 'vue-flatpickr-component' import flatPickr from 'vue-flatpickr-component'
import 'flatpickr/dist/flatpickr.css' import 'flatpickr/dist/flatpickr.css'
import { i18n } from '@/i18n'
import {format} from 'date-fns' import {format} from 'date-fns'
import {calculateDayInterval} from '@/helpers/time/calculateDayInterval' import {calculateDayInterval} from '@/helpers/time/calculateDayInterval'
@ -136,13 +137,13 @@ export default {
flatPickr, flatPickr,
}, },
props: { props: {
value: { modelValue: {
validator: prop => prop instanceof Date || prop === null || typeof prop === 'string', validator: prop => prop instanceof Date || prop === null || typeof prop === 'string',
}, },
chooseDateLabel: { chooseDateLabel: {
type: String, type: String,
default() { default() {
return this.$t('input.datepicker.chooseDate') return i18n.global.t('input.datepicker.chooseDate')
}, },
}, },
disabled: { disabled: {
@ -150,14 +151,15 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change', 'close', 'close-on-change'],
mounted() { mounted() {
document.addEventListener('click', this.hideDatePopup) document.addEventListener('click', this.hideDatePopup)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hideDatePopup) document.removeEventListener('click', this.hideDatePopup)
}, },
watch: { watch: {
value: { modelValue: {
handler: 'setDateValue', handler: 'setDateValue',
immediate: true, immediate: true,
}, },
@ -191,7 +193,7 @@ export default {
}, },
updateData() { updateData() {
this.changed = true this.changed = true
this.$emit('input', this.date) this.$emit('update:modelValue', this.date)
this.$emit('change', this.date) this.$emit('change', this.date)
}, },
toggleDatePopup() { toggleDatePopup() {

View File

@ -5,7 +5,7 @@
<vue-easymde <vue-easymde
:configs="config" :configs="config"
@change="bubble" @change="bubble"
@input="handleInput" @update:modelValue="handleInput"
class="content" class="content"
v-if="isEditActive" v-if="isEditActive"
v-model="text"/> v-model="text"/>
@ -21,12 +21,10 @@
</p> </p>
<ul class="actions" v-if="bottomActions.length > 0"> <ul class="actions" v-if="bottomActions.length > 0">
<template v-if="isEditEnabled && !showPreviewText && showSave"> <li v-if="isEditEnabled && !showPreviewText && showSave">
<li> <a v-if="showEditButton" @click="toggleEdit">{{ $t('input.editor.edit') }}</a>
<a v-if="showEditButton" @click="toggleEdit">{{ $t('input.editor.edit') }}</a> <a v-else-if="isEditActive" @click="toggleEdit" class="done-edit">{{ $t('misc.save') }}</a>
<a v-else-if="isEditActive" @click="toggleEdit" class="done-edit">{{ $t('misc.save') }}</a> </li>
</li>
</template>
<li v-for="(action, k) in bottomActions" :key="k"> <li v-for="(action, k) in bottomActions" :key="k">
<a @click="action.action">{{ action.title }}</a> <a @click="action.action">{{ action.title }}</a>
</li> </li>
@ -45,15 +43,17 @@
</template> </template>
<script> <script>
import VueEasymde from 'vue-easymde' import VueEasymde from './vue-easymde/vue-easymde.vue'
import EasyMDE from 'easymde'
import marked from 'marked' import marked from 'marked'
import DOMPurify from 'dompurify' import DOMPurify from 'dompurify'
import hljs from 'highlight.js/lib/common' import hljs from 'highlight.js/lib/common'
import {createEasyMDEConfig} from './editorConfig'
import AttachmentModel from '../../models/attachment' import AttachmentModel from '../../models/attachment'
import AttachmentService from '../../services/attachment' import AttachmentService from '../../services/attachment'
import {findCheckboxesInText} from '../../helpers/checklistFromText' import {findCheckboxesInText} from '../../helpers/checklistFromText'
import {createRandomID} from '@/helpers/randomId'
export default { export default {
name: 'editor', name: 'editor',
@ -61,7 +61,7 @@ export default {
VueEasymde, VueEasymde,
}, },
props: { props: {
value: { modelValue: {
type: String, type: String,
default: '', default: '',
}, },
@ -71,9 +71,7 @@ export default {
}, },
uploadEnabled: { uploadEnabled: {
type: Boolean, type: Boolean,
default() { default: false,
return false
},
}, },
uploadCallback: { uploadCallback: {
type: Function, type: Function,
@ -94,13 +92,14 @@ export default {
}, },
emptyText: { emptyText: {
type: String, type: String,
default: () => '', default: '',
}, },
showSave: { showSave: {
type: Boolean, type: Boolean,
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
computed: { computed: {
showPreviewText() { showPreviewText() {
return this.isPreviewActive && this.text === '' && this.emptyText !== '' return this.isPreviewActive && this.text === '' && this.emptyText !== ''
@ -119,154 +118,30 @@ export default {
preview: '', preview: '',
attachmentService: null, attachmentService: null,
loadedAttachments: {}, loadedAttachments: {},
config: createEasyMDEConfig({
config: {
autoDownloadFontAwesome: false,
spellChecker: false,
placeholder: this.placeholder, placeholder: this.placeholder,
uploadImage: this.uploadEnabled, uploadImage: this.uploadEnabled,
imageUploadFunction: this.uploadCallback, imageUploadFunction: this.uploadCallback,
minHeight: '150px', }),
toolbar: [ checkboxId: createRandomID(),
{
name: 'heading-1',
action: EasyMDE.toggleHeading1,
title: this.$t('input.editor.heading1'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-2',
action: EasyMDE.toggleHeading2,
title: this.$t('input.editor.heading2'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-3',
action: EasyMDE.toggleHeading3,
title: this.$t('input.editor.heading3'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-smaller',
action: EasyMDE.toggleHeadingSmaller,
title: this.$t('input.editor.headingSmaller'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-bigger',
action: EasyMDE.toggleHeadingBigger,
title: this.$t('input.editor.headingBigger'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
'|',
{
name: 'bold',
action: EasyMDE.toggleBold,
title: this.$t('input.editor.bold'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 3H6.5H15.25C18.15 3 20.5 5.36 20.5 8.25C20.5 9.8 19.81 11.19 18.73 12.15C20.37 13.04 21.5 14.76 21.5 16.75C21.5 19.64 19.15 22 16.25 22H6.5H3.5C2.95 22 2.5 21.55 2.5 21C2.5 20.45 2.95 20 3.5 20H5.5V5H3.5C2.95 5 2.5 4.55 2.5 4C2.5 3.45 2.95 3 3.5 3ZM7.5 20H16.25C18.04 20 19.5 18.54 19.5 16.75C19.5 14.96 18.04 13.5 16.25 13.5H7.5V20ZM7.5 11.5H15.25C17.04 11.5 18.5 10.04 18.5 8.25C18.5 6.46 17.04 5 15.25 5H7.5V11.5Z"/></svg>',
},
{
name: 'italic',
action: EasyMDE.toggleItalic,
title: this.$t('input.editor.italic'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14.0967 4.2H17.0001C17.3301 4.2 17.6001 3.93 17.6001 3.6C17.6001 3.27 17.3301 3 17.0001 3H10.2001C9.8701 3 9.6001 3.27 9.6001 3.6C9.6001 3.93 9.8701 4.2 10.2001 4.2H12.8748L9.90335 19.8H6.9999C6.6699 19.8 6.3999 20.07 6.3999 20.4C6.3999 20.73 6.6699 21 6.9999 21H13.7999C14.1299 21 14.3999 20.73 14.3999 20.4C14.3999 20.07 14.1299 19.8 13.7999 19.8H11.1253L14.0967 4.2Z"/></svg>',
},
{
name: 'strikethrough',
action: EasyMDE.toggleStrikethrough,
title: this.$t('input.editor.strikethrough'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.25 7.17005C18.25 7.50005 17.98 7.77005 17.65 7.77005C17.32 7.77005 17.05 7.50005 17.05 7.17005V5.96005C15.97 5.12005 14.17 4.56005 12.79 4.31005C11.1 4.00005 9.51 4.30005 8.41 5.12005C7.2 6.03005 6.67 7.67005 7.19 8.88005C7.56 9.73005 8.37 10.31 8.98 10.64C9.57215 10.9644 10.1961 11.2013 10.8465 11.3999H20.4C20.73 11.3999 21 11.6699 21 11.9999C21 12.3299 20.73 12.5999 20.4 12.5999H15.3012C16.6583 13.0929 17.5255 13.7765 17.95 14.69C18.73 16.36 17.74 18.33 16.36 19.41C15.05 20.4401 13.35 21 11.54 21H11.16C9.78 20.9401 8.34 20.5301 6.95 19.85V20.3601C6.95 20.6901 6.68 20.96 6.35 20.96C6.02 20.96 5.75 20.6901 5.75 20.3601V17.36C5.75 17.03 6.02 16.76 6.35 16.76C6.68 16.76 6.95 17.03 6.95 17.36V18.5C8.35 19.2801 9.81 19.74 11.21 19.8C12.86 19.89 14.46 19.39 15.62 18.48C16.6 17.71 17.37 16.3 16.86 15.21C16.55 14.54 15.8 14.0201 14.58 13.63C13.9711 13.4331 13.3222 13.2762 12.6906 13.1235C12.6168 13.1056 12.5432 13.0878 12.47 13.07C12.4313 13.0607 12.3925 13.0514 12.3537 13.0421C11.7861 12.9055 11.2108 12.767 10.6413 12.5999H3.6C3.27 12.5999 3 12.3299 3 11.9999C3 11.6699 3.27 11.3999 3.6 11.3999H7.90288C7.04984 10.8343 6.42752 10.1363 6.09 9.36005C5.34 7.63005 6.03 5.40005 7.69 4.16005C9.05 3.15005 10.99 2.77005 13 3.13005C13.64 3.25005 15.53 3.66005 17.05 4.53005V4.17005C17.05 3.84005 17.32 3.57005 17.65 3.57005C17.98 3.57005 18.25 3.84005 18.25 4.17005V7.17005Z"/></svg>',
},
{
name: 'code',
action: EasyMDE.toggleCodeBlock,
title: this.$t('input.editor.code'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M8.57 20.9601C8.64 20.9901 8.71 21.0001 8.78 21.0001C9.02 21.0001 9.24 20.8501 9.34 20.6101L15.79 3.81005C15.9 3.50005 15.75 3.15005 15.44 3.03005C15.14 2.92005 14.79 3.07005 14.67 3.38005L8.22 20.1801C8.11 20.4901 8.26 20.8401 8.57 20.9601ZM7.00007 18.0001C6.85007 18.0001 6.69007 17.9401 6.58007 17.8201L1.18007 12.4201C0.950068 12.1901 0.950068 11.8101 1.18007 11.5701L6.58007 6.17006C6.81007 5.94006 7.19007 5.94006 7.43007 6.17006C7.66007 6.40006 7.66007 6.78006 7.43007 7.02006L2.45007 12.0001L7.43007 16.9801C7.66007 17.2101 7.66007 17.5901 7.43007 17.8301C7.31007 17.9401 7.15007 18.0001 7.00007 18.0001ZM17 18.0001C16.85 18.0001 16.69 17.9401 16.58 17.8201C16.35 17.5901 16.35 17.2101 16.58 16.9701L21.55 12.0001L16.57 7.02006C16.34 6.79006 16.34 6.41006 16.57 6.17006C16.81 5.94006 17.19 5.94006 17.42 6.17006L22.82 11.5701C23.05 11.8001 23.05 12.1801 22.82 12.4201L17.42 17.8201C17.31 17.9401 17.15 18.0001 17 18.0001Z"/></svg>',
},
{
name: 'quote',
action: EasyMDE.toggleBlockquote,
title: this.$t('input.editor.quote'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.373 5.16357H5.62695C4.79102 5.16357 4.11133 5.84326 4.11133 6.6792V16.2095C4.11133 17.0464 4.79102 17.7261 5.62695 17.7261H6.8877V21.1245C6.8877 21.3667 7.0332 21.5854 7.25684 21.6782C7.33203 21.7095 7.41016 21.7241 7.4873 21.7241C7.64258 21.7241 7.7959 21.6636 7.91113 21.5493L11.748 17.7261H19.373C20.209 17.7261 20.8887 17.0464 20.8887 16.2095V6.6792C20.8887 5.84326 20.209 5.16357 19.373 5.16357ZM19.6895 16.2095C19.6895 16.3843 19.5469 16.5269 19.373 16.5269H11.5C11.3408 16.5269 11.1895 16.5894 11.0762 16.7017L8.08691 19.6802V17.1265C8.08691 16.7954 7.81836 16.5269 7.4873 16.5269H5.62695C5.45312 16.5269 5.31055 16.3843 5.31055 16.2095V6.6792C5.31055 6.50537 5.45312 6.36279 5.62695 6.36279H19.373C19.5469 6.36279 19.6895 6.50537 19.6895 6.6792V16.2095ZM10.3431 8.45264C9.46326 8.45264 8.75 9.16589 8.75 10.0458C8.75 10.9257 9.46326 11.639 10.3431 11.639C10.4775 11.639 10.6058 11.6173 10.7305 11.5861V11.6195C10.7305 12.1322 10.3135 12.5492 9.75586 12.5492C9.4248 12.5492 9.17871 12.8177 9.17871 13.1488C9.17871 13.4799 9.46973 13.7484 9.80078 13.7484C10.9746 13.7484 11.9297 12.7933 11.9297 11.6195V10.1176L11.9294 10.1165L11.9292 10.1155C11.9297 10.1049 11.9312 10.0946 11.9326 10.0843L11.9326 10.0843C11.9345 10.0716 11.9363 10.059 11.9363 10.0458C11.9363 9.16589 11.223 8.45264 10.3431 8.45264ZM13.0637 10.0458C13.0637 9.16589 13.7771 8.45264 14.657 8.45264C15.5369 8.45264 16.2501 9.16589 16.2501 10.0458C16.2501 10.0584 16.2484 10.0706 16.2466 10.0828C16.2452 10.0929 16.2437 10.103 16.2433 10.1134C16.2433 10.1149 16.2441 10.1161 16.2441 10.1176V11.6195C16.2441 12.7933 15.2891 13.7484 14.1152 13.7484C13.7842 13.7484 13.4922 13.4799 13.4922 13.1488C13.4922 12.8177 13.7383 12.5492 14.0693 12.5492C14.6279 12.5492 15.0449 12.1322 15.0449 11.6195V11.5858C14.9202 11.6173 14.7915 11.639 14.657 11.639C13.7771 11.639 13.0637 10.9257 13.0637 10.0458Z"/></svg>',
},
{
name: 'unordered-list',
action: EasyMDE.toggleUnorderedList,
title: this.$t('input.editor.unorderedList'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6.5281 3.7002H3.5281C3.1981 3.7002 2.9281 3.9702 2.9281 4.3002V7.3002C2.9281 7.6302 3.1981 7.9002 3.5281 7.9002H6.5281C6.8581 7.9002 7.1281 7.6302 7.1281 7.3002V4.3002C7.1281 3.9702 6.8581 3.7002 6.5281 3.7002ZM5.9281 6.7002H4.1281V4.9002H5.9281V6.7002ZM3.5281 9.90015H6.5281C6.8581 9.90015 7.1281 10.1701 7.1281 10.5001V13.5001C7.1281 13.8301 6.8581 14.1001 6.5281 14.1001H3.5281C3.1981 14.1001 2.9281 13.8301 2.9281 13.5001V10.5001C2.9281 10.1701 3.1981 9.90015 3.5281 9.90015ZM4.1281 12.9001H5.9281V11.1001H4.1281V12.9001ZM3.5281 16.1001H6.5281C6.8581 16.1001 7.1281 16.3701 7.1281 16.7001V19.7001C7.1281 20.0301 6.8581 20.3001 6.5281 20.3001H3.5281C3.1981 20.3001 2.9281 20.0301 2.9281 19.7001V16.7001C2.9281 16.3701 3.1981 16.1001 3.5281 16.1001ZM4.1281 19.1001H5.9281V17.3001H4.1281V19.1001ZM9.72817 6.4002H20.7282C21.0582 6.4002 21.3282 6.1302 21.3282 5.8002C21.3282 5.4702 21.0582 5.2002 20.7282 5.2002H9.72817C9.39817 5.2002 9.12817 5.4702 9.12817 5.8002C9.12817 6.1302 9.39817 6.4002 9.72817 6.4002ZM9.72817 11.4001H20.7282C21.0582 11.4001 21.3282 11.6701 21.3282 12.0001C21.3282 12.3301 21.0582 12.6001 20.7282 12.6001H9.72817C9.39817 12.6001 9.12817 12.3301 9.12817 12.0001C9.12817 11.6701 9.39817 11.4001 9.72817 11.4001ZM9.72817 17.6001H20.7282C21.0582 17.6001 21.3282 17.8701 21.3282 18.2001C21.3282 18.5301 21.0582 18.8001 20.7282 18.8001H9.72817C9.39817 18.8001 9.12817 18.5301 9.12817 18.2001C9.12817 17.8701 9.39817 17.6001 9.72817 17.6001Z"/></svg>',
},
{
name: 'ordered-list',
action: EasyMDE.toggleOrderedList,
title: this.$t('input.editor.orderedList'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M4.19494 8.29994H5.99494C6.26494 8.29994 6.49494 8.07995 6.49494 7.79994C6.49494 7.51995 6.27494 7.29994 5.99494 7.29994H5.59494V3.79994C5.59494 3.62994 5.50494 3.46994 5.36494 3.37994C5.22494 3.28994 5.04494 3.26994 4.89494 3.33994L3.89494 3.76994C3.64494 3.87994 3.52494 4.17994 3.63494 4.42994C3.74494 4.67994 4.03494 4.79994 4.29494 4.68994L4.59494 4.55994V7.29994H4.19494C3.91494 7.29994 3.69494 7.51995 3.69494 7.79994C3.69494 8.07995 3.91494 8.29994 4.19494 8.29994ZM20.195 6.39995H9.19497C8.86497 6.39995 8.59497 6.12995 8.59497 5.79995C8.59497 5.46995 8.86497 5.19995 9.19497 5.19995H20.195C20.525 5.19995 20.795 5.46995 20.795 5.79995C20.795 6.12995 20.525 6.39995 20.195 6.39995ZM3.78486 14.36H6.37486C6.65486 14.36 6.87486 14.14 6.87486 13.86C6.87486 13.58 6.65486 13.36 6.37486 13.36H4.88486C5.00486 13.23 5.12486 13.09 5.23486 12.95C5.26626 12.9151 5.29645 12.8802 5.32626 12.8458L5.32629 12.8457C5.38192 12.7814 5.43627 12.7186 5.49486 12.66C5.73486 12.4 5.98486 12.12 6.17486 11.79C6.47486 11.25 6.41486 10.63 6.01486 10.17C5.57486 9.66 4.86486 9.5 4.24486 9.74C3.74486 9.95 3.39486 10.35 3.22486 10.91C3.14486 11.18 3.29486 11.46 3.56486 11.54C3.82486 11.61 4.10486 11.46 4.18486 11.2C4.29486 10.85 4.48486 10.73 4.62486 10.67C4.88486 10.57 5.13486 10.68 5.26486 10.82C5.38486 10.96 5.40486 11.12 5.30486 11.29C5.17595 11.5202 4.99618 11.7165 4.80458 11.9257L4.75486 11.98C4.67298 12.0801 4.58283 12.1801 4.49946 12.2727L4.49945 12.2727L4.47486 12.3C4.12486 12.72 3.76486 13.13 3.40486 13.53C3.27486 13.68 3.23486 13.9 3.32486 14.07C3.41486 14.24 3.58486 14.36 3.78486 14.36ZM3.68486 20.3699C4.04486 20.5899 4.46486 20.6999 4.87486 20.6999C5.13486 20.6999 5.38486 20.6499 5.61486 20.5499C6.31486 20.2799 6.73486 19.5599 6.60486 18.8799C6.53486 18.5499 6.35486 18.2899 6.12486 18.0899C6.32486 17.8999 6.45486 17.6499 6.50486 17.3799C6.57486 17.0099 6.49486 16.6299 6.27486 16.3099C5.85486 15.6899 5.07486 15.5199 4.10486 15.8299C3.83486 15.9199 3.69486 16.1999 3.77486 16.4599C3.86486 16.7299 4.14486 16.8699 4.40486 16.7899C4.70486 16.6999 5.24486 16.5799 5.45486 16.8899C5.51486 16.9899 5.54486 17.0999 5.52486 17.1999C5.51486 17.2699 5.47486 17.3599 5.36486 17.4299C5.26486 17.4999 5.12486 17.5399 4.95486 17.5799L4.77486 17.6299C4.54486 17.6999 4.40486 17.9099 4.41486 18.1499C4.42486 18.3899 4.61486 18.5799 4.84486 18.6099C5.20486 18.6599 5.58486 18.8299 5.63486 19.0799C5.67486 19.2999 5.46486 19.5499 5.25486 19.6299C4.94486 19.7599 4.52486 19.7099 4.21486 19.5199C3.97486 19.3699 3.67486 19.4399 3.52486 19.6799C3.37486 19.9199 3.44486 20.2299 3.68486 20.3699ZM20.195 18.7999H9.19497C8.86497 18.7999 8.59497 18.5299 8.59497 18.1999C8.59497 17.8699 8.86497 17.5999 9.19497 17.5999H20.195C20.525 17.5999 20.795 17.8699 20.795 18.1999C20.795 18.5299 20.525 18.7999 20.195 18.7999ZM9.19497 12.5999H20.195C20.525 12.5999 20.795 12.3299 20.795 11.9999C20.795 11.6699 20.525 11.3999 20.195 11.3999H9.19497C8.86497 11.3999 8.59497 11.6699 8.59497 11.9999C8.59497 12.3299 8.86497 12.5999 9.19497 12.5999Z"/></svg>',
},
'|',
{
name: 'clean-block',
action: EasyMDE.cleanBlock,
title: this.$t('input.editor.cleanBlock'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9.25989 6.18384H20.4513C20.7823 6.18384 21.0509 6.45239 21.0509 6.78345V17.9749C21.0509 18.3059 20.7823 18.5745 20.4513 18.5745H9.25989C9.0929 18.5745 8.93469 18.5061 8.82043 18.384L3.6095 12.7883C3.39563 12.5579 3.39563 12.2004 3.6095 11.97L8.82043 6.37427C8.93469 6.2522 9.0929 6.18384 9.25989 6.18384ZM9.52063 17.3752H19.8517V7.38306H9.52063L4.86926 12.3792L9.52063 17.3752ZM12.7755 15.0686C12.6222 15.0686 12.4679 15.01 12.3517 14.8928C12.1173 14.6584 12.1173 14.2786 12.3517 14.0452L14.0503 12.3469L12.3517 10.6487C12.1173 10.4153 12.1173 10.0354 12.3517 9.80103C12.5841 9.56665 12.965 9.56665 13.1993 9.80103L14.8981 11.4994L16.5968 9.80103C16.8312 9.56665 17.212 9.56665 17.4445 9.80103C17.6788 10.0354 17.6788 10.4153 17.4445 10.6487L15.7458 12.3469L17.4445 14.0452C17.6788 14.2786 17.6788 14.6584 17.4445 14.8928C17.3282 15.01 17.174 15.0686 17.0206 15.0686C16.8673 15.0686 16.714 15.01 16.5968 14.8928L14.8981 13.1945L13.1993 14.8928C13.0822 15.01 12.9288 15.0686 12.7755 15.0686Z"/></svg>',
},
{
name: 'link',
action: EasyMDE.drawLink,
title: this.$t('input.editor.link'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4399 15.3452C11.4999 15.3652 11.5699 15.3752 11.6299 15.3752C11.8799 15.3752 12.1199 15.2152 12.1999 14.9652C12.2999 14.6452 12.1299 14.3052 11.8199 14.2052C11.3499 14.0452 10.9299 13.7852 10.5699 13.4152C10.1999 13.0552 9.9399 12.6452 9.7799 12.1552C9.6599 11.8252 9.5999 11.4652 9.5999 11.0952C9.5999 10.2152 9.9399 9.38518 10.5699 8.75518L15.1599 4.15518C16.4499 2.87518 18.5399 2.87518 19.8299 4.15518C20.4499 4.78518 20.7899 5.61518 20.7899 6.49518C20.7899 7.37518 20.4499 8.20518 19.8299 8.82518L16.7399 11.9052C16.5099 12.1452 16.5099 12.5252 16.7399 12.7552C16.9799 12.9852 17.3599 12.9852 17.5899 12.7552L20.6799 9.67518C21.5299 8.83518 21.9999 7.69518 21.9999 6.49518C21.9999 5.29518 21.5299 4.16518 20.6899 3.30518C18.9299 1.55518 16.0799 1.55518 14.3199 3.30518L9.7299 7.90518C8.8699 8.75518 8.3999 9.88518 8.3999 11.0952C8.3999 11.6152 8.4899 12.1152 8.6499 12.5552C8.8599 13.1952 9.2399 13.7952 9.7199 14.2652C10.1999 14.7552 10.7999 15.1352 11.4399 15.3452ZM3.32 20.6851C4.2 21.5551 5.35 21.9951 6.5 21.9951C7.65 21.9951 8.81 21.5551 9.69 20.7051L14.28 16.1051C15.14 15.2551 15.61 14.1251 15.61 12.9151C15.61 12.4551 15.54 11.9951 15.4 11.5551C15.17 10.8651 14.8 10.2551 14.28 9.73509C13.76 9.21509 13.15 8.84509 12.46 8.61509C12.14 8.51509 11.8 8.68509 11.7 8.99509C11.6 9.30509 11.77 9.64509 12.1 9.75509C12.61 9.91509 13.06 10.1951 13.44 10.5751C13.82 10.9551 14.09 11.4051 14.26 11.9151C14.36 12.2351 14.41 12.5651 14.41 12.9051C14.41 13.7951 14.06 14.6251 13.43 15.2451L8.84 19.8451C7.55 21.1251 5.46 21.1251 4.17 19.8451C3.55 19.2151 3.21 18.3951 3.21 17.5051C3.21 16.6151 3.55 15.7851 4.17 15.1651L7.35 11.9851C7.58 11.7451 7.59 11.3651 7.35 11.1351C7.11 10.9051 6.73 10.9051 6.5 11.1351L3.32 14.3151C2.47 15.1551 2 16.2851 2 17.4951C2 18.7051 2.47 19.8351 3.32 20.6851Z"/></svg>',
},
{
name: 'image',
action: EasyMDE.drawImage,
title: this.$t('input.editor.image'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M4 4C2.89543 4 2 4.89543 2 6V16V17.5152V18C2 19.1046 2.89543 20 4 20H20C21.0528 20 21.9156 19.1866 21.9942 18.1539L22 18.1632V18V16V6C22 4.89543 21.1046 4 20 4H4ZM3.2 17.7V16.5642L6.78192 13.7254C6.8616 13.6622 6.97597 13.6689 7.04776 13.7409L10.3126 17.0146C10.7026 17.4056 11.3357 17.4065 11.7268 17.0165C11.7606 16.9827 11.792 16.9465 11.8207 16.9083L16.736 10.352C16.8023 10.2636 16.9277 10.2457 17.016 10.312C17.0355 10.3265 17.0521 10.3445 17.0651 10.365L20.8 16.2669V17.7C20.8 18.3075 20.3075 18.8 19.7 18.8H4.3C3.69249 18.8 3.2 18.3075 3.2 17.7ZM17.3865 8.61836L20.8 14.08V6.3C20.8 5.69249 20.3075 5.2 19.7 5.2H4.3C3.69249 5.2 3.2 5.69249 3.2 6.3V15.04L6.65054 12.2796C6.84949 12.1204 7.13629 12.1363 7.31645 12.3164L10.8369 15.8369C10.915 15.915 11.0417 15.915 11.1198 15.8369C11.1265 15.8302 16.5625 8.58336 16.5625 8.58336C16.7282 8.36245 17.0416 8.31768 17.2625 8.48336C17.3118 8.52034 17.3538 8.56611 17.3865 8.61836ZM8 8.5C8 9.32843 7.32843 10 6.5 10C5.67157 10 5 9.32843 5 8.5C5 7.67157 5.67157 7 6.5 7C7.32843 7 8 7.67157 8 8.5Z"/></svg>',
},
{
name: 'table',
action: EasyMDE.drawTable,
title: this.$t('input.editor.table'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6.18524 3.08496H19.4152C20.6752 3.08496 21.7152 4.11496 21.7152 5.38496V18.615C21.7152 19.885 20.6852 20.915 19.4152 20.915H6.18524C4.91524 20.915 3.88525 19.885 3.88525 18.615V5.38496C3.88525 4.11496 4.91524 3.08496 6.18524 3.08496ZM19.4052 19.705C20.0152 19.705 20.5052 19.215 20.5052 18.605H20.5153V5.38496C20.5153 4.77496 20.0252 4.28496 19.4152 4.28496H6.18524C5.57524 4.28496 5.08521 4.77496 5.08521 5.38496V18.605C5.08521 19.215 5.57524 19.705 6.18524 19.705H19.4052ZM17.4453 9.15503H8.15527C7.82527 9.15503 7.5553 9.42503 7.5553 9.75503C7.5553 10.085 7.82527 10.355 8.15527 10.355H17.4453C17.7753 10.355 18.0453 10.085 18.0453 9.75503C18.0453 9.42503 17.7753 9.15503 17.4453 9.15503ZM17.4453 13.635H8.15527C7.82527 13.635 7.5553 13.905 7.5553 14.235C7.5553 14.565 7.82527 14.835 8.15527 14.835H17.4453C17.7753 14.835 18.0453 14.565 18.0453 14.235C18.0453 13.905 17.7753 13.635 17.4453 13.635Z"/></svg>',
},
{
name: 'horizontal-rule',
action: EasyMDE.drawHorizontalRule,
title: this.$t('input.editor.horizontalRule'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21 13H3C2.45 13 2 12.55 2 12C2 11.45 2.45 11 3 11H21C21.55 11 22 11.45 22 12C22 12.55 21.55 13 21 13Z"/></svg>',
},
'|',
{
name: 'side-by-side',
action: EasyMDE.toggleSideBySide,
title: this.$t('input.editor.sideBySide'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.4787 14.58C18.3587 14.69 18.2987 14.85 18.2987 15C18.2987 15.15 18.3587 15.31 18.4787 15.42C18.7187 15.65 19.0987 15.65 19.3287 15.42L22.3287 12.42C22.5587 12.18 22.5587 11.8 22.3287 11.57L19.3287 8.56996C19.0887 8.33996 18.7087 8.33996 18.4787 8.56996C18.2487 8.80996 18.2487 9.18996 18.4787 9.41996L20.451 11.3999L14.4487 11.3999L14.4487 4.6C14.4487 4.27 14.1787 4 13.8487 4C13.5187 4 13.2487 4.27 13.2487 4.6L13.2487 19.4C13.2487 19.73 13.5187 20 13.8487 20C14.1787 20 14.4487 19.73 14.4487 19.4L14.4487 12.5999L20.4511 12.5999L18.4787 14.58ZM9.54878 19.4L9.54878 12.5999L3.5486 12.5999L5.52867 14.58C5.75867 14.81 5.75867 15.19 5.52867 15.43C5.29867 15.66 4.91867 15.66 4.67867 15.43L1.67867 12.43C1.63274 12.384 1.5956 12.3323 1.56725 12.2774C1.53058 12.2077 1.50724 12.1299 1.50068 12.0477C1.49934 12.0317 1.49867 12.0158 1.49867 12C1.49867 11.9841 1.49933 11.9682 1.50067 11.9522C1.51454 11.778 1.60365 11.6242 1.73526 11.5234L4.67867 8.57997C4.90867 8.34997 5.28867 8.34997 5.52867 8.57997C5.75867 8.80997 5.75867 9.18997 5.52867 9.42997L3.55107 11.3999L9.54878 11.3999L9.54878 4.6C9.54878 4.27 9.81878 4 10.1488 4C10.4788 4 10.7488 4.27 10.7488 4.6L10.7488 11.9999L10.7488 19.4C10.7488 19.73 10.4788 20 10.1488 20C9.81878 20 9.54878 19.73 9.54878 19.4Z"/></svg>',
},
{
name: 'guide',
action: () => {
window.open('https://www.markdownguide.org/basic-syntax/', '_blank')
},
title: this.$t('input.editor.guide'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.4999 2.3999H6.4999C5.0699 2.3999 3.8999 3.5699 3.8999 4.9999V18.9999C3.8999 20.4299 5.0699 21.5999 6.4999 21.5999H19.4999C19.8299 21.5999 20.0999 21.3299 20.0999 20.9999V16.9999V2.9999C20.0999 2.6699 19.8299 2.3999 19.4999 2.3999ZM5.0999 4.9999V16.8118C5.50468 16.5513 5.98546 16.3999 6.4999 16.3999H18.8999V3.5999H6.4999C5.7299 3.5999 5.0999 4.2299 5.0999 4.9999ZM6.4999 17.5999H18.8999V20.3999H6.4999C5.7299 20.3999 5.0999 19.7699 5.0999 18.9999C5.0999 18.2299 5.7299 17.5999 6.4999 17.5999ZM8.4999 8.5999H15.4999C15.8299 8.5999 16.0999 8.3299 16.0999 7.9999C16.0999 7.6699 15.8299 7.3999 15.4999 7.3999H8.4999C8.1699 7.3999 7.8999 7.6699 7.8999 7.9999C7.8999 8.3299 8.1699 8.5999 8.4999 8.5999ZM15.4999 11.3999H8.4999C8.1699 11.3999 7.8999 11.6699 7.8999 11.9999C7.8999 12.3299 8.1699 12.5999 8.4999 12.5999H15.4999C15.8299 12.5999 16.0999 12.3299 16.0999 11.9999C16.0999 11.6699 15.8299 11.3999 15.4999 11.3999Z"/></svg>',
},
],
},
} }
}, },
watch: { watch: {
value(newVal) { modelValue(modelValue) {
this.text = newVal this.text = modelValue
this.$nextTick(this.renderPreview) this.$nextTick(this.renderPreview)
}, },
text(newVal, oldVal) { text(newVal, oldVal) {
// Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside. // Only bubble the new value if it actually changed, but not if the component just got mounted and the text changed from the outside.
if (oldVal === '' && this.text === this.value) { if (oldVal === '' && this.text === this.modelValue) {
return return
} }
this.bubble() this.bubble()
}, },
}, },
mounted() { mounted() {
if (this.value !== '') { if (this.modelValue !== '') {
this.text = this.value this.text = this.modelValue
} }
if (this.previewIsDefault && this.hasPreview) { if (this.previewIsDefault && this.hasPreview) {
@ -299,7 +174,7 @@ export default {
} }
this.changeTimeout = setTimeout(() => { this.changeTimeout = setTimeout(() => {
this.$emit('input', this.text) this.$emit('update:modelValue',this.text)
this.$emit('change', this.text) this.$emit('change', this.text)
}, timeout) }, timeout)
}, },
@ -335,7 +210,7 @@ export default {
} }
checkboxNum++ checkboxNum++
return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this._uid}"/>` return `<input type="checkbox" data-checkbox-num="${checkboxNum}" ${checked} class="text-checkbox-${this.checkboxId}"/>`
}, },
link: (href, title, text) => { link: (href, title, text) => {
const isLocal = href.startsWith(`${location.protocol}//${location.hostname}`) const isLocal = href.startsWith(`${location.protocol}//${location.hostname}`)
@ -358,7 +233,7 @@ export default {
// dom tree. If we're calling this right after setting this.preview it could be the images were // dom tree. If we're calling this right after setting this.preview it could be the images were
// not already made available. // not already made available.
// Some docs at https://stackoverflow.com/q/62865160/10924593 // Some docs at https://stackoverflow.com/q/62865160/10924593
this.$nextTick(() => { this.$nextTick(async () => {
const attachmentImage = document.getElementsByClassName('attachment-image') const attachmentImage = document.getElementsByClassName('attachment-image')
if (attachmentImage) { if (attachmentImage) {
for (const img of attachmentImage) { for (const img of attachmentImage) {
@ -379,15 +254,13 @@ export default {
this.attachmentService = new AttachmentService() this.attachmentService = new AttachmentService()
} }
this.attachmentService.getBlobUrl(attachment) const url = await this.attachmentService.getBlobUrl(attachment)
.then(url => { img.src = url
img.src = url this.loadedAttachments[cacheKey] = url
this.loadedAttachments[cacheKey] = url
})
} }
} }
const textCheckbox = document.getElementsByClassName(`text-checkbox-${this._uid}`) const textCheckbox = document.getElementsByClassName(`text-checkbox-${this.checkboxId}`)
if (textCheckbox) { if (textCheckbox) {
for (const check of textCheckbox) { for (const check of textCheckbox) {
check.removeEventListener('change', this.handleCheckboxClick) check.removeEventListener('change', this.handleCheckboxClick)
@ -435,8 +308,9 @@ export default {
</script> </script>
<style lang="scss"> <style lang="scss">
@import '../../../node_modules/highlight.js/scss/base16/equilibrium-gray-light'; @import 'codemirror/lib/codemirror.css';
@import '../../../node_modules/easymde/dist/easymde.min.css'; @import './vue-easymde/vue-easymde.css';
@import 'highlight.js/scss/base16/equilibrium-gray-light';
.editor { .editor {
.clear { .clear {

View File

@ -0,0 +1,134 @@
import EasyMDE from 'easymde'
import {i18n} from '@/i18n'
export function createEasyMDEConfig({ placeholder, uploadImage, imageUploadFunction }) {
return {
autoDownloadFontAwesome: false,
spellChecker: false,
placeholder,
uploadImage,
imageUploadFunction,
minHeight: '150px',
toolbar: [
{
name: 'heading-1',
action: EasyMDE.toggleHeading1,
title: i18n.global.t('input.editor.heading1'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-2',
action: EasyMDE.toggleHeading2,
title: i18n.global.t('input.editor.heading2'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-3',
action: EasyMDE.toggleHeading3,
title: i18n.global.t('input.editor.heading3'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-smaller',
action: EasyMDE.toggleHeadingSmaller,
title: i18n.global.t('input.editor.headingSmaller'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
{
name: 'heading-bigger',
action: EasyMDE.toggleHeadingBigger,
title: i18n.global.t('input.editor.headingBigger'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.2773 19.25L12.5773 4.34995C12.5773 4.34995 12.5773 4.24995 12.4773 4.24995C12.4773 4.24995 12.4773 4.14995 12.3773 4.14995C12.3773 4.14995 12.2773 4.14995 12.2773 4.04995L12.1773 3.94995H12.0773H11.9773C11.8773 3.94995 11.8773 3.94995 11.8773 3.94995H11.7773C11.6773 4.04995 11.6773 4.14995 11.5773 4.14995C11.5773 4.14995 11.5773 4.14995 11.4773 4.14995C11.4773 4.14995 11.4773 4.24995 11.3773 4.24995L11.2773 4.34995L5.67733 19.25C5.57733 19.55 5.67733 19.95 5.97733 20.05C6.07733 20.05 6.07733 20.05 6.17733 20.05C6.37733 20.05 6.67733 19.95 6.77733 19.65L7.87733 16.85H16.1773L17.2773 19.65C17.3773 19.85 17.5773 20.05 17.8773 20.05C17.9773 20.05 17.9773 20.05 18.0773 20.05C18.2773 19.85 18.4773 19.55 18.2773 19.25ZM8.27733 15.65L11.9773 6.24995L15.6773 15.65H8.27733Z"/></svg>',
},
'|',
{
name: 'bold',
action: EasyMDE.toggleBold,
title: i18n.global.t('input.editor.bold'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3.5 3H6.5H15.25C18.15 3 20.5 5.36 20.5 8.25C20.5 9.8 19.81 11.19 18.73 12.15C20.37 13.04 21.5 14.76 21.5 16.75C21.5 19.64 19.15 22 16.25 22H6.5H3.5C2.95 22 2.5 21.55 2.5 21C2.5 20.45 2.95 20 3.5 20H5.5V5H3.5C2.95 5 2.5 4.55 2.5 4C2.5 3.45 2.95 3 3.5 3ZM7.5 20H16.25C18.04 20 19.5 18.54 19.5 16.75C19.5 14.96 18.04 13.5 16.25 13.5H7.5V20ZM7.5 11.5H15.25C17.04 11.5 18.5 10.04 18.5 8.25C18.5 6.46 17.04 5 15.25 5H7.5V11.5Z"/></svg>',
},
{
name: 'italic',
action: EasyMDE.toggleItalic,
title: i18n.global.t('input.editor.italic'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M14.0967 4.2H17.0001C17.3301 4.2 17.6001 3.93 17.6001 3.6C17.6001 3.27 17.3301 3 17.0001 3H10.2001C9.8701 3 9.6001 3.27 9.6001 3.6C9.6001 3.93 9.8701 4.2 10.2001 4.2H12.8748L9.90335 19.8H6.9999C6.6699 19.8 6.3999 20.07 6.3999 20.4C6.3999 20.73 6.6699 21 6.9999 21H13.7999C14.1299 21 14.3999 20.73 14.3999 20.4C14.3999 20.07 14.1299 19.8 13.7999 19.8H11.1253L14.0967 4.2Z"/></svg>',
},
{
name: 'strikethrough',
action: EasyMDE.toggleStrikethrough,
title: i18n.global.t('input.editor.strikethrough'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.25 7.17005C18.25 7.50005 17.98 7.77005 17.65 7.77005C17.32 7.77005 17.05 7.50005 17.05 7.17005V5.96005C15.97 5.12005 14.17 4.56005 12.79 4.31005C11.1 4.00005 9.51 4.30005 8.41 5.12005C7.2 6.03005 6.67 7.67005 7.19 8.88005C7.56 9.73005 8.37 10.31 8.98 10.64C9.57215 10.9644 10.1961 11.2013 10.8465 11.3999H20.4C20.73 11.3999 21 11.6699 21 11.9999C21 12.3299 20.73 12.5999 20.4 12.5999H15.3012C16.6583 13.0929 17.5255 13.7765 17.95 14.69C18.73 16.36 17.74 18.33 16.36 19.41C15.05 20.4401 13.35 21 11.54 21H11.16C9.78 20.9401 8.34 20.5301 6.95 19.85V20.3601C6.95 20.6901 6.68 20.96 6.35 20.96C6.02 20.96 5.75 20.6901 5.75 20.3601V17.36C5.75 17.03 6.02 16.76 6.35 16.76C6.68 16.76 6.95 17.03 6.95 17.36V18.5C8.35 19.2801 9.81 19.74 11.21 19.8C12.86 19.89 14.46 19.39 15.62 18.48C16.6 17.71 17.37 16.3 16.86 15.21C16.55 14.54 15.8 14.0201 14.58 13.63C13.9711 13.4331 13.3222 13.2762 12.6906 13.1235C12.6168 13.1056 12.5432 13.0878 12.47 13.07C12.4313 13.0607 12.3925 13.0514 12.3537 13.0421C11.7861 12.9055 11.2108 12.767 10.6413 12.5999H3.6C3.27 12.5999 3 12.3299 3 11.9999C3 11.6699 3.27 11.3999 3.6 11.3999H7.90288C7.04984 10.8343 6.42752 10.1363 6.09 9.36005C5.34 7.63005 6.03 5.40005 7.69 4.16005C9.05 3.15005 10.99 2.77005 13 3.13005C13.64 3.25005 15.53 3.66005 17.05 4.53005V4.17005C17.05 3.84005 17.32 3.57005 17.65 3.57005C17.98 3.57005 18.25 3.84005 18.25 4.17005V7.17005Z"/></svg>',
},
{
name: 'code',
action: EasyMDE.toggleCodeBlock,
title: i18n.global.t('input.editor.code'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M8.57 20.9601C8.64 20.9901 8.71 21.0001 8.78 21.0001C9.02 21.0001 9.24 20.8501 9.34 20.6101L15.79 3.81005C15.9 3.50005 15.75 3.15005 15.44 3.03005C15.14 2.92005 14.79 3.07005 14.67 3.38005L8.22 20.1801C8.11 20.4901 8.26 20.8401 8.57 20.9601ZM7.00007 18.0001C6.85007 18.0001 6.69007 17.9401 6.58007 17.8201L1.18007 12.4201C0.950068 12.1901 0.950068 11.8101 1.18007 11.5701L6.58007 6.17006C6.81007 5.94006 7.19007 5.94006 7.43007 6.17006C7.66007 6.40006 7.66007 6.78006 7.43007 7.02006L2.45007 12.0001L7.43007 16.9801C7.66007 17.2101 7.66007 17.5901 7.43007 17.8301C7.31007 17.9401 7.15007 18.0001 7.00007 18.0001ZM17 18.0001C16.85 18.0001 16.69 17.9401 16.58 17.8201C16.35 17.5901 16.35 17.2101 16.58 16.9701L21.55 12.0001L16.57 7.02006C16.34 6.79006 16.34 6.41006 16.57 6.17006C16.81 5.94006 17.19 5.94006 17.42 6.17006L22.82 11.5701C23.05 11.8001 23.05 12.1801 22.82 12.4201L17.42 17.8201C17.31 17.9401 17.15 18.0001 17 18.0001Z"/></svg>',
},
{
name: 'quote',
action: EasyMDE.toggleBlockquote,
title: i18n.global.t('input.editor.quote'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.373 5.16357H5.62695C4.79102 5.16357 4.11133 5.84326 4.11133 6.6792V16.2095C4.11133 17.0464 4.79102 17.7261 5.62695 17.7261H6.8877V21.1245C6.8877 21.3667 7.0332 21.5854 7.25684 21.6782C7.33203 21.7095 7.41016 21.7241 7.4873 21.7241C7.64258 21.7241 7.7959 21.6636 7.91113 21.5493L11.748 17.7261H19.373C20.209 17.7261 20.8887 17.0464 20.8887 16.2095V6.6792C20.8887 5.84326 20.209 5.16357 19.373 5.16357ZM19.6895 16.2095C19.6895 16.3843 19.5469 16.5269 19.373 16.5269H11.5C11.3408 16.5269 11.1895 16.5894 11.0762 16.7017L8.08691 19.6802V17.1265C8.08691 16.7954 7.81836 16.5269 7.4873 16.5269H5.62695C5.45312 16.5269 5.31055 16.3843 5.31055 16.2095V6.6792C5.31055 6.50537 5.45312 6.36279 5.62695 6.36279H19.373C19.5469 6.36279 19.6895 6.50537 19.6895 6.6792V16.2095ZM10.3431 8.45264C9.46326 8.45264 8.75 9.16589 8.75 10.0458C8.75 10.9257 9.46326 11.639 10.3431 11.639C10.4775 11.639 10.6058 11.6173 10.7305 11.5861V11.6195C10.7305 12.1322 10.3135 12.5492 9.75586 12.5492C9.4248 12.5492 9.17871 12.8177 9.17871 13.1488C9.17871 13.4799 9.46973 13.7484 9.80078 13.7484C10.9746 13.7484 11.9297 12.7933 11.9297 11.6195V10.1176L11.9294 10.1165L11.9292 10.1155C11.9297 10.1049 11.9312 10.0946 11.9326 10.0843L11.9326 10.0843C11.9345 10.0716 11.9363 10.059 11.9363 10.0458C11.9363 9.16589 11.223 8.45264 10.3431 8.45264ZM13.0637 10.0458C13.0637 9.16589 13.7771 8.45264 14.657 8.45264C15.5369 8.45264 16.2501 9.16589 16.2501 10.0458C16.2501 10.0584 16.2484 10.0706 16.2466 10.0828C16.2452 10.0929 16.2437 10.103 16.2433 10.1134C16.2433 10.1149 16.2441 10.1161 16.2441 10.1176V11.6195C16.2441 12.7933 15.2891 13.7484 14.1152 13.7484C13.7842 13.7484 13.4922 13.4799 13.4922 13.1488C13.4922 12.8177 13.7383 12.5492 14.0693 12.5492C14.6279 12.5492 15.0449 12.1322 15.0449 11.6195V11.5858C14.9202 11.6173 14.7915 11.639 14.657 11.639C13.7771 11.639 13.0637 10.9257 13.0637 10.0458Z"/></svg>',
},
{
name: 'unordered-list',
action: EasyMDE.toggleUnorderedList,
title: i18n.global.t('input.editor.unorderedList'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6.5281 3.7002H3.5281C3.1981 3.7002 2.9281 3.9702 2.9281 4.3002V7.3002C2.9281 7.6302 3.1981 7.9002 3.5281 7.9002H6.5281C6.8581 7.9002 7.1281 7.6302 7.1281 7.3002V4.3002C7.1281 3.9702 6.8581 3.7002 6.5281 3.7002ZM5.9281 6.7002H4.1281V4.9002H5.9281V6.7002ZM3.5281 9.90015H6.5281C6.8581 9.90015 7.1281 10.1701 7.1281 10.5001V13.5001C7.1281 13.8301 6.8581 14.1001 6.5281 14.1001H3.5281C3.1981 14.1001 2.9281 13.8301 2.9281 13.5001V10.5001C2.9281 10.1701 3.1981 9.90015 3.5281 9.90015ZM4.1281 12.9001H5.9281V11.1001H4.1281V12.9001ZM3.5281 16.1001H6.5281C6.8581 16.1001 7.1281 16.3701 7.1281 16.7001V19.7001C7.1281 20.0301 6.8581 20.3001 6.5281 20.3001H3.5281C3.1981 20.3001 2.9281 20.0301 2.9281 19.7001V16.7001C2.9281 16.3701 3.1981 16.1001 3.5281 16.1001ZM4.1281 19.1001H5.9281V17.3001H4.1281V19.1001ZM9.72817 6.4002H20.7282C21.0582 6.4002 21.3282 6.1302 21.3282 5.8002C21.3282 5.4702 21.0582 5.2002 20.7282 5.2002H9.72817C9.39817 5.2002 9.12817 5.4702 9.12817 5.8002C9.12817 6.1302 9.39817 6.4002 9.72817 6.4002ZM9.72817 11.4001H20.7282C21.0582 11.4001 21.3282 11.6701 21.3282 12.0001C21.3282 12.3301 21.0582 12.6001 20.7282 12.6001H9.72817C9.39817 12.6001 9.12817 12.3301 9.12817 12.0001C9.12817 11.6701 9.39817 11.4001 9.72817 11.4001ZM9.72817 17.6001H20.7282C21.0582 17.6001 21.3282 17.8701 21.3282 18.2001C21.3282 18.5301 21.0582 18.8001 20.7282 18.8001H9.72817C9.39817 18.8001 9.12817 18.5301 9.12817 18.2001C9.12817 17.8701 9.39817 17.6001 9.72817 17.6001Z"/></svg>',
},
{
name: 'ordered-list',
action: EasyMDE.toggleOrderedList,
title: i18n.global.t('input.editor.orderedList'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M4.19494 8.29994H5.99494C6.26494 8.29994 6.49494 8.07995 6.49494 7.79994C6.49494 7.51995 6.27494 7.29994 5.99494 7.29994H5.59494V3.79994C5.59494 3.62994 5.50494 3.46994 5.36494 3.37994C5.22494 3.28994 5.04494 3.26994 4.89494 3.33994L3.89494 3.76994C3.64494 3.87994 3.52494 4.17994 3.63494 4.42994C3.74494 4.67994 4.03494 4.79994 4.29494 4.68994L4.59494 4.55994V7.29994H4.19494C3.91494 7.29994 3.69494 7.51995 3.69494 7.79994C3.69494 8.07995 3.91494 8.29994 4.19494 8.29994ZM20.195 6.39995H9.19497C8.86497 6.39995 8.59497 6.12995 8.59497 5.79995C8.59497 5.46995 8.86497 5.19995 9.19497 5.19995H20.195C20.525 5.19995 20.795 5.46995 20.795 5.79995C20.795 6.12995 20.525 6.39995 20.195 6.39995ZM3.78486 14.36H6.37486C6.65486 14.36 6.87486 14.14 6.87486 13.86C6.87486 13.58 6.65486 13.36 6.37486 13.36H4.88486C5.00486 13.23 5.12486 13.09 5.23486 12.95C5.26626 12.9151 5.29645 12.8802 5.32626 12.8458L5.32629 12.8457C5.38192 12.7814 5.43627 12.7186 5.49486 12.66C5.73486 12.4 5.98486 12.12 6.17486 11.79C6.47486 11.25 6.41486 10.63 6.01486 10.17C5.57486 9.66 4.86486 9.5 4.24486 9.74C3.74486 9.95 3.39486 10.35 3.22486 10.91C3.14486 11.18 3.29486 11.46 3.56486 11.54C3.82486 11.61 4.10486 11.46 4.18486 11.2C4.29486 10.85 4.48486 10.73 4.62486 10.67C4.88486 10.57 5.13486 10.68 5.26486 10.82C5.38486 10.96 5.40486 11.12 5.30486 11.29C5.17595 11.5202 4.99618 11.7165 4.80458 11.9257L4.75486 11.98C4.67298 12.0801 4.58283 12.1801 4.49946 12.2727L4.49945 12.2727L4.47486 12.3C4.12486 12.72 3.76486 13.13 3.40486 13.53C3.27486 13.68 3.23486 13.9 3.32486 14.07C3.41486 14.24 3.58486 14.36 3.78486 14.36ZM3.68486 20.3699C4.04486 20.5899 4.46486 20.6999 4.87486 20.6999C5.13486 20.6999 5.38486 20.6499 5.61486 20.5499C6.31486 20.2799 6.73486 19.5599 6.60486 18.8799C6.53486 18.5499 6.35486 18.2899 6.12486 18.0899C6.32486 17.8999 6.45486 17.6499 6.50486 17.3799C6.57486 17.0099 6.49486 16.6299 6.27486 16.3099C5.85486 15.6899 5.07486 15.5199 4.10486 15.8299C3.83486 15.9199 3.69486 16.1999 3.77486 16.4599C3.86486 16.7299 4.14486 16.8699 4.40486 16.7899C4.70486 16.6999 5.24486 16.5799 5.45486 16.8899C5.51486 16.9899 5.54486 17.0999 5.52486 17.1999C5.51486 17.2699 5.47486 17.3599 5.36486 17.4299C5.26486 17.4999 5.12486 17.5399 4.95486 17.5799L4.77486 17.6299C4.54486 17.6999 4.40486 17.9099 4.41486 18.1499C4.42486 18.3899 4.61486 18.5799 4.84486 18.6099C5.20486 18.6599 5.58486 18.8299 5.63486 19.0799C5.67486 19.2999 5.46486 19.5499 5.25486 19.6299C4.94486 19.7599 4.52486 19.7099 4.21486 19.5199C3.97486 19.3699 3.67486 19.4399 3.52486 19.6799C3.37486 19.9199 3.44486 20.2299 3.68486 20.3699ZM20.195 18.7999H9.19497C8.86497 18.7999 8.59497 18.5299 8.59497 18.1999C8.59497 17.8699 8.86497 17.5999 9.19497 17.5999H20.195C20.525 17.5999 20.795 17.8699 20.795 18.1999C20.795 18.5299 20.525 18.7999 20.195 18.7999ZM9.19497 12.5999H20.195C20.525 12.5999 20.795 12.3299 20.795 11.9999C20.795 11.6699 20.525 11.3999 20.195 11.3999H9.19497C8.86497 11.3999 8.59497 11.6699 8.59497 11.9999C8.59497 12.3299 8.86497 12.5999 9.19497 12.5999Z"/></svg>',
},
'|',
{
name: 'clean-block',
action: EasyMDE.cleanBlock,
title: i18n.global.t('input.editor.cleanBlock'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M9.25989 6.18384H20.4513C20.7823 6.18384 21.0509 6.45239 21.0509 6.78345V17.9749C21.0509 18.3059 20.7823 18.5745 20.4513 18.5745H9.25989C9.0929 18.5745 8.93469 18.5061 8.82043 18.384L3.6095 12.7883C3.39563 12.5579 3.39563 12.2004 3.6095 11.97L8.82043 6.37427C8.93469 6.2522 9.0929 6.18384 9.25989 6.18384ZM9.52063 17.3752H19.8517V7.38306H9.52063L4.86926 12.3792L9.52063 17.3752ZM12.7755 15.0686C12.6222 15.0686 12.4679 15.01 12.3517 14.8928C12.1173 14.6584 12.1173 14.2786 12.3517 14.0452L14.0503 12.3469L12.3517 10.6487C12.1173 10.4153 12.1173 10.0354 12.3517 9.80103C12.5841 9.56665 12.965 9.56665 13.1993 9.80103L14.8981 11.4994L16.5968 9.80103C16.8312 9.56665 17.212 9.56665 17.4445 9.80103C17.6788 10.0354 17.6788 10.4153 17.4445 10.6487L15.7458 12.3469L17.4445 14.0452C17.6788 14.2786 17.6788 14.6584 17.4445 14.8928C17.3282 15.01 17.174 15.0686 17.0206 15.0686C16.8673 15.0686 16.714 15.01 16.5968 14.8928L14.8981 13.1945L13.1993 14.8928C13.0822 15.01 12.9288 15.0686 12.7755 15.0686Z"/></svg>',
},
{
name: 'link',
action: EasyMDE.drawLink,
title: i18n.global.t('input.editor.link'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M11.4399 15.3452C11.4999 15.3652 11.5699 15.3752 11.6299 15.3752C11.8799 15.3752 12.1199 15.2152 12.1999 14.9652C12.2999 14.6452 12.1299 14.3052 11.8199 14.2052C11.3499 14.0452 10.9299 13.7852 10.5699 13.4152C10.1999 13.0552 9.9399 12.6452 9.7799 12.1552C9.6599 11.8252 9.5999 11.4652 9.5999 11.0952C9.5999 10.2152 9.9399 9.38518 10.5699 8.75518L15.1599 4.15518C16.4499 2.87518 18.5399 2.87518 19.8299 4.15518C20.4499 4.78518 20.7899 5.61518 20.7899 6.49518C20.7899 7.37518 20.4499 8.20518 19.8299 8.82518L16.7399 11.9052C16.5099 12.1452 16.5099 12.5252 16.7399 12.7552C16.9799 12.9852 17.3599 12.9852 17.5899 12.7552L20.6799 9.67518C21.5299 8.83518 21.9999 7.69518 21.9999 6.49518C21.9999 5.29518 21.5299 4.16518 20.6899 3.30518C18.9299 1.55518 16.0799 1.55518 14.3199 3.30518L9.7299 7.90518C8.8699 8.75518 8.3999 9.88518 8.3999 11.0952C8.3999 11.6152 8.4899 12.1152 8.6499 12.5552C8.8599 13.1952 9.2399 13.7952 9.7199 14.2652C10.1999 14.7552 10.7999 15.1352 11.4399 15.3452ZM3.32 20.6851C4.2 21.5551 5.35 21.9951 6.5 21.9951C7.65 21.9951 8.81 21.5551 9.69 20.7051L14.28 16.1051C15.14 15.2551 15.61 14.1251 15.61 12.9151C15.61 12.4551 15.54 11.9951 15.4 11.5551C15.17 10.8651 14.8 10.2551 14.28 9.73509C13.76 9.21509 13.15 8.84509 12.46 8.61509C12.14 8.51509 11.8 8.68509 11.7 8.99509C11.6 9.30509 11.77 9.64509 12.1 9.75509C12.61 9.91509 13.06 10.1951 13.44 10.5751C13.82 10.9551 14.09 11.4051 14.26 11.9151C14.36 12.2351 14.41 12.5651 14.41 12.9051C14.41 13.7951 14.06 14.6251 13.43 15.2451L8.84 19.8451C7.55 21.1251 5.46 21.1251 4.17 19.8451C3.55 19.2151 3.21 18.3951 3.21 17.5051C3.21 16.6151 3.55 15.7851 4.17 15.1651L7.35 11.9851C7.58 11.7451 7.59 11.3651 7.35 11.1351C7.11 10.9051 6.73 10.9051 6.5 11.1351L3.32 14.3151C2.47 15.1551 2 16.2851 2 17.4951C2 18.7051 2.47 19.8351 3.32 20.6851Z"/></svg>',
},
{
name: 'image',
action: EasyMDE.drawImage,
title: i18n.global.t('input.editor.image'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M4 4C2.89543 4 2 4.89543 2 6V16V17.5152V18C2 19.1046 2.89543 20 4 20H20C21.0528 20 21.9156 19.1866 21.9942 18.1539L22 18.1632V18V16V6C22 4.89543 21.1046 4 20 4H4ZM3.2 17.7V16.5642L6.78192 13.7254C6.8616 13.6622 6.97597 13.6689 7.04776 13.7409L10.3126 17.0146C10.7026 17.4056 11.3357 17.4065 11.7268 17.0165C11.7606 16.9827 11.792 16.9465 11.8207 16.9083L16.736 10.352C16.8023 10.2636 16.9277 10.2457 17.016 10.312C17.0355 10.3265 17.0521 10.3445 17.0651 10.365L20.8 16.2669V17.7C20.8 18.3075 20.3075 18.8 19.7 18.8H4.3C3.69249 18.8 3.2 18.3075 3.2 17.7ZM17.3865 8.61836L20.8 14.08V6.3C20.8 5.69249 20.3075 5.2 19.7 5.2H4.3C3.69249 5.2 3.2 5.69249 3.2 6.3V15.04L6.65054 12.2796C6.84949 12.1204 7.13629 12.1363 7.31645 12.3164L10.8369 15.8369C10.915 15.915 11.0417 15.915 11.1198 15.8369C11.1265 15.8302 16.5625 8.58336 16.5625 8.58336C16.7282 8.36245 17.0416 8.31768 17.2625 8.48336C17.3118 8.52034 17.3538 8.56611 17.3865 8.61836ZM8 8.5C8 9.32843 7.32843 10 6.5 10C5.67157 10 5 9.32843 5 8.5C5 7.67157 5.67157 7 6.5 7C7.32843 7 8 7.67157 8 8.5Z"/></svg>',
},
{
name: 'table',
action: EasyMDE.drawTable,
title: i18n.global.t('input.editor.table'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M6.18524 3.08496H19.4152C20.6752 3.08496 21.7152 4.11496 21.7152 5.38496V18.615C21.7152 19.885 20.6852 20.915 19.4152 20.915H6.18524C4.91524 20.915 3.88525 19.885 3.88525 18.615V5.38496C3.88525 4.11496 4.91524 3.08496 6.18524 3.08496ZM19.4052 19.705C20.0152 19.705 20.5052 19.215 20.5052 18.605H20.5153V5.38496C20.5153 4.77496 20.0252 4.28496 19.4152 4.28496H6.18524C5.57524 4.28496 5.08521 4.77496 5.08521 5.38496V18.605C5.08521 19.215 5.57524 19.705 6.18524 19.705H19.4052ZM17.4453 9.15503H8.15527C7.82527 9.15503 7.5553 9.42503 7.5553 9.75503C7.5553 10.085 7.82527 10.355 8.15527 10.355H17.4453C17.7753 10.355 18.0453 10.085 18.0453 9.75503C18.0453 9.42503 17.7753 9.15503 17.4453 9.15503ZM17.4453 13.635H8.15527C7.82527 13.635 7.5553 13.905 7.5553 14.235C7.5553 14.565 7.82527 14.835 8.15527 14.835H17.4453C17.7753 14.835 18.0453 14.565 18.0453 14.235C18.0453 13.905 17.7753 13.635 17.4453 13.635Z"/></svg>',
},
{
name: 'horizontal-rule',
action: EasyMDE.drawHorizontalRule,
title: i18n.global.t('input.editor.horizontalRule'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M21 13H3C2.45 13 2 12.55 2 12C2 11.45 2.45 11 3 11H21C21.55 11 22 11.45 22 12C22 12.55 21.55 13 21 13Z"/></svg>',
},
'|',
{
name: 'side-by-side',
action: EasyMDE.toggleSideBySide,
title: i18n.global.t('input.editor.sideBySide'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M18.4787 14.58C18.3587 14.69 18.2987 14.85 18.2987 15C18.2987 15.15 18.3587 15.31 18.4787 15.42C18.7187 15.65 19.0987 15.65 19.3287 15.42L22.3287 12.42C22.5587 12.18 22.5587 11.8 22.3287 11.57L19.3287 8.56996C19.0887 8.33996 18.7087 8.33996 18.4787 8.56996C18.2487 8.80996 18.2487 9.18996 18.4787 9.41996L20.451 11.3999L14.4487 11.3999L14.4487 4.6C14.4487 4.27 14.1787 4 13.8487 4C13.5187 4 13.2487 4.27 13.2487 4.6L13.2487 19.4C13.2487 19.73 13.5187 20 13.8487 20C14.1787 20 14.4487 19.73 14.4487 19.4L14.4487 12.5999L20.4511 12.5999L18.4787 14.58ZM9.54878 19.4L9.54878 12.5999L3.5486 12.5999L5.52867 14.58C5.75867 14.81 5.75867 15.19 5.52867 15.43C5.29867 15.66 4.91867 15.66 4.67867 15.43L1.67867 12.43C1.63274 12.384 1.5956 12.3323 1.56725 12.2774C1.53058 12.2077 1.50724 12.1299 1.50068 12.0477C1.49934 12.0317 1.49867 12.0158 1.49867 12C1.49867 11.9841 1.49933 11.9682 1.50067 11.9522C1.51454 11.778 1.60365 11.6242 1.73526 11.5234L4.67867 8.57997C4.90867 8.34997 5.28867 8.34997 5.52867 8.57997C5.75867 8.80997 5.75867 9.18997 5.52867 9.42997L3.55107 11.3999L9.54878 11.3999L9.54878 4.6C9.54878 4.27 9.81878 4 10.1488 4C10.4788 4 10.7488 4.27 10.7488 4.6L10.7488 11.9999L10.7488 19.4C10.7488 19.73 10.4788 20 10.1488 20C9.81878 20 9.54878 19.73 9.54878 19.4Z"/></svg>',
},
{
name: 'guide',
action() {
window.open('https://www.markdownguide.org/basic-syntax/', '_blank')
},
title: i18n.global.t('input.editor.guide'),
icon: '<svg viewBox="0 0 24 24"><rect fill="none" rx="0" ry="0"/><path fill-rule="evenodd" clip-rule="evenodd" d="M19.4999 2.3999H6.4999C5.0699 2.3999 3.8999 3.5699 3.8999 4.9999V18.9999C3.8999 20.4299 5.0699 21.5999 6.4999 21.5999H19.4999C19.8299 21.5999 20.0999 21.3299 20.0999 20.9999V16.9999V2.9999C20.0999 2.6699 19.8299 2.3999 19.4999 2.3999ZM5.0999 4.9999V16.8118C5.50468 16.5513 5.98546 16.3999 6.4999 16.3999H18.8999V3.5999H6.4999C5.7299 3.5999 5.0999 4.2299 5.0999 4.9999ZM6.4999 17.5999H18.8999V20.3999H6.4999C5.7299 20.3999 5.0999 19.7699 5.0999 18.9999C5.0999 18.2299 5.7299 17.5999 6.4999 17.5999ZM8.4999 8.5999H15.4999C15.8299 8.5999 16.0999 8.3299 16.0999 7.9999C16.0999 7.6699 15.8299 7.3999 15.4999 7.3999H8.4999C8.1699 7.3999 7.8999 7.6699 7.8999 7.9999C7.8999 8.3299 8.1699 8.5999 8.4999 8.5999ZM15.4999 11.3999H8.4999C8.1699 11.3999 7.8999 11.6699 7.8999 11.9999C7.8999 12.3299 8.1699 12.5999 8.4999 12.5999H15.4999C15.8299 12.5999 16.0999 12.3299 16.0999 11.9999C16.0999 11.6699 15.8299 11.3999 15.4999 11.3999Z"/></svg>',
},
],
}
}

View File

@ -2,7 +2,7 @@
<div :class="{'is-disabled': disabled}" class="fancycheckbox"> <div :class="{'is-disabled': disabled}" class="fancycheckbox">
<input <input
:checked="checked" :checked="checked"
:disabled="disabled" :disabled="disabled || null"
:id="checkBoxId" :id="checkBoxId"
@change="(event) => updateData(event.target.checked)" @change="(event) => updateData(event.target.checked)"
style="display: none;" style="display: none;"
@ -21,16 +21,18 @@
</template> </template>
<script> <script>
import {createRandomID} from '@/helpers/randomId'
export default { export default {
name: 'fancycheckbox', name: 'fancycheckbox',
data() { data() {
return { return {
checked: false, checked: false,
checkBoxId: 'fancycheckbox' + Math.random(), checkBoxId: `fancycheckbox_${createRandomID()}`,
} }
}, },
props: { props: {
value: { modelValue: {
required: false, required: false,
}, },
disabled: { disabled: {
@ -39,10 +41,11 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(modelValue) {
this.checked = value this.checked = modelValue
}, },
immediate: true, immediate: true,
@ -51,7 +54,7 @@ export default {
methods: { methods: {
updateData(checked) { updateData(checked) {
this.checked = checked this.checked = checked
this.$emit('input', checked) this.$emit('update:modelValue', checked)
this.$emit('change', checked) this.$emit('change', checked)
}, },
}, },

View File

@ -81,16 +81,9 @@
</template> </template>
<script> <script>
import { i18n } from '@/i18n'
import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside' import {closeWhenClickedOutside} from '@/helpers/closeWhenClickedOutside'
/**
* Available events:
* @search: Triggered every time the search query input changes
* @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
* @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
* @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
*/
export default { export default {
name: 'multiselect', name: 'multiselect',
data() { data() {
@ -133,7 +126,7 @@ export default {
}, },
}, },
// The object with the value, updated every time an entry is selected. // The object with the value, updated every time an entry is selected.
value: { modelValue: {
default() { default() {
return null return null
}, },
@ -149,14 +142,14 @@ export default {
createPlaceholder: { createPlaceholder: {
type: String, type: String,
default() { default() {
return this.$t('input.multiselect.createPlaceholder') return i18n.global.t('input.multiselect.createPlaceholder')
}, },
}, },
// The text shown next to an option. // The text shown next to an option.
selectPlaceholder: { selectPlaceholder: {
type: String, type: String,
default() { default() {
return this.$t('input.multiselect.selectPlaceholder') return i18n.global.t('input.multiselect.selectPlaceholder')
}, },
}, },
// If true, allows for selecting multiple items. v-model will be an array with all selected values in that case. // If true, allows for selecting multiple items. v-model will be an array with all selected values in that case.
@ -188,18 +181,29 @@ export default {
}, },
}, },
}, },
/**
* Available events:
* @search: Triggered every time the search query input changes
* @select: Triggered every time an option from the search results is selected. Also triggers a change in v-model.
* @create: If nothing or no exact match was found and `creatable` is true, this event is triggered with the current value of the search query.
* @remove: If `multiple` is enabled, this will be fired every time an item is removed from the array of selected items.
*/
emits: ['update:modelValue', 'search', 'select', 'create', 'remove'],
mounted() { mounted() {
document.addEventListener('click', this.hideSearchResultsHandler) document.addEventListener('click', this.hideSearchResultsHandler)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hideSearchResultsHandler) document.removeEventListener('click', this.hideSearchResultsHandler)
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.setSelectedObject(value) this.setSelectedObject(value)
}, },
immediate: true, immediate: true,
deep: true,
}, },
}, },
computed: { computed: {
@ -278,13 +282,13 @@ export default {
this.internalValue = object this.internalValue = object
} }
this.$emit('input', this.internalValue) this.$emit('update:modelValue', this.internalValue)
this.$emit('select', object) this.$emit('select', object)
this.setSelectedObject(object) this.setSelectedObject(object)
this.closeSearchResults() this.closeSearchResults()
}, },
setSelectedObject(object, resetOnly = false) { setSelectedObject(object, resetOnly = false) {
this.$set(this, 'internalValue', object) this.internalValue = object
// We assume we're getting an array when multiple is enabled and can therefore leave the query // We assume we're getting an array when multiple is enabled and can therefore leave the query
// value etc as it is // value etc as it is
@ -352,7 +356,7 @@ export default {
} }
} }
this.$emit('input', this.internalValue) this.$emit('update:modelValue', this.internalValue)
this.$emit('remove', item) this.$emit('remove', item)
}, },
focus() { focus() {

View File

@ -0,0 +1,374 @@
.EasyMDEContainer {
display: block;
}
.EasyMDEContainer.sided--no-fullscreen {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.EasyMDEContainer .CodeMirror {
box-sizing: border-box;
height: auto;
border: 1px solid #ddd;
border-bottom-left-radius: 4px;
border-bottom-right-radius: 4px;
padding: 10px;
font: inherit;
z-index: 0;
word-wrap: break-word;
}
.EasyMDEContainer .CodeMirror-scroll {
cursor: text;
}
.EasyMDEContainer .CodeMirror-fullscreen {
background: #fff;
position: fixed !important;
top: 50px;
left: 0;
right: 0;
bottom: 0;
height: auto;
z-index: 8;
border-right: none !important;
border-bottom-right-radius: 0 !important;
}
.EasyMDEContainer .CodeMirror-sided {
width: 50% !important;
}
.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
border-right: none!important;
border-bottom-right-radius: 0px;
position: relative;
flex: 1 1 auto;
}
.EasyMDEContainer .CodeMirror-placeholder {
opacity: .5;
}
.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected {
background: #d9d9d9;
}
.editor-toolbar {
position: relative;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
padding: 9px 10px;
border-top: 1px solid #bbb;
border-left: 1px solid #bbb;
border-right: 1px solid #bbb;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
}
.editor-toolbar.fullscreen {
width: 100%;
height: 50px;
padding-top: 10px;
padding-bottom: 10px;
box-sizing: border-box;
background: #fff;
border: 0;
position: fixed;
top: 0;
left: 0;
opacity: 1;
z-index: 9;
}
.editor-toolbar.fullscreen::before {
width: 20px;
height: 50px;
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
position: fixed;
top: 0;
left: 0;
margin: 0;
padding: 0;
}
.editor-toolbar.fullscreen::after {
width: 20px;
height: 50px;
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
position: fixed;
top: 0;
right: 0;
margin: 0;
padding: 0;
}
.EasyMDEContainer.sided--no-fullscreen .editor-toolbar {
width: 100%;
}
.editor-toolbar button, .editor-toolbar .easymde-dropdown {
background: transparent;
display: inline-block;
text-align: center;
text-decoration: none !important;
height: 30px;
margin: 0;
padding: 0;
border: 1px solid transparent;
border-radius: 3px;
cursor: pointer;
}
.editor-toolbar button {
width: 30px;
}
.editor-toolbar button.active,
.editor-toolbar button:hover {
background: #fcfcfc;
border-color: #95a5a6;
}
.editor-toolbar i.separator {
display: inline-block;
width: 0;
border-left: 1px solid #d9d9d9;
border-right: 1px solid #fff;
color: transparent;
text-indent: -10px;
margin: 0 6px;
}
.editor-toolbar button:after {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 65%;
vertical-align: text-bottom;
position: relative;
top: 2px;
}
.editor-toolbar button.heading-1:after {
content: "1";
}
.editor-toolbar button.heading-2:after {
content: "2";
}
.editor-toolbar button.heading-3:after {
content: "3";
}
.editor-toolbar button.heading-bigger:after {
content: "▲";
}
.editor-toolbar button.heading-smaller:after {
content: "▼";
}
.editor-toolbar.disabled-for-preview button:not(.no-disable) {
opacity: .6;
pointer-events: none;
}
@media only screen and (max-width: 700px) {
.editor-toolbar i.no-mobile {
display: none;
}
}
.editor-statusbar {
padding: 8px 10px;
font-size: 12px;
color: #959694;
text-align: right;
}
.EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
width: 100%;
}
.editor-statusbar span {
display: inline-block;
min-width: 4em;
margin-left: 1em;
}
.editor-statusbar .lines:before {
content: 'lines: '
}
.editor-statusbar .words:before {
content: 'words: '
}
.editor-statusbar .characters:before {
content: 'characters: '
}
.editor-preview-full {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 7;
overflow: auto;
display: none;
box-sizing: border-box;
}
.editor-preview-side {
position: fixed;
bottom: 0;
width: 50%;
top: 50px;
right: 0;
z-index: 9;
overflow: auto;
display: none;
box-sizing: border-box;
border: 1px solid #ddd;
word-wrap: break-word;
}
.editor-preview-active-side {
display: block
}
.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
flex: 1 1 auto;
height: auto;
position: static;
}
.editor-preview-active {
display: block
}
.editor-preview {
padding: 10px;
background: #fafafa;
}
.editor-preview > p {
margin-top: 0
}
.editor-preview pre {
background: #eee;
margin-bottom: 10px;
}
.editor-preview table td,
.editor-preview table th {
border: 1px solid #ddd;
padding: 5px;
}
.cm-s-easymde .cm-tag {
color: #63a35c;
}
.cm-s-easymde .cm-attribute {
color: #795da3;
}
.cm-s-easymde .cm-string {
color: #183691;
}
.cm-s-easymde .cm-header-1 {
font-size: 200%;
line-height: 200%;
}
.cm-s-easymde .cm-header-2 {
font-size: 160%;
line-height: 160%;
}
.cm-s-easymde .cm-header-3 {
font-size: 125%;
line-height: 125%;
}
.cm-s-easymde .cm-header-4 {
font-size: 110%;
line-height: 110%;
}
.cm-s-easymde .cm-comment {
background: rgba(0, 0, 0, .05);
border-radius: 2px;
}
.cm-s-easymde .cm-link {
color: #7f8c8d;
}
.cm-s-easymde .cm-url {
color: #aab2b3;
}
.cm-s-easymde .cm-quote {
color: #7f8c8d;
font-style: italic;
}
.editor-toolbar .easymde-dropdown {
position: relative;
background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%);
border-radius: 0;
border: 1px solid #fff;
}
.editor-toolbar .easymde-dropdown:hover {
background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%);
}
.easymde-dropdown-content {
display: block;
visibility: hidden;
position: absolute;
background-color: #f9f9f9;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
padding: 8px;
z-index: 2;
top: 30px;
}
.easymde-dropdown:active .easymde-dropdown-content,
.easymde-dropdown:focus .easymde-dropdown-content {
visibility: visible;
}
span[data-img-src]::after{
content: '';
background-image: var(--bg-image);
display: block;
max-height: 100%;
max-width: 100%;
background-size: contain;
height: 0;
padding-top: var(--height);
width: var(--width);
background-repeat: no-repeat;
}

View File

@ -0,0 +1,157 @@
<template>
<div class="vue-easymde">
<textarea
class="vue-simplemde-textarea"
:name="name"
:value="modelValue"
@input="handleInput($event.target.value)"
/>
</div>
</template>
<script>
import EasyMDE from 'easymde'
import marked from 'marked'
export default {
name: 'vue-easymde',
props: {
modelValue: String,
name: String,
previewClass: String,
autoinit: {
type: Boolean,
default: true,
},
highlight: {
type: Boolean,
default: false,
},
sanitize: {
type: Boolean,
default: false,
},
configs: {
type: Object,
default() {
return {}
},
},
previewRender: {
type: Function,
},
},
emits: ['update:modelValue', 'blur', 'initialized'],
data() {
return {
isValueUpdateFromInner: false,
easymde: null,
}
},
mounted() {
if (this.autoinit) this.initialize()
},
deactivated() {
const editor = this.easymde
if (!editor) return
const isFullScreen = editor.codemirror.getOption('fullScreen')
if (isFullScreen) editor.toggleFullScreen()
},
beforeUnmount() {
if (this.easymde) {
this.easymde.toTextArea()
this.easymde.cleanup()
this.easymde = null
}
},
methods: {
initialize() {
const configs = Object.assign({
element: this.$el.firstElementChild,
initialValue: this.modelValue,
previewRender: this.previewRender,
renderingConfig: {},
}, this.configs)
// Synchronize the values of value and initialValue
if (configs.initialValue) {
this.$emit('update:modelValue', configs.initialValue)
}
// Determine whether to enable code highlighting
if (this.highlight) {
configs.renderingConfig.codeSyntaxHighlighting = true
}
// Set whether to render the input html
marked.setOptions({ sanitize: this.sanitize })
// Instantiated editor
this.easymde = new EasyMDE(configs)
// Add a custom previewClass
const className = this.previewClass || ''
this.addPreviewClass(className)
// Binding event
this.bindingEvents()
this.$nextTick(() => {
this.$emit('initialized', this.easymde)
})
},
addPreviewClass(className) {
const wrapper = this.easymde.codemirror.getWrapperElement()
const preview = document.createElement('div')
wrapper.nextSibling.className += ` ${className}`
preview.className = `editor-preview ${className}`
wrapper.appendChild(preview)
},
bindingEvents() {
this.easymde.codemirror.on('change', this.handleCodemirrorInput)
this.easymde.codemirror.on('blur', this.handleCodemirrorBlur)
},
handleCodemirrorInput(instance, changeObj) {
if (changeObj.origin === 'setValue') {
return
}
const val = this.easymde.value()
this.handleInput(val)
},
handleCodemirrorBlur() {
const val = this.easymde.value()
this.isValueUpdateFromInner = true
this.$emit('blur', val)
},
handleInput(val) {
this.isValueUpdateFromInner = true
this.$emit('update:modelValue', val)
},
},
watch: {
modelValue(val) {
if (this.isValueUpdateFromInner) {
this.isValueUpdateFromInner = false
} else {
this.easymde.value(val)
}
},
},
}
</script>
<style lang="scss" scoped>
.vue-easymde .markdown-body {
padding: 0.5em
}
.vue-easymde .editor-preview-active, .vue-easymde .editor-preview-active-side {
display: block;
}
</style>

View File

@ -2,13 +2,13 @@
<dropdown> <dropdown>
<template v-if="isSavedFilter"> <template v-if="isSavedFilter">
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.edit`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.edit`, params: { listId: list.id } }"
icon="pen" icon="pen"
> >
{{ $t('menu.edit') }} {{ $t('menu.edit') }}
</dropdown-item> </dropdown-item>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.delete`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.delete`, params: { listId: list.id } }"
icon="trash-alt" icon="trash-alt"
> >
{{ $t('misc.delete') }} {{ $t('misc.delete') }}
@ -16,7 +16,7 @@
</template> </template>
<template v-else-if="list.isArchived"> <template v-else-if="list.isArchived">
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.archive`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.archive`, params: { listId: list.id } }"
icon="archive" icon="archive"
> >
{{ $t('menu.unarchive') }} {{ $t('menu.unarchive') }}
@ -24,32 +24,32 @@
</template> </template>
<template v-else> <template v-else>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.edit`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.edit`, params: { listId: list.id } }"
icon="pen" icon="pen"
> >
{{ $t('menu.edit') }} {{ $t('menu.edit') }}
</dropdown-item> </dropdown-item>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.background`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.background`, params: { listId: list.id } }"
v-if="backgroundsEnabled" v-if="backgroundsEnabled"
icon="image" icon="image"
> >
{{ $t('menu.setBackground') }} {{ $t('menu.setBackground') }}
</dropdown-item> </dropdown-item>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.share`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.share`, params: { listId: list.id } }"
icon="share-alt" icon="share-alt"
> >
{{ $t('menu.share') }} {{ $t('menu.share') }}
</dropdown-item> </dropdown-item>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.duplicate`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.duplicate`, params: { listId: list.id } }"
icon="paste" icon="paste"
> >
{{ $t('menu.duplicate') }} {{ $t('menu.duplicate') }}
</dropdown-item> </dropdown-item>
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.archive`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.archive`, params: { listId: list.id } }"
icon="archive" icon="archive"
> >
{{ $t('menu.archive') }} {{ $t('menu.archive') }}
@ -63,7 +63,7 @@
@change="sub => subscription = sub" @change="sub => subscription = sub"
/> />
<dropdown-item <dropdown-item
:to="{ name: `${listRoutePrefix}.settings.delete`, params: { listId: list.id } }" :to="{ name: `${listRoutePrefix}.delete`, params: { listId: list.id } }"
icon="trash-alt" icon="trash-alt"
class="has-text-danger" class="has-text-danger"
> >
@ -106,15 +106,19 @@ export default {
listRoutePrefix() { listRoutePrefix() {
let name = 'list' let name = 'list'
if (this.$route.name !== null && this.$route.name.startsWith('list.')) { if (this.$route.name !== null && this.$route.name.startsWith('list.')) {
name = this.$route.name // HACK: we should implement a better routing for the modals
const settingsRoutes = ['edit', 'delete', 'archive', 'background', 'share', 'duplicate']
const suffix = settingsRoutes.find((route) => this.$route.name.endsWith(`.settings.${route}`))
name = this.$route.name.replace(`.settings.${suffix}`,'')
} }
if (this.isSavedFilter) { if (this.isSavedFilter) {
name = name.replace('list.', 'filter.') name = name.replace('list.', 'filter.')
} }
return name return `${name}.settings`
}, },
isSavedFilter() { isSavedFilter() {
return getSavedFilterIdFromListId(this.list.id) > 0 return getSavedFilterIdFromListId(this.list.id) > 0

View File

@ -1,9 +1,8 @@
<template> <template>
<transition name="fade"> <transition name="fade">
<filters <filters
@change="change"
v-if="visibleInternal" v-if="visibleInternal"
v-model="params" v-model="value"
ref="filters" ref="filters"
/> />
</transition> </transition>
@ -15,23 +14,42 @@ import Filters from '../../../components/list/partials/filters'
export default { export default {
name: 'filter-popup', name: 'filter-popup',
components: {
Filters,
},
props: {
modelValue: {
required: true,
},
visible: {
type: Boolean,
default: false,
},
},
emits: ['update:modelValue'],
data() { data() {
return { return {
params: null,
visibleInternal: false, visibleInternal: false,
} }
}, },
components: { computed: {
Filters, value: {
get() {
return this.modelValue
},
set(value) {
this.$emit('update:modelValue', value)
},
},
}, },
mounted() { mounted() {
document.addEventListener('click', this.hidePopup) document.addEventListener('click', this.hidePopup)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hidePopup) document.removeEventListener('click', this.hidePopup)
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.params = value this.params = value
}, },
@ -41,26 +59,15 @@ export default {
this.visibleInternal = !this.visibleInternal this.visibleInternal = !this.visibleInternal
}, },
}, },
props: {
value: {
required: true,
},
visible: {
type: Boolean,
default: false,
},
},
methods: { methods: {
change() {
this.$emit('change', this.params)
this.$emit('input', this.params)
},
hidePopup(e) { hidePopup(e) {
if (this.visibleInternal) { if (!this.visibleInternal) {
closeWhenClickedOutside(e, this.$refs.filters.$el, () => { return
this.visibleInternal = false
})
} }
closeWhenClickedOutside(e, this.$refs.filters.$el, () => {
this.visibleInternal = false
})
}, },
}, },
} }

View File

@ -35,7 +35,7 @@
<label class="label">{{ $t('task.attributes.priority') }}</label> <label class="label">{{ $t('task.attributes.priority') }}</label>
<div class="control single-value-control"> <div class="control single-value-control">
<priority-select <priority-select
:disabled="!filters.usePriority" :disabled="!filters.usePriority || null"
v-model.number="filters.priority" v-model.number="filters.priority"
@change="setPriority" @change="setPriority"
/> />
@ -53,7 +53,7 @@
<percent-done-select <percent-done-select
v-model.number="filters.percentDone" v-model.number="filters.percentDone"
@change="setPercentDoneFilter" @change="setPercentDoneFilter"
:disabled="!filters.usePercentDone" :disabled="!filters.usePercentDone || null"
/> />
<fancycheckbox <fancycheckbox
v-model="filters.usePercentDone" v-model="filters.usePercentDone"
@ -253,12 +253,13 @@ export default {
this.filters.requireAllFilters = this.params.filter_concat === 'and' this.filters.requireAllFilters = this.params.filter_concat === 'and'
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.params = value this.params = value
this.prepareFilters() this.prepareFilters()
@ -286,7 +287,7 @@ export default {
}, },
methods: { methods: {
change() { change() {
this.$emit('input', this.params) this.$emit('update:modelValue', this.params)
this.$emit('change', this.params) this.$emit('change', this.params)
}, },
prepareFilters() { prepareFilters() {
@ -342,11 +343,11 @@ export default {
this.params.filter_by.forEach((f, i) => { this.params.filter_by.forEach((f, i) => {
if (f === filterName && this.params.filter_comparator[i] === 'greater_equals') { if (f === filterName && this.params.filter_comparator[i] === 'greater_equals') {
foundStart = true foundStart = true
this.$set(this.params.filter_value, i, formatISO(new Date(parts[0]))) this.params.filter_value[i] = formatISO(new Date(parts[0]))
} }
if (f === filterName && this.params.filter_comparator[i] === 'less_equals') { if (f === filterName && this.params.filter_comparator[i] === 'less_equals') {
foundEnd = true foundEnd = true
this.$set(this.params.filter_value, i, formatISO(new Date(parts[1]))) this.params.filter_value[i] = formatISO(new Date(parts[1]))
} }
}) })
@ -404,7 +405,7 @@ export default {
this.params.filter_by.forEach((f, i) => { this.params.filter_by.forEach((f, i) => {
if (f === filterName) { if (f === filterName) {
found = true found = true
this.$set(this.params.filter_value, i, this.filters[variableName]) this.params.filter_value[i] = this.filters[variableName]
} }
}) })
@ -464,10 +465,10 @@ export default {
} }
}) })
if (foundDone === false) { if (foundDone === false) {
this.$set(this.filters, 'done', true) this.filters.done = true
} }
}, },
prepareRelatedObjectFilter(kind, filterName = null, servicePrefix = null) { async prepareRelatedObjectFilter(kind, filterName = null, servicePrefix = null) {
if (filterName === null) { if (filterName === null) {
filterName = kind filterName = kind
} }
@ -477,13 +478,11 @@ export default {
} }
this.prepareSingleValue(filterName) this.prepareSingleValue(filterName)
if (typeof this.filters[filterName] !== 'undefined' && this.filters[filterName] !== '') { if (typeof this.filters[filterName] === 'undefined' || this.filters[filterName] === '') {
this[`${servicePrefix}Service`].getAll({}, {s: this.filters[filterName]}) return
.then(r => {
this.$set(this, kind, r)
})
.catch(e => this.$message.error(e))
} }
this[kind] = await this[`${servicePrefix}Service`].getAll({}, {s: this.filters[filterName]})
}, },
setDoneFilter() { setDoneFilter() {
if (this.filters.done) { if (this.filters.done) {
@ -521,24 +520,18 @@ export default {
this.setDateFilter('reminders') this.setDateFilter('reminders')
}, },
clear(kind) { clear(kind) {
this.$set(this, `found${kind}`, []) this[`found${kind}`] = []
}, },
find(kind, query) { async find(kind, query) {
if (query === '') { if (query === '') {
this.clear(kind) this.clear(kind)
} }
this[`${kind}Service`].getAll({}, {s: query}) const response = await this[`${kind}Service`].getAll({}, {s: query})
.then(response => {
// Filter users from the results who are already assigned
const unassignedUsers = response.filter(({id}) => !includesById(this[kind], id))
this.$set(this, `found${kind}`, unassignedUsers) // Filter users from the results who are already assigned
}) this[`found${kind}`] = response.filter(({id}) => !includesById(this[kind], id))
.catch(e => {
this.$message.error(e)
})
}, },
add(kind, filterName) { add(kind, filterName) {
this.$nextTick(() => { this.$nextTick(() => {
@ -562,7 +555,7 @@ export default {
ids.push(u.id) ids.push(u.id)
}) })
this.$set(this.filters, filterName, ids.join(',')) this.filters[filterName] = ids.join(',')
this.setSingleValueFilter(filterName, filterName, '', 'in') this.setSingleValueFilter(filterName, filterName, '', 'in')
}, },
findLabels(query) { findLabels(query) {
@ -597,7 +590,7 @@ export default {
labelIDs.push(u.id) labelIDs.push(u.id)
}) })
this.$set(this.filters, 'labels', labelIDs.join(',')) this.filters.labels = labelIDs.join(',')
this.setSingleValueFilter('labels', 'labels', '', 'in') this.setSingleValueFilter('labels', 'labels', '', 'in')
}, },
}, },

View File

@ -56,7 +56,7 @@ export default {
}, },
}, },
methods: { methods: {
loadBackground() { async loadBackground() {
if (this.list === null || !this.list.backgroundInformation || this.backgroundLoading) { if (this.list === null || !this.list.backgroundInformation || this.backgroundLoading) {
return return
} }
@ -64,14 +64,11 @@ export default {
this.backgroundLoading = true this.backgroundLoading = true
const listService = new ListService() const listService = new ListService()
listService.background(this.list) try {
.then(b => { this.background = await listService.background(this.list)
this.$set(this, 'background', b) } finally {
}) this.backgroundLoading = false
.catch(e => { }
this.$message.error(e)
})
.finally(() => this.backgroundLoading = false)
}, },
toggleFavoriteList(list) { toggleFavoriteList(list) {
// The favorites pseudo list is always favorite // The favorites pseudo list is always favorite
@ -80,7 +77,6 @@ export default {
return return
} }
this.$store.dispatch('lists/toggleListFavorite', list) this.$store.dispatch('lists/toggleListFavorite', list)
.catch(e => this.$message.error(e))
}, },
}, },
} }

View File

@ -13,7 +13,7 @@
/> />
<x-button <x-button
:loading="migrationService.loading" :loading="migrationService.loading"
:disabled="migrationService.loading" :disabled="migrationService.loading || null"
@click="$refs.uploadInput.click()" @click="$refs.uploadInput.click()"
> >
{{ $t('migrate.upload') }} {{ $t('migrate.upload') }}
@ -23,7 +23,7 @@
<p>{{ $t('migrate.authorize', {name: name}) }}</p> <p>{{ $t('migrate.authorize', {name: name}) }}</p>
<x-button <x-button
:loading="migrationService.loading" :loading="migrationService.loading"
:disabled="migrationService.loading" :disabled="migrationService.loading || null"
:href="authUrl" :href="authUrl"
> >
{{ $t('migrate.getStarted') }} {{ $t('migrate.getStarted') }}
@ -138,58 +138,35 @@ export default {
} }
this.migrate() this.migrate()
}) })
.catch(e => {
this.$message.error(e)
})
} }
}, },
methods: { methods: {
getAuthUrl() { async getAuthUrl() {
this.migrationService.getAuthUrl() const { url } = await this.migrationService.getAuthUrl()
.then(r => { this.authUrl = url
this.authUrl = r.url
})
.catch(e => {
this.$message.error(e)
})
}, },
migrate() {
async migrate() {
this.isMigrating = true this.isMigrating = true
this.lastMigrationDate = null this.lastMigrationDate = null
this.message = '' this.message = ''
let migrationConfig = { code: this.migratorAuthCode }
if (this.isFileMigrator) { if (this.isFileMigrator) {
return this.migrateFile() if (this.$refs.uploadInput.files.length === 0) {
return
}
migrationConfig = this.$refs.uploadInput.files[0]
} }
this.migrationService.migrate({code: this.migratorAuthCode}) try {
.then(r => { const { message } = await this.migrationService.migrate(migrationConfig)
this.message = r.message this.message = message
this.$store.dispatch('namespaces/loadNamespaces') return this.$store.dispatch('namespaces/loadNamespaces')
}) } finally {
.catch(e => { this.isMigrating = false
this.$message.error(e)
})
.finally(() => {
this.isMigrating = false
})
},
migrateFile() {
if (this.$refs.uploadInput.files.length === 0) {
return
} }
this.migrationService.migrate(this.$refs.uploadInput.files[0])
.then(r => {
this.message = r.message
this.$store.dispatch('namespaces/loadNamespaces')
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.isMigrating = false
})
}, },
}, },
} }

View File

@ -16,16 +16,16 @@
/> />
</div> </div>
<div class="control"> <div class="control">
<x-button @click="setApiUrl" :disabled="apiUrl === ''"> <x-button @click="setApiUrl" :disabled="apiUrl === '' || null">
{{ $t('apiConfig.change') }} {{ $t('apiConfig.change') }}
</x-button> </x-button>
</div> </div>
</div> </div>
</div> </div>
<div class="api-url-info" v-else> <div class="api-url-info" v-else>
<i18n path="apiConfig.signInOn"> <i18n-t keypath="apiConfig.signInOn">
<span class="url" v-tooltip="apiUrl"> {{ apiDomain }} </span> <span class="url" v-tooltip="apiUrl"> {{ apiDomain }} </span>
</i18n> </i18n-t>
<br /> <br />
<a @click="() => (configureApi = true)">{{ $t('apiConfig.change') }}</a> <a @click="() => (configureApi = true)">{{ $t('apiConfig.change') }}</a>
</div> </div>
@ -60,6 +60,7 @@ export default {
successMsg: '', successMsg: '',
} }
}, },
emits: ['foundApi'],
created() { created() {
if (this.apiUrl === '') { if (this.apiUrl === '') {
this.configureApi = true this.configureApi = true
@ -105,7 +106,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it has a port and if not check if it is reachable at https // Check if it has a port and if not check if it is reachable at https
@ -114,7 +115,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it is reachable at /api/v1 and https // Check if it is reachable at /api/v1 and https
@ -127,7 +128,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it is reachable at port API_DEFAULT_PORT and https // Check if it is reachable at port API_DEFAULT_PORT and https
@ -137,7 +138,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it is reachable at :API_DEFAULT_PORT and /api/v1 and https // Check if it is reachable at :API_DEFAULT_PORT and /api/v1 and https
@ -150,7 +151,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it is reachable at port API_DEFAULT_PORT and http // Check if it is reachable at port API_DEFAULT_PORT and http
@ -160,7 +161,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch((e) => { .catch((e) => {
// Check if it is reachable at :API_DEFAULT_PORT and /api/v1 and http // Check if it is reachable at :API_DEFAULT_PORT and /api/v1 and http
@ -173,7 +174,7 @@ export default {
window.API_URL = urlToCheck.toString() window.API_URL = urlToCheck.toString()
return this.$store.dispatch('config/update') return this.$store.dispatch('config/update')
} }
return Promise.reject(e) throw e
}) })
.catch(() => { .catch(() => {
// Still not found, url is still invalid // Still not found, url is still invalid

View File

@ -51,5 +51,6 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['close'],
} }
</script> </script>

View File

@ -43,6 +43,8 @@
</template> </template>
<script> <script>
import { i18n } from '@/i18n'
export default { export default {
name: 'create-edit', name: 'create-edit',
props: { props: {
@ -53,7 +55,7 @@ export default {
primaryLabel: { primaryLabel: {
type: String, type: String,
default() { default() {
return this.$t('misc.create') return i18n.global.t('misc.create')
}, },
}, },
primaryIcon: { primaryIcon: {
@ -77,6 +79,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['create', 'primary', 'tertary'],
methods: { methods: {
primary() { primary() {
this.$emit('create') this.$emit('create')

View File

@ -1,14 +1,14 @@
<template> <template>
<div class="dropdown is-right is-active" ref="dropdown"> <div class="dropdown is-right is-active" ref="dropdown">
<div class="dropdown-trigger" @click="open = !open"> <div class="dropdown-trigger" @click="open = !open">
<slot name="trigger"> <slot name="trigger" :close="close">
<icon :icon="triggerIcon" class="icon"/> <icon :icon="triggerIcon" class="icon"/>
</slot> </slot>
</div> </div>
<transition name="fade"> <transition name="fade">
<div class="dropdown-menu" v-if="open"> <div class="dropdown-menu" v-if="open">
<div class="dropdown-content"> <div class="dropdown-content">
<slot></slot> <slot :close="close"></slot>
</div> </div>
</div> </div>
</transition> </transition>
@ -26,10 +26,10 @@ export default {
} }
}, },
mounted() { mounted() {
document.addEventListener('click', this.hide) document.addEventListener('click', this.handleClickOutside)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hide) document.removeEventListener('click', this.handleClickOutside)
}, },
props: { props: {
triggerIcon: { triggerIcon: {
@ -37,14 +37,22 @@ export default {
default: 'ellipsis-h', default: 'ellipsis-h',
}, },
}, },
emits: ['close'],
methods: { methods: {
hide(e) { close() {
if (this.open) { this.open = false
closeWhenClickedOutside(e, this.$refs.dropdown, () => { },
this.open = false toggleOpen() {
this.$emit('close', e) this.open = !this.open
}) },
handleClickOutside(e) {
if (!this.open) {
return
} }
closeWhenClickedOutside(e, this.$refs.dropdown, () => {
this.open = false
this.$emit('close', e)
})
}, },
}, },
} }

View File

@ -1,9 +1,9 @@
<template> <template>
<div class="notification is-danger"> <div class="notification is-danger">
<i18n path="loadingError.failed"> <i18n-t keypath="loadingError.failed">
<a @click="() => location.reload()">{{ $t('loadingError.tryAgain') }}</a> <a @click="() => location.reload()">{{ $t('loadingError.tryAgain') }}</a>
<a href="https://vikunja.io/contact/" rel="noreferrer noopener nofollow" target="_blank">{{ $t('loadingError.contact') }}</a> <a href="https://vikunja.io/contact/" rel="noreferrer noopener nofollow" target="_blank">{{ $t('loadingError.contact') }}</a>
</i18n> </i18n-t>
</div> </div>
</template> </template>

View File

@ -11,7 +11,7 @@
> >
<div v-if="item.title" class="notification-title">{{ item.title }}</div> <div v-if="item.title" class="notification-title">{{ item.title }}</div>
<div class="notification-content"> <div class="notification-content">
<template v-for="(t, k) in item.text">{{ t }}<br :key="k"/></template> <template v-for="(t, k) in item.text" :key="k">{{ t }}<br /></template>
</div> </div>
<div <div
class="buttons is-right" class="buttons is-right"

View File

@ -1,42 +1,39 @@
<template> <template>
<nav <nav
aria-label="pagination" aria-label="pagination"
class="pagination is-centered p-4" class="pagination is-centered p-4"
role="navigation" role="navigation"
v-if="totalPages > 1" v-if="totalPages > 1"
> >
<router-link <router-link
:disabled="currentPage === 1" :disabled="currentPage === 1 || null"
:to="getRouteForPagination(currentPage - 1)" :to="getRouteForPagination(currentPage - 1)"
class="pagination-previous" class="pagination-previous"
tag="button"> tag="button">
{{ $t('misc.previous') }} {{ $t('misc.previous') }}
</router-link> </router-link>
<router-link <router-link
:disabled="currentPage === totalPages" :disabled="currentPage === totalPages || null"
:to="getRouteForPagination(currentPage + 1)" :to="getRouteForPagination(currentPage + 1)"
class="pagination-next" class="pagination-next"
tag="button"> tag="button">
{{ $t('misc.next') }} {{ $t('misc.next') }}
</router-link> </router-link>
<ul class="pagination-list"> <ul class="pagination-list">
<template v-for="(p, i) in pages"> <li :key="`page-${i}`" v-for="(p, i) in pages">
<li :key="'page' + i" v-if="p.isEllipsis"> <span class="pagination-ellipsis" v-if="p.isEllipsis">&hellip;</span>
<span class="pagination-ellipsis">&hellip;</span> <router-link
</li> :aria-label="'Goto page ' + p.number"
<li :key="'page' + i" v-else> :class="{ 'is-current': p.number === currentPage }"
<router-link :to="getRouteForPagination(p.number)"
:aria-label="'Goto page ' + p.number" class="pagination-link"
:class="{ 'is-current': p.number === currentPage }" v-else
:to="getRouteForPagination(p.number)" >
class="pagination-link" {{ p.number }}
> </router-link>
{{ p.number }} </li>
</router-link> </ul>
</li> </nav>
</template>
</ul>
</nav>
</template> </template>
<script> <script>
@ -112,14 +109,14 @@ export default {
<style lang="scss" scoped> <style lang="scss" scoped>
.pagination { .pagination {
padding-bottom: 1rem; padding-bottom: 1rem;
.pagination-previous, .pagination-previous,
.pagination-next { .pagination-next {
&:not(:disabled):hover { &:not(:disabled):hover {
background: $scheme-main; background: $scheme-main;
cursor: pointer; cursor: pointer;
} }
} }
} }
</style> </style>

View File

@ -1,8 +1,8 @@
<template> <template>
<span class="shortcuts"> <span class="shortcuts">
<template v-for="(k, i) in keys"> <template v-for="(k, i) in keys" :key="i">
<kbd :key="i">{{ k }}</kbd> <kbd>{{ k }}</kbd>
<span v-if="i < keys.length - 1" :key="`plus${i}`">+</span> <span v-if="i < keys.length - 1">+</span>
</template> </template>
</span> </span>
</template> </template>

View File

@ -4,7 +4,7 @@
:icon="icon" :icon="icon"
v-tooltip="tooltipText" v-tooltip="tooltipText"
@click="changeSubscription" @click="changeSubscription"
:disabled="disabled" :disabled="disabled || null"
v-if="isButton" v-if="isButton"
> >
{{ buttonText }} {{ buttonText }}
@ -49,6 +49,7 @@ export default {
default: true, default: true,
}, },
}, },
emits: ['change'],
computed: { computed: {
tooltipText() { tooltipText() {
if (this.disabled) { if (this.disabled) {
@ -88,33 +89,23 @@ export default {
this.unsubscribe() this.unsubscribe()
} }
}, },
subscribe() { async subscribe() {
const subscription = new SubscriptionModel({ const subscription = new SubscriptionModel({
entity: this.entity, entity: this.entity,
entityId: this.entityId, entityId: this.entityId,
}) })
this.subscriptionService.create(subscription) await this.subscriptionService.create(subscription)
.then(() => { this.$emit('change', subscription)
this.$emit('change', subscription) this.$message.success({message: this.$t('task.subscription.subscribeSuccess', {entity: this.entity})})
this.$message.success({message: this.$t('task.subscription.subscribeSuccess', {entity: this.entity})})
})
.catch(e => {
this.$message.error(e)
})
}, },
unsubscribe() { async unsubscribe() {
const subscription = new SubscriptionModel({ const subscription = new SubscriptionModel({
entity: this.entity, entity: this.entity,
entityId: this.entityId, entityId: this.entityId,
}) })
this.subscriptionService.delete(subscription) await this.subscriptionService.delete(subscription)
.then(() => { this.$emit('change', null)
this.$emit('change', null) this.$message.success({message: this.$t('task.subscription.unsubscribeSuccess', {entity: this.entity})})
this.$message.success({message: this.$t('task.subscription.unsubscribeSuccess', {entity: this.entity})})
})
.catch(e => {
this.$message.error(e)
})
}, },
}, },
} }

View File

@ -102,6 +102,7 @@ export default {
validator: validValue(VARIANTS), validator: validValue(VARIANTS),
}, },
}, },
emits: ['close', 'submit'],
} }
</script> </script>

View File

@ -14,6 +14,7 @@ import Multiselect from '@/components/input/multiselect.vue'
export default { export default {
name: 'namespace-search', name: 'namespace-search',
emits: ['selected'],
data() { data() {
return { return {
query: '', query: '',

View File

@ -72,7 +72,7 @@ export default {
document.addEventListener('click', this.hidePopup) document.addEventListener('click', this.hidePopup)
this.interval = setInterval(this.loadNotifications, LOAD_NOTIFICATIONS_INTERVAL) this.interval = setInterval(this.loadNotifications, LOAD_NOTIFICATIONS_INTERVAL)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hidePopup) document.removeEventListener('click', this.hidePopup)
clearInterval(this.interval) clearInterval(this.interval)
}, },
@ -93,14 +93,8 @@ export default {
closeWhenClickedOutside(e, this.$refs.popup, () => this.showNotifications = false) closeWhenClickedOutside(e, this.$refs.popup, () => this.showNotifications = false)
} }
}, },
loadNotifications() { async loadNotifications() {
this.notificationService.getAll() this.allNotifications = await this.notificationService.getAll()
.then(r => {
this.$set(this, 'allNotifications', r)
})
.catch(e => {
this.$message.error(e)
})
}, },
to(n, index) { to(n, index) {
const to = { const to = {
@ -127,17 +121,13 @@ export default {
break break
} }
return () => { return async () => {
if (to.name !== '') { if (to.name !== '') {
this.$router.push(to) this.$router.push(to)
} }
n.read = true n.read = true
this.notificationService.update(n) this.allNotifications[index] = await this.notificationService.update(n)
.then(r => {
this.$set(this.allNotifications, index, r)
})
.catch(e => this.$message.error(e))
} }
}, },
}, },

View File

@ -61,7 +61,6 @@ import TeamModel from '@/models/team'
import {CURRENT_LIST, LOADING, LOADING_MODULE, QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types' import {CURRENT_LIST, LOADING, LOADING_MODULE, QUICK_ACTIONS_ACTIVE} from '@/store/mutation-types'
import ListModel from '@/models/list' import ListModel from '@/models/list'
import createTask from '@/components/tasks/mixins/createTask'
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue' import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
import {getHistory} from '../../modules/listHistory' import {getHistory} from '../../modules/listHistory'
@ -97,9 +96,6 @@ export default {
teamService: new TeamService(), teamService: new TeamService(),
} }
}, },
mixins: [
createTask,
],
computed: { computed: {
active() { active() {
const active = this.$store.state[QUICK_ACTIONS_ACTIVE] const active = this.$store.state[QUICK_ACTIONS_ACTIVE]
@ -286,20 +282,17 @@ export default {
this.taskSearchTimeout = null this.taskSearchTimeout = null
} }
this.taskSearchTimeout = setTimeout(() => { this.taskSearchTimeout = setTimeout(async () => {
this.taskService.getAll({}, {s: query}) const r = await this.taskService.getAll({}, {s: query})
.then(r => { this.foundTasks = r.map(t => {
r = r.map(t => { t.type = TYPE_TASK
t.type = TYPE_TASK const list = this.$store.getters['lists/getListById'](t.listId)
const list = this.$store.getters['lists/getListById'](t.listId) === null ? null : this.$store.getters['lists/getListById'](t.listId) if (list !== null) {
if (list !== null) { t.title = `${t.title} (${list.title})`
t.title = `${t.title} (${list.title})` }
}
return t return t
}) })
this.$set(this, 'foundTasks', r)
})
}, 150) }, 150)
}, },
searchTeams() { searchTeams() {
@ -322,15 +315,12 @@ export default {
this.teamSearchTimeout = null this.teamSearchTimeout = null
} }
this.teamSearchTimeout = setTimeout(() => { this.teamSearchTimeout = setTimeout(async () => {
this.teamService.getAll({}, {s: query}) const r = await this.teamService.getAll({}, {s: query})
.then(r => { this.foundTeams = r.map(t => {
r = r.map(t => { t.title = t.name
t.title = t.name return t
return t })
})
this.$set(this, 'foundTeams', r)
})
}, 150) }, 150)
}, },
closeQuickActions() { closeQuickActions() {
@ -382,22 +372,20 @@ export default {
break break
} }
}, },
newTask() { async newTask() {
if (this.currentList === null) { if (this.currentList === null) {
return return
} }
this.createNewTask(this.query, 0, this.currentList.id) const task = await this.$store.dispatch('tasks/createNewTask', {
.then(r => { title: this.query,
this.$message.success({message: this.$t('task.createSuccess')}) listId: this.currentList.id,
this.$router.push({name: 'task.detail', params: {id: r.id}}) })
this.closeQuickActions() this.$message.success({message: this.$t('task.createSuccess')})
}) this.$router.push({name: 'task.detail', params: {id: task.id}})
.catch((e) => { this.closeQuickActions()
this.$message.error(e)
})
}, },
newList() { async newList() {
if (this.currentList === null) { if (this.currentList === null) {
return return
} }
@ -406,42 +394,27 @@ export default {
title: this.query, title: this.query,
namespaceId: this.currentList.namespaceId, namespaceId: this.currentList.namespaceId,
}) })
this.$store.dispatch('lists/createList', newList) const list = await this.$store.dispatch('lists/createList', newList)
.then(r => { this.$message.success({message: this.$t('list.create.createdSuccess')})
this.$message.success({message: this.$t('list.create.createdSuccess')}) this.$router.push({name: 'list.index', params: {listId: list.id}})
this.$router.push({name: 'list.index', params: {listId: r.id}}) this.closeQuickActions()
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
}, },
newNamespace() { async newNamespace() {
const newNamespace = new NamespaceModel({title: this.query}) const newNamespace = new NamespaceModel({title: this.query})
this.$store.dispatch('namespaces/createNamespace', newNamespace) await this.$store.dispatch('namespaces/createNamespace', newNamespace)
.then(() => { this.$message.success({message: this.$t('namespace.create.success')})
this.$message.success({message: this.$t('namespace.create.success')}) this.closeQuickActions()
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
}, },
newTeam() { async newTeam() {
const newTeam = new TeamModel({name: this.query}) const newTeam = new TeamModel({name: this.query})
this.teamService.create(newTeam) const team = await this.teamService.create(newTeam)
.then(r => { this.$router.push({
this.$router.push({ name: 'teams.edit',
name: 'teams.edit', params: {id: team.id},
params: {id: r.id}, })
}) this.$message.success({message: this.$t('team.create.success')})
this.$message.success({message: this.$t('team.create.success')}) this.closeQuickActions()
this.closeQuickActions()
})
.catch((e) => {
this.$message.error(e)
})
}, },
select(parentIndex, index) { select(parentIndex, index) {

View File

@ -68,7 +68,7 @@
/> />
</div> </div>
</div> </div>
<x-button @click="add" icon="plus"> <x-button @click="add(listId)" icon="plus">
{{ $t('list.share.share') }} {{ $t('list.share.share') }}
</x-button> </x-button>
</div> </div>
@ -160,7 +160,7 @@
<transition name="modal"> <transition name="modal">
<modal <modal
@close="showDeleteModal = false" @close="showDeleteModal = false"
@submit="remove()" @submit="remove(listId)"
v-if="showDeleteModal" v-if="showDeleteModal"
> >
<template #header> <template #header>
@ -215,59 +215,41 @@ export default {
frontendUrl: (state) => state.config.frontendUrl, frontendUrl: (state) => state.config.frontendUrl,
}), }),
methods: { methods: {
load() { async load(listId) {
// If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here // If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here
if (this.listId === 0) { if (listId === 0) {
return return
} }
this.linkShareService this.linkShares = await this.linkShareService.getAll({listId})
.getAll({listId: this.listId})
.then((r) => {
this.linkShares = r
})
.catch((e) => {
this.$message.error(e)
})
}, },
add() { async add(listId) {
const newLinkShare = new LinkShareModel({ const newLinkShare = new LinkShareModel({
right: this.selectedRight, right: this.selectedRight,
listId: this.listId, listId,
name: this.name, name: this.name,
password: this.password, password: this.password,
}) })
this.linkShareService await this.linkShareService.create(newLinkShare)
.create(newLinkShare) this.selectedRight = rights.READ
.then(() => { this.name = ''
this.selectedRight = rights.READ this.password = ''
this.name = '' this.showNewForm = false
this.password = '' this.$message.success({message: this.$t('list.share.links.createSuccess')})
this.showNewForm = false await this.load(listId)
this.$message.success({message: this.$t('list.share.links.createSuccess')})
this.load()
})
.catch((e) => {
this.$message.error(e)
})
}, },
remove() { async remove(listId) {
const linkshare = new LinkShareModel({ const linkshare = new LinkShareModel({
id: this.linkIdToDelete, id: this.linkIdToDelete,
listId: this.listId, listId,
}) })
this.linkShareService try {
.delete(linkshare) await this.linkShareService.delete(linkshare)
.then(() => { this.$message.success({message: this.$t('list.share.links.deleteSuccess')})
this.$message.success({message: this.$t('list.share.links.deleteSuccess')}) await this.load(listId)
this.load() } finally {
}) this.showDeleteModal = false
.catch((e) => { }
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})
}, },
copy, copy,
getShareLink(hash) { getShareLink(hash) {

View File

@ -272,45 +272,34 @@ export default {
this.load() this.load()
}, },
methods: { methods: {
load() { async load() {
this.stuffService this.sharables = await this.stuffService.getAll(this.stuffModel)
.getAll(this.stuffModel) this.sharables.forEach((s) =>
.then((r) => { this.selectedRight[s.id] = s.right,
this.$set(this, 'sharables', r) )
r.forEach((s) =>
this.$set(this.selectedRight, s.id, s.right),
)
})
.catch((e) => {
this.$message.error(e)
})
}, },
deleteSharable() {
async deleteSharable() {
if (this.shareType === 'user') { if (this.shareType === 'user') {
this.stuffModel.userId = this.sharable.username this.stuffModel.userId = this.sharable.username
} else if (this.shareType === 'team') { } else if (this.shareType === 'team') {
this.stuffModel.teamId = this.sharable.id this.stuffModel.teamId = this.sharable.id
} }
this.stuffService await this.stuffService.delete(this.stuffModel)
.delete(this.stuffModel) this.showDeleteModal = false
.then(() => { for (const i in this.sharables) {
this.showDeleteModal = false if (
for (const i in this.sharables) { (this.sharables[i].username === this.stuffModel.userId && this.shareType === 'user') ||
if ( (this.sharables[i].id === this.stuffModel.teamId && this.shareType === 'team')
(this.sharables[i].username === this.stuffModel.userId && this.shareType === 'user') || ) {
(this.sharables[i].id === this.stuffModel.teamId && this.shareType === 'team') this.sharables.splice(i, 1)
) { }
this.sharables.splice(i, 1) }
} this.$message.success({message: this.$t('list.share.userTeam.removeSuccess', {type: this.shareTypeName, sharable: this.sharableName})})
}
this.$message.success({message: this.$t('list.share.userTeam.removeSuccess', {type: this.shareTypeName, sharable: this.sharableName})})
})
.catch((e) => {
this.$message.error(e)
})
}, },
add(admin) {
async add(admin) {
if (admin === null) { if (admin === null) {
admin = false admin = false
} }
@ -325,17 +314,12 @@ export default {
this.stuffModel.teamId = this.sharable.id this.stuffModel.teamId = this.sharable.id
} }
this.stuffService await this.stuffService.create(this.stuffModel)
.create(this.stuffModel) this.$message.success({message: this.$t('list.share.userTeam.addedSuccess', {type: this.shareTypeName})})
.then(() => { await this.load()
this.$message.success({message: this.$t('list.share.userTeam.addedSuccess', {type: this.shareTypeName})})
this.load()
})
.catch((e) => {
this.$message.error(e)
})
}, },
toggleType(sharable) {
async toggleType(sharable) {
if ( if (
this.selectedRight[sharable.id] !== rights.ADMIN && this.selectedRight[sharable.id] !== rights.ADMIN &&
this.selectedRight[sharable.id] !== rights.READ && this.selectedRight[sharable.id] !== rights.READ &&
@ -351,43 +335,32 @@ export default {
this.stuffModel.teamId = sharable.id this.stuffModel.teamId = sharable.id
} }
this.stuffService const r = await this.stuffService.update(this.stuffModel)
.update(this.stuffModel) for (const i in this.sharables) {
.then((r) => { if (
for (const i in this.sharables) { (this.sharables[i].username ===
if ( this.stuffModel.userId &&
(this.sharables[i].username === this.shareType === 'user') ||
this.stuffModel.userId && (this.sharables[i].id === this.stuffModel.teamId &&
this.shareType === 'user') || this.shareType === 'team')
(this.sharables[i].id === this.stuffModel.teamId && ) {
this.shareType === 'team') this.sharables[i].right = r.right
) { }
this.$set(this.sharables[i], 'right', r.right) }
} this.$message.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})})
}
this.$message.success({message: this.$t('list.share.userTeam.updatedSuccess', {type: this.shareTypeName})})
})
.catch((e) => {
this.$message.error(e)
})
}, },
find(query) {
async find(query) {
if (query === '') { if (query === '') {
this.$set(this, 'found', []) this.clearAll()
return return
} }
this.searchService this.found = await this.searchService.getAll({}, {s: query})
.getAll({}, {s: query})
.then((response) => {
this.$set(this, 'found', response)
})
.catch((e) => {
this.$message.error(e)
})
}, },
clearAll() { clearAll() {
this.$set(this, 'found', []) this.found = []
}, },
}, },
} }

View File

@ -38,7 +38,6 @@
<script> <script>
import TaskService from '../../services/task' import TaskService from '../../services/task'
import createTask from '@/components/tasks/mixins/createTask'
import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue' import QuickAddMagic from '@/components/tasks/partials/quick-add-magic.vue'
const INPUT_BORDER_PX = 2 const INPUT_BORDER_PX = 2
@ -50,6 +49,7 @@ const cleanupTitle = title => {
export default { export default {
name: 'add-task', name: 'add-task',
emits: ['taskAdded'],
data() { data() {
return { return {
newTaskTitle: '', newTaskTitle: '',
@ -59,9 +59,6 @@ export default {
initialTextAreaHeight: null, initialTextAreaHeight: null,
} }
}, },
mixins: [
createTask,
],
components: { components: {
QuickAddMagic, QuickAddMagic,
}, },
@ -85,7 +82,7 @@ export default {
this.initialTextAreaHeight = this.$refs.newTaskInput.scrollHeight + INPUT_BORDER_PX this.initialTextAreaHeight = this.$refs.newTaskInput.scrollHeight + INPUT_BORDER_PX
}, },
methods: { methods: {
addTask() { async addTask() {
if (this.newTaskTitle === '') { if (this.newTaskTitle === '') {
this.errorMessage = this.$t('list.create.addTitleRequired') this.errorMessage = this.$t('list.create.addTitleRequired')
return return
@ -96,33 +93,31 @@ export default {
return return
} }
const newTasks = [] const newTasks = this.newTaskTitle.split(/[\r\n]+/).map(async t => {
this.newTaskTitle.split(/[\r\n]+/).forEach(t => {
const title = cleanupTitle(t) const title = cleanupTitle(t)
if (title === '') { if (title === '') {
return return
} }
newTasks.push( const task = await this.$store.dispatch('tasks/createNewTask', {
this.createNewTask(title, 0, this.$store.state.auth.settings.defaultListId, this.defaultPosition) title: this.newTaskTitle,
.then(task => { listId: this.$store.state.auth.settings.defaultListId,
this.$emit('taskAdded', task) position: this.defaultPosition,
return task })
}), this.$emit('taskAdded', task)
) return task
}) })
Promise.all(newTasks) try {
.then(() => { await Promise.all(newTasks)
this.newTaskTitle = '' this.newTaskTitle = ''
}) } catch(e) {
.catch(e => { if (e.message === 'NO_LIST') {
if (e === 'NO_LIST') { this.errorMessage = this.$t('list.create.addListRequired')
this.errorMessage = this.$t('list.create.addListRequired') return
return }
} throw e
this.$message.error(e) }
})
}, },
handleEnter(e) { handleEnter(e) {
// when pressing shift + enter we want to continue as we normally would. Otherwise, we want to create // when pressing shift + enter we want to continue as we normally would. Otherwise, we want to create

View File

@ -69,6 +69,8 @@
</template> </template>
<script> <script>
import AsyncEditor from '@/components/input/AsyncEditor'
import ListService from '../../services/list' import ListService from '../../services/list'
import TaskService from '../../services/task' import TaskService from '../../services/task'
import TaskModel from '../../models/task' import TaskModel from '../../models/task'
@ -76,8 +78,6 @@ import priorities from '../../models/constants/priorities'
import EditLabels from './partials/editLabels' import EditLabels from './partials/editLabels'
import Reminders from './partials/reminders' import Reminders from './partials/reminders'
import ColorPicker from '../input/colorPicker' import ColorPicker from '../input/colorPicker'
import LoadingComponent from '../misc/loading'
import ErrorComponent from '../misc/error'
export default { export default {
name: 'edit-task', name: 'edit-task',
@ -99,12 +99,7 @@ export default {
ColorPicker, ColorPicker,
Reminders, Reminders,
EditLabels, EditLabels,
editor: () => ({ editor: AsyncEditor,
component: import('../../components/input/editor'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
}),
}, },
props: { props: {
task: { task: {
@ -139,17 +134,10 @@ export default {
this.editorActive = false this.editorActive = false
this.$nextTick(() => (this.editorActive = true)) this.$nextTick(() => (this.editorActive = true))
}, },
editTaskSubmit() { async editTaskSubmit() {
this.taskService this.taskEditTask = await this.taskService.update(this.taskEditTask)
.update(this.taskEditTask) this.initTaskFields()
.then((r) => { this.$message.success({message: this.$t('task.detail.updateSuccess')})
this.$set(this, 'taskEditTask', r)
this.initTaskFields()
this.$message.success({message: this.$t('task.detail.updateSuccess')})
})
.catch((e) => {
this.$message.error(e)
})
}, },
}, },
} }

View File

@ -11,14 +11,14 @@
</x-button> </x-button>
</div> </div>
<filter-popup <filter-popup
@change="loadTasks()"
:visible="showTaskFilter" :visible="showTaskFilter"
v-model="params" v-model="params"
@update:modelValue="loadTasks()"
/> />
</div> </div>
<div class="dates"> <div class="dates">
<template v-for="(y, yk) in days"> <template v-for="(y, yk) in days" :key="yk + 'year'">
<div :key="yk + 'year'" class="months"> <div class="months">
<div <div
:key="mk + 'month'" :key="mk + 'month'"
class="month" class="month"
@ -86,9 +86,8 @@
:w="t.durationDays * dayWidth" :w="t.durationDays * dayWidth"
:x="t.offsetDays * dayWidth - 6" :x="t.offsetDays * dayWidth - 6"
:y="0" :y="0"
@clicked="setTaskDragged(t)" @dragstop="(e) => resizeTask(t, e)"
@dragstop="resizeTask" @resizestop="(e) => resizeTask(t, e)"
@resizestop="resizeTask"
axis="x" axis="x"
class="task" class="task"
> >
@ -136,9 +135,8 @@
:sticks="['mr', 'ml']" :sticks="['mr', 'ml']"
:x="dayOffsetUntilToday * dayWidth - 6" :x="dayOffsetUntilToday * dayWidth - 6"
:y="0" :y="0"
@clicked="setTaskDragged(t)" @dragstop="(e) => resizeTask(t, e)"
@dragstop="resizeTask" @resizestop="(e) => resizeTask(t, e)"
@resizestop="resizeTask"
axis="x" axis="x"
class="task nodate" class="task nodate"
v-tooltip="$t('list.gantt.noDates')" v-tooltip="$t('list.gantt.noDates')"
@ -232,7 +230,6 @@ export default {
theTasks: [], // Pretty much a copy of the prop, since we cant mutate the prop directly theTasks: [], // Pretty much a copy of the prop, since we cant mutate the prop directly
tasksWithoutDates: [], tasksWithoutDates: [],
taskService: new TaskService(), taskService: new TaskService(),
taskDragged: null, // Saves to currently dragged task to be able to update it
fullWidth: 0, fullWidth: 0,
now: new Date(), now: new Date(),
dayOffsetUntilToday: 0, dayOffsetUntilToday: 0,
@ -298,56 +295,43 @@ export default {
this.fullWidth += this.dayWidth this.fullWidth += this.dayWidth
} }
console.debug('prepareGanttDays; years:', years) console.debug('prepareGanttDays; years:', years)
this.$set(this, 'days', years) this.days = years
}, },
parseTasks() { parseTasks() {
this.setDates() this.setDates()
this.loadTasks() this.loadTasks()
}, },
loadTasks() {
this.$set(this, 'theTasks', [])
this.$set(this, 'tasksWithoutDates', [])
const getAllTasks = (page = 1) => { async loadTasks() {
return this.taskCollectionService this.theTasks = []
.getAll({listId: this.listId}, this.params, page) this.tasksWithoutDates = []
.then((tasks) => {
if (page < this.taskCollectionService.totalPages) { const getAllTasks = async (page = 1) => {
return getAllTasks(page + 1).then((nextTasks) => { const tasks = await this.taskCollectionService.getAll({listId: this.listId}, this.params, page)
return tasks.concat(nextTasks) if (page < this.taskCollectionService.totalPages) {
}) const nextTasks = await getAllTasks(page + 1)
} else { return tasks.concat(nextTasks)
return tasks }
} return tasks
})
.catch((e) => {
return Promise.reject(e)
})
} }
getAllTasks() const tasks = await getAllTasks()
.then((tasks) => { this.theTasks = tasks
this.theTasks = tasks .filter((t) => {
.filter((t) => { if (t.startDate === null && !t.done) {
if (t.startDate === null && !t.done) { this.tasksWithoutDates.push(t)
this.tasksWithoutDates.push(t) }
} return (
return ( t.startDate >= this.startDate &&
t.startDate >= this.startDate && t.endDate <= this.endDate
t.endDate <= this.endDate )
)
})
.map((t) => {
return this.addGantAttributes(t)
})
.sort(function (a, b) {
if (a.startDate < b.startDate) return -1
if (a.startDate > b.startDate) return 1
return 0
})
}) })
.catch((e) => { .map((t) => this.addGantAttributes(t))
this.$message.error(e) .sort(function (a, b) {
if (a.startDate < b.startDate) return -1
if (a.startDate > b.startDate) return 1
return 0
}) })
}, },
addGantAttributes(t) { addGantAttributes(t) {
@ -360,15 +344,14 @@ export default {
t.offsetDays = Math.floor((t.startDate - this.startDate) / 1000 / 60 / 60 / 24) t.offsetDays = Math.floor((t.startDate - this.startDate) / 1000 / 60 / 60 / 24)
return t return t
}, },
setTaskDragged(t) { async resizeTask(taskDragged, newRect) {
this.taskDragged = t
},
resizeTask(newRect) {
if (this.isTaskEdit) { if (this.isTaskEdit) {
return return
} }
const didntHaveDates = this.taskDragged.startDate === null ? true : false let newTask = { ...taskDragged }
const didntHaveDates = newTask.startDate === null ? true : false
let startDate = new Date(this.startDate) let startDate = new Date(this.startDate)
startDate.setDate( startDate.setDate(
@ -378,62 +361,52 @@ export default {
startDate.setUTCMinutes(0) startDate.setUTCMinutes(0)
startDate.setUTCSeconds(0) startDate.setUTCSeconds(0)
startDate.setUTCMilliseconds(0) startDate.setUTCMilliseconds(0)
this.taskDragged.startDate = startDate newTask.startDate = startDate
let endDate = new Date(startDate) let endDate = new Date(startDate)
endDate.setDate( endDate.setDate(
startDate.getDate() + newRect.width / this.dayWidth, startDate.getDate() + newRect.width / this.dayWidth,
) )
this.taskDragged.startDate = startDate newTask.startDate = startDate
this.taskDragged.endDate = endDate newTask.endDate = endDate
// We take the task from the overall tasks array because the one in it has bad data after it was updated once. // We take the task from the overall tasks array because the one in it has bad data after it was updated once.
// FIXME: This is a workaround. We should use a better mechanism to get the task or, even better, // FIXME: This is a workaround. We should use a better mechanism to get the task or, even better,
// prevent it from containing outdated Data in the first place. // prevent it from containing outdated Data in the first place.
for (const tt in this.theTasks) { for (const tt in this.theTasks) {
if (this.theTasks[tt].id === this.taskDragged.id) { if (this.theTasks[tt].id === newTask.id) {
this.$set(this, 'taskDragged', this.theTasks[tt]) newTask = this.theTasks[tt]
break break
} }
} }
const ganttData = { const ganttData = {
endDate: this.taskDragged.endDate, endDate: newTask.endDate,
durationDays: this.taskDragged.durationDays, durationDays: newTask.durationDays,
offsetDays: this.taskDragged.offsetDays, offsetDays: newTask.offsetDays,
} }
this.taskService const r = await this.taskService.update(newTask)
.update(this.taskDragged) r.endDate = ganttData.endDate
.then(r => { r.durationDays = ganttData.durationDays
r.endDate = ganttData.endDate r.offsetDays = ganttData.offsetDays
r.durationDays = ganttData.durationDays
r.offsetDays = ganttData.offsetDays
// If the task didn't have dates before, we'll update the list // If the task didn't have dates before, we'll update the list
if (didntHaveDates) { if (didntHaveDates) {
for (const t in this.tasksWithoutDates) { for (const t in this.tasksWithoutDates) {
if (this.tasksWithoutDates[t].id === r.id) { if (this.tasksWithoutDates[t].id === r.id) {
this.tasksWithoutDates.splice(t, 1) this.tasksWithoutDates.splice(t, 1)
break break
}
}
this.theTasks.push(this.addGantAttributes(r))
} else {
for (const tt in this.theTasks) {
if (this.theTasks[tt].id === r.id) {
this.$set(
this.theTasks,
tt,
this.addGantAttributes(r),
)
break
}
}
} }
}) }
.catch((e) => { this.theTasks.push(this.addGantAttributes(r))
this.$message.error(e) } else {
}) for (const tt in this.theTasks) {
if (this.theTasks[tt].id === r.id) {
this.theTasks[tt] = this.addGantAttributes(r)
break
}
}
}
}, },
editTask(task) { editTask(task) {
this.taskToEdit = task this.taskToEdit = task
@ -453,7 +426,7 @@ export default {
this.$nextTick(() => (this.newTaskFieldActive = false)) this.$nextTick(() => (this.newTaskFieldActive = false))
} }
}, },
addNewTask() { async addNewTask() {
if (!this.newTaskFieldActive) { if (!this.newTaskFieldActive) {
return return
} }
@ -461,16 +434,10 @@ export default {
title: this.newTaskTitle, title: this.newTaskTitle,
listId: this.listId, listId: this.listId,
}) })
this.taskService const r = await this.taskService.create(task)
.create(task) this.tasksWithoutDates.push(this.addGantAttributes(r))
.then((r) => { this.newTaskTitle = ''
this.tasksWithoutDates.push(this.addGantAttributes(r)) this.hideCrateNewTask()
this.newTaskTitle = ''
this.hideCrateNewTask()
})
.catch((e) => {
this.$message.error(e)
})
}, },
formatYear(date) { formatYear(date) {
return this.format(date, 'MMMM, yyyy') return this.format(date, 'MMMM, yyyy')

View File

@ -1,141 +0,0 @@
import {parseTaskText} from '@/modules/parseTaskText'
import TaskModel from '@/models/task'
import {formatISO} from 'date-fns'
import LabelTask from '@/models/labelTask'
import LabelModel from '@/models/label'
import LabelTaskService from '@/services/labelTask'
import {mapState} from 'vuex'
import UserService from '@/services/user'
import TaskService from '@/services/task'
import {getQuickAddMagicMode} from '@/helpers/quickAddMagicMode'
export default {
data() {
return {
taskService: TaskService,
labelTaskService: LabelTaskService,
userService: UserService,
}
},
created() {
this.labelTaskService = new LabelTaskService()
this.userService = new UserService()
this.taskService = new TaskService()
},
computed: mapState({
labels: state => state.labels.labels,
}),
methods: {
createNewTask(newTaskTitle, bucketId = 0, lId = 0, position = 0) {
const parsedTask = parseTaskText(newTaskTitle, getQuickAddMagicMode())
const assignees = []
// Uses the following ways to get the list id of the new task:
// 1. If specified in quick add magic, look in store if it exists and use it if it does
// 2. Else check if a list was passed as parameter
// 3. Otherwise use the id from the route parameter
// 4. If none of the above worked, reject the promise with an error.
let listId = null
if (parsedTask.list !== null) {
const list = this.$store.getters['lists/findListByExactname'](parsedTask.list)
listId = list === null ? null : list.id
}
if (listId === null && lId !== 0) {
listId = lId
}
if (typeof this.$route.params.listId !== 'undefined') {
listId = parseInt(this.$route.params.listId)
}
if (typeof listId === 'undefined' || listId === null) {
return Promise.reject('NO_LIST')
}
// Separate closure because we need to wait for the results of the user search if users were entered in the
// task create request. Because _that_ happens in a promise, we'll need something to call when it resolves.
const createTask = () => {
const task = new TaskModel({
title: parsedTask.text,
listId: listId,
dueDate: parsedTask.date !== null ? formatISO(parsedTask.date) : null, // I don't know why, but it all goes up in flames when I just pass in the date normally.
priority: parsedTask.priority,
assignees: assignees,
bucketId: bucketId,
position: position,
})
return this.taskService.create(task)
.then(task => {
if (parsedTask.labels.length > 0) {
const labelAddsToWaitFor = []
const addLabelToTask = label => {
const labelTask = new LabelTask({
taskId: task.id,
labelId: label.id,
})
return this.labelTaskService.create(labelTask)
.then(result => {
task.labels.push(label)
return Promise.resolve(result)
})
.catch(e => Promise.reject(e))
}
// Then do everything that is involved in finding, creating and adding the label to the task
parsedTask.labels.forEach(labelTitle => {
// Check if the label exists
const label = Object.values(this.labels).find(l => {
return l.title.toLowerCase() === labelTitle.toLowerCase()
})
// Label found, use it
if (typeof label !== 'undefined') {
labelAddsToWaitFor.push(addLabelToTask(label))
} else {
// label not found, create it
const label = new LabelModel({title: labelTitle})
labelAddsToWaitFor.push(this.$store.dispatch('labels/createLabel', label)
.then(res => {
return addLabelToTask(res)
})
.catch(e => Promise.reject(e)),
)
}
})
// This waits until all labels are created and added to the task
return Promise.all(labelAddsToWaitFor)
.then(() => {
return Promise.resolve(task)
})
}
return Promise.resolve(task)
})
.catch(e => Promise.reject(e))
}
if (parsedTask.assignees.length > 0) {
const searches = []
parsedTask.assignees.forEach(a => {
searches.push(this.userService.getAll({}, {s: a})
.then(users => {
const user = users.find(u => u.username.toLowerCase() === a.toLowerCase())
if (typeof user !== 'undefined') {
assignees.push(user)
}
return Promise.resolve(users)
}),
)
})
return Promise.all(searches)
.then(() => createTask())
}
return createTask()
},
},
}

View File

@ -38,7 +38,7 @@ export default {
'$route.path': 'loadTasksOnSavedFilter', '$route.path': 'loadTasksOnSavedFilter',
}, },
methods: { methods: {
loadTasks( async loadTasks(
page, page,
search = '', search = '',
params = null, params = null,
@ -76,17 +76,9 @@ export default {
} }
this.tasks = [] this.tasks = []
this.tasks = await this.taskCollectionService.getAll(list, params, page)
this.taskCollectionService.getAll(list, params, page) this.currentPage = page
.then(r => { this.loadedList = JSON.parse(JSON.stringify(currentList))
this.tasks = r
this.currentPage = page
this.loadedList = JSON.parse(JSON.stringify(currentList))
})
.catch(e => {
this.$message.error(e)
})
}, },
loadTasksForPage(e) { loadTasksForPage(e) {

View File

@ -35,7 +35,7 @@
<div class="filename">{{ a.file.name }}</div> <div class="filename">{{ a.file.name }}</div>
<div class="info"> <div class="info">
<p class="collapses"> <p class="collapses">
<i18n path="task.attachment.createdBy"> <i18n-t keypath="task.attachment.createdBy">
<span v-tooltip="formatDate(a.created)"> <span v-tooltip="formatDate(a.created)">
{{ formatDateSince(a.created) }} {{ formatDateSince(a.created) }}
</span> </span>
@ -44,7 +44,7 @@
:user="a.createdBy" :user="a.createdBy"
:is-inline="true" :is-inline="true"
/> />
</i18n> </i18n-t>
<span> <span>
{{ a.file.getHumanSize() }} {{ a.file.getHumanSize() }}
</span> </span>
@ -218,24 +218,19 @@ export default {
uploadFiles(files) { uploadFiles(files) {
uploadFiles(this.attachmentService, this.taskId, files) uploadFiles(this.attachmentService, this.taskId, files)
}, },
deleteAttachment() { async deleteAttachment() {
this.attachmentService try {
.delete(this.attachmentToDelete) const r = await this.attachmentService.delete(this.attachmentToDelete)
.then((r) => { this.$store.commit(
this.$store.commit( 'attachments/removeById',
'attachments/removeById', this.attachmentToDelete.id,
this.attachmentToDelete.id, )
) this.$message.success(r)
this.$message.success(r) } finally{
}) this.showDeleteModal = false
.catch((e) => { }
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})
}, },
viewOrDownload(attachment) { async viewOrDownload(attachment) {
if ( if (
attachment.file.name.endsWith('.jpg') || attachment.file.name.endsWith('.jpg') ||
attachment.file.name.endsWith('.png') || attachment.file.name.endsWith('.png') ||
@ -243,9 +238,7 @@ export default {
attachment.file.name.endsWith('.gif') attachment.file.name.endsWith('.gif')
) { ) {
this.showImageModal = true this.showImageModal = true
this.attachmentService.getBlobUrl(attachment).then((url) => { this.attachmentImageBlobUrl = await this.attachmentService.getBlobUrl(attachment)
this.attachmentImageBlobUrl = url
})
} else { } else {
this.downloadAttachment(attachment) this.downloadAttachment(attachment)
} }

View File

@ -66,7 +66,7 @@
</transition> </transition>
</div> </div>
<editor <editor
:has-preview="true" :hasPreview="true"
:is-edit-enabled="canWrite" :is-edit-enabled="canWrite"
:upload-callback="attachmentUpload" :upload-callback="attachmentUpload"
:upload-enabled="true" :upload-enabled="true"
@ -110,7 +110,7 @@
taskCommentService.loading && taskCommentService.loading &&
!isCommentEdit, !isCommentEdit,
}" }"
:has-preview="false" :hasPreview="false"
:upload-callback="attachmentUpload" :upload-callback="attachmentUpload"
:upload-enabled="true" :upload-enabled="true"
:placeholder="$t('task.comment.placeholder')" :placeholder="$t('task.comment.placeholder')"
@ -134,9 +134,9 @@
<transition name="modal"> <transition name="modal">
<modal <modal
@close="showDeleteModal = false"
@submit="deleteComment()"
v-if="showDeleteModal" v-if="showDeleteModal"
@close="showDeleteModal = false"
@submit="() => deleteComment(commentToDelete)"
> >
<template #header><span>{{ $t('task.comment.delete') }}</span></template> <template #header><span>{{ $t('task.comment.delete') }}</span></template>
@ -152,22 +152,17 @@
</template> </template>
<script> <script>
import AsyncEditor from '@/components/input/AsyncEditor'
import TaskCommentService from '../../../services/taskComment' import TaskCommentService from '../../../services/taskComment'
import TaskCommentModel from '../../../models/taskComment' import TaskCommentModel from '../../../models/taskComment'
import LoadingComponent from '../../misc/loading'
import ErrorComponent from '../../misc/error'
import {uploadFile} from '@/helpers/attachments' import {uploadFile} from '@/helpers/attachments'
import {mapState} from 'vuex' import {mapState} from 'vuex'
export default { export default {
name: 'comments', name: 'comments',
components: { components: {
editor: () => ({ editor: AsyncEditor,
component: import('../../input/editor'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
}),
}, },
props: { props: {
taskId: { taskId: {
@ -191,7 +186,6 @@ export default {
taskCommentService: new TaskCommentService(), taskCommentService: new TaskCommentService(),
newComment: new TaskCommentModel(), newComment: new TaskCommentModel(),
editorActive: true, editorActive: true,
actions: {},
saved: null, saved: null,
saving: null, saving: null,
@ -200,43 +194,46 @@ export default {
}, },
watch: { watch: {
taskId: { taskId: {
handler(taskId) { handler: 'loadComments',
if (!this.enabled) {
return
}
this.loadComments()
this.newComment.taskId = taskId
this.commentEdit.taskId = taskId
this.commentToDelete.taskId = taskId
},
immediate: true, immediate: true,
}, },
canWrite() { },
this.makeActions() computed: {
...mapState({
userAvatar: state => state.auth.info.getAvatarUrl(48),
enabled: state => state.config.taskCommentsEnabled,
}),
actions() {
if (!this.canWrite) {
return {}
}
return Object.fromEntries(this.comments.map((c) => ([
c.id,
[{
action: () => this.toggleDelete(c.id),
title: this.$t('misc.delete'),
}],
])))
}, },
}, },
computed: mapState({
userAvatar: state => state.auth.info.getAvatarUrl(48),
enabled: state => state.config.taskCommentsEnabled,
}),
methods: { methods: {
attachmentUpload(...args) { attachmentUpload(...args) {
return uploadFile(this.taskId, ...args) return uploadFile(this.taskId, ...args)
}, },
loadComments() { async loadComments(taskId) {
this.taskCommentService if (!this.enabled) {
.getAll({taskId: this.taskId}) return
.then(r => { }
this.$set(this, 'comments', r)
this.makeActions() this.newComment.taskId = taskId
}) this.commentEdit.taskId = taskId
.catch((e) => { this.commentToDelete.taskId = taskId
this.$message.error(e) this.comments = await this.taskCommentService.getAll({taskId})
})
}, },
addComment() {
async addComment() {
if (this.newComment.comment === '') { if (this.newComment.comment === '') {
return return
} }
@ -250,30 +247,27 @@ export default {
this.$nextTick(() => (this.editorActive = true)) this.$nextTick(() => (this.editorActive = true))
this.creating = true this.creating = true
this.taskCommentService try {
.create(this.newComment) const comment = await this.taskCommentService.create(this.newComment)
.then((r) => { this.comments.push(comment)
this.comments.push(r) this.newComment.comment = ''
this.newComment.comment = '' this.$message.success({message: this.$t('task.comment.addedSuccess')})
this.$message.success({message: this.$t('task.comment.addedSuccess')}) } finally {
this.makeActions() this.creating = false
}) }
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.creating = false
})
}, },
toggleEdit(comment) { toggleEdit(comment) {
this.isCommentEdit = !this.isCommentEdit this.isCommentEdit = !this.isCommentEdit
this.commentEdit = comment this.commentEdit = comment
}, },
toggleDelete(commentId) { toggleDelete(commentId) {
this.showDeleteModal = !this.showDeleteModal this.showDeleteModal = !this.showDeleteModal
this.commentToDelete.id = commentId this.commentToDelete.id = commentId
}, },
editComment() {
async editComment() {
if (this.commentEdit.comment === '') { if (this.commentEdit.comment === '') {
return return
} }
@ -281,54 +275,30 @@ export default {
this.saving = this.commentEdit.id this.saving = this.commentEdit.id
this.commentEdit.taskId = this.taskId this.commentEdit.taskId = this.taskId
this.taskCommentService try {
.update(this.commentEdit) const comment = this.taskCommentService.update(this.commentEdit)
.then((r) => { for (const c in this.comments) {
for (const c in this.comments) { if (this.comments[c].id === this.commentEdit.id) {
if (this.comments[c].id === this.commentEdit.id) { this.comments[c] = comment
this.$set(this.comments, c, r)
}
} }
this.saved = this.commentEdit.id }
setTimeout(() => { this.saved = this.commentEdit.id
this.saved = null setTimeout(() => {
}, 2000) this.saved = null
}) }, 2000)
.catch((e) => { } finally {
this.$message.error(e) this.isCommentEdit = false
}) this.saving = null
.finally(() => { }
this.isCommentEdit = false
this.saving = null
})
}, },
deleteComment() {
this.taskCommentService async deleteComment(commentToDelete) {
.delete(this.commentToDelete) try {
.then(() => { await this.taskCommentService.delete(commentToDelete)
for (const a in this.comments) { const index = this.comments.findIndex(({id}) => id === commentToDelete.id)
if (this.comments[a].id === this.commentToDelete.id) { this.comments.splice(index, 1)
this.comments.splice(a, 1) } finally {
} this.showDeleteModal = false
}
})
.catch((e) => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
})
},
makeActions() {
if (this.canWrite) {
this.comments.forEach((c) => {
this.$set(this.actions, c.id, [
{
action: () => this.toggleDelete(c.id),
title: this.$t('misc.delete'),
},
])
})
} }
}, },
}, },

View File

@ -57,12 +57,14 @@ export default {
flatPickr, flatPickr,
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
this.dueDate = value.dueDate this.dueDate = value.dueDate
@ -83,7 +85,7 @@ export default {
this.changeInterval = setInterval(this.updateDueDate, 1000) this.changeInterval = setInterval(this.updateDueDate, 1000)
}, },
beforeDestroy() { beforeUnmount() {
if (this.changeInterval) { if (this.changeInterval) {
clearInterval(this.changeInterval) clearInterval(this.changeInterval)
} }
@ -110,7 +112,8 @@ export default {
this.dueDate = this.dueDate.setDate(this.dueDate.getDate() + days) this.dueDate = this.dueDate.setDate(this.dueDate.getDate() + days)
this.updateDueDate() this.updateDueDate()
}, },
updateDueDate() {
async updateDueDate() {
if (!this.dueDate) { if (!this.dueDate) {
return return
} }
@ -120,16 +123,10 @@ export default {
} }
this.task.dueDate = new Date(this.dueDate) this.task.dueDate = new Date(this.dueDate)
this.taskService const task = await this.taskService.update(this.task)
.update(this.task) this.lastValue = task.dueDate
.then((r) => { this.task = task
this.lastValue = r.dueDate this.$emit('update:modelValue', task)
this.task = r
this.$emit('input', r)
})
.catch((e) => {
this.$message.error(e)
})
}, },
}, },
} }

View File

@ -30,8 +30,7 @@
</template> </template>
<script> <script>
import LoadingComponent from '@/components/misc/loading.vue' import AsyncEditor from '@/components/input/AsyncEditor'
import ErrorComponent from '@/components/misc/error.vue'
import {LOADING} from '@/store/mutation-types' import {LOADING} from '@/store/mutation-types'
import {mapState} from 'vuex' import {mapState} from 'vuex'
@ -39,12 +38,7 @@ import {mapState} from 'vuex'
export default { export default {
name: 'description', name: 'description',
components: { components: {
editor: () => ({ editor: AsyncEditor,
component: import('@/components/input/editor.vue'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
}),
}, },
data() { data() {
return { return {
@ -57,7 +51,7 @@ export default {
loading: LOADING, loading: LOADING,
}), }),
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
attachmentUpload: { attachmentUpload: {
@ -67,8 +61,9 @@ export default {
required: true, required: true,
}, },
}, },
emits: ['update:modelValue'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
}, },
@ -76,24 +71,19 @@ export default {
}, },
}, },
methods: { methods: {
save() { async save() {
this.saving = true this.saving = true
this.$store.dispatch('tasks/update', this.task) try {
.then(t => { this.task = await this.$store.dispatch('tasks/update', this.task)
this.task = t this.$emit('update:modelValue', this.task)
this.$emit('input', t) this.saved = true
this.saved = true setTimeout(() => {
setTimeout(() => { this.saved = false
this.saved = false }, 2000)
}, 2000) } finally {
}) this.saving = false
.catch(e => { }
this.$message.error(e)
})
.finally(() => {
this.saving = false
})
}, },
}, },
} }

View File

@ -6,7 +6,6 @@
<multiselect <multiselect
:loading="listUserService.loading" :loading="listUserService.loading"
:placeholder="$t('task.assignee.placeholder')" :placeholder="$t('task.assignee.placeholder')"
:disabled="disabled"
:multiple="true" :multiple="true"
@search="findUser" @search="findUser"
:search-results="foundUsers" :search-results="foundUsers"
@ -54,10 +53,11 @@ export default {
disabled: { disabled: {
default: false, default: false,
}, },
value: { modelValue: {
type: Array, type: Array,
}, },
}, },
emits: ['update:modelValue'],
data() { data() {
return { return {
newAssignee: new UserModel(), newAssignee: new UserModel(),
@ -68,59 +68,49 @@ export default {
} }
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.assignees = value this.assignees = value
}, },
immediate: true, immediate: true,
deep: true,
}, },
}, },
methods: { methods: {
addAssignee(user) { async addAssignee(user) {
this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId}) await this.$store.dispatch('tasks/addAssignee', {user: user, taskId: this.taskId})
.then(() => { this.$emit('update:modelValue', this.assignees)
this.$emit('input', this.assignees) this.$message.success({message: this.$t('task.assignee.assignSuccess')})
this.$message.success({message: this.$t('task.assignee.assignSuccess')})
})
.catch(e => {
this.$message.error(e)
})
}, },
removeAssignee(user) {
this.$store.dispatch('tasks/removeAssignee', {user: user, taskId: this.taskId}) async removeAssignee(user) {
.then(() => { await this.$store.dispatch('tasks/removeAssignee', {user: user, taskId: this.taskId})
// Remove the assignee from the list
for (const a in this.assignees) { // Remove the assignee from the list
if (this.assignees[a].id === user.id) { for (const a in this.assignees) {
this.assignees.splice(a, 1) if (this.assignees[a].id === user.id) {
} this.assignees.splice(a, 1)
} }
this.$message.success({message: this.$t('task.assignee.unassignSuccess')}) }
}) this.$message.success({message: this.$t('task.assignee.unassignSuccess')})
.catch(e => {
this.$message.error(e)
})
}, },
findUser(query) {
async findUser(query) {
if (query === '') { if (query === '') {
this.clearAllFoundUsers() this.clearAllFoundUsers()
return return
} }
this.listUserService.getAll({listId: this.listId}, {s: query}) const response = await this.listUserService.getAll({listId: this.listId}, {s: query})
.then(response => {
// Filter the results to not include users who are already assigned
const filteredResponse = response.filter(({id}) => !includesById(this.assignees, id))
this.$set(this, 'foundUsers', filteredResponse) // Filter the results to not include users who are already assigned
}) this.foundUsers = response.filter(({id}) => !includesById(this.assignees, id))
.catch(e => {
this.$message.error(e)
})
}, },
clearAllFoundUsers() { clearAllFoundUsers() {
this.$set(this, 'foundUsers', []) this.foundUsers = []
}, },
focus() { focus() {
this.$refs.multiselect.focus() this.$refs.multiselect.focus()
}, },

View File

@ -47,7 +47,7 @@ import {LOADING, LOADING_MODULE} from '@/store/mutation-types'
export default { export default {
name: 'edit-labels', name: 'edit-labels',
props: { props: {
value: { modelValue: {
default: () => [], default: () => [],
type: Array, type: Array,
}, },
@ -60,6 +60,7 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
data() { data() {
return { return {
labelTaskService: new LabelTaskService(), labelTaskService: new LabelTaskService(),
@ -72,11 +73,12 @@ export default {
Multiselect, Multiselect,
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.labels = value this.labels = value
}, },
immediate: true, immediate: true,
deep: true,
}, },
}, },
computed: { computed: {
@ -91,9 +93,10 @@ export default {
findLabel(query) { findLabel(query) {
this.query = query this.query = query
}, },
addLabel(label, showNotification = true) {
async addLabel(label, showNotification = true) {
const bubble = () => { const bubble = () => {
this.$emit('input', this.labels) this.$emit('update:modelValue', this.labels)
this.$emit('change', this.labels) this.$emit('change', this.labels)
} }
@ -102,25 +105,21 @@ export default {
return return
} }
this.$store.dispatch('tasks/addLabel', {label: label, taskId: this.taskId}) await this.$store.dispatch('tasks/addLabel', {label: label, taskId: this.taskId})
.then(() => { bubble()
bubble() if (showNotification) {
if (showNotification) { this.$message.success({message: this.$t('task.label.addSuccess')})
this.$message.success({message: this.$t('task.label.addSuccess')}) }
}
})
.catch(e => {
this.$message.error(e)
})
}, },
removeLabel(label) {
async removeLabel(label) {
const removeFromState = () => { const removeFromState = () => {
for (const l in this.labels) { for (const l in this.labels) {
if (this.labels[l].id === label.id) { if (this.labels[l].id === label.id) {
this.labels.splice(l, 1) this.labels.splice(l, 1)
} }
} }
this.$emit('input', this.labels) this.$emit('update:modelValue', this.labels)
this.$emit('change', this.labels) this.$emit('change', this.labels)
} }
@ -129,30 +128,21 @@ export default {
return return
} }
this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId}) await this.$store.dispatch('tasks/removeLabel', {label: label, taskId: this.taskId})
.then(() => { removeFromState()
removeFromState() this.$message.success({message: this.$t('task.label.removeSuccess')})
this.$message.success({message: this.$t('task.label.removeSuccess')})
})
.catch(e => {
this.$message.error(e)
})
}, },
createAndAddLabel(title) {
async createAndAddLabel(title) {
if (this.taskId === 0) { if (this.taskId === 0) {
return return
} }
const newLabel = new LabelModel({title: title}) const newLabel = new LabelModel({title: title})
this.$store.dispatch('labels/createLabel', newLabel) const label = await this.$store.dispatch('labels/createLabel', newLabel)
.then(r => { this.addLabel(label, false)
this.addLabel(r, false) this.labels.push(label)
this.labels.push(r) this.$message.success({message: this.$t('task.label.addCreateSuccess')})
this.$message.success({message: this.$t('task.label.addCreateSuccess')})
})
.catch(e => {
this.$message.error(e)
})
}, },
}, },

View File

@ -8,7 +8,7 @@
@blur="save($event.target.textContent)" @blur="save($event.target.textContent)"
@keydown.enter.prevent.stop="$event.target.blur()" @keydown.enter.prevent.stop="$event.target.blur()"
:contenteditable="canWrite ? 'true' : 'false'" :contenteditable="canWrite ? 'true' : 'false'"
spellcheck="false" :spellcheck="false"
> >
{{ task.title.trim() }} {{ task.title.trim() }}
</h1> </h1>
@ -39,14 +39,14 @@ export default {
computed: { computed: {
...mapState(['loading']), ...mapState(['loading']),
task() { task() {
return this.value return this.modelValue
}, },
textIdentifier() { textIdentifier() {
return this.task?.getTextIdentifier() || '' return this.task?.getTextIdentifier() || ''
}, },
}, },
props: { props: {
value: { modelValue: {
required: true, required: true,
}, },
canWrite: { canWrite: {
@ -54,8 +54,11 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue'],
methods: { methods: {
save(title) { async save(title) {
// We only want to save if the title was actually changed. // We only want to save if the title was actually changed.
// Because the contenteditable does not have a change event // Because the contenteditable does not have a change event
// we're building it ourselves and only continue // we're building it ourselves and only continue
@ -71,20 +74,17 @@ export default {
title, title,
} }
this.$store.dispatch('tasks/update', newTask) try {
.then((task) => { const task = await this.$store.dispatch('tasks/update', newTask)
this.$emit('input', task) this.$emit('update:modelValue', task)
this.showSavedMessage = true this.showSavedMessage = true
setTimeout(() => { setTimeout(() => {
this.showSavedMessage = false this.showSavedMessage = false
}, 2000) }, 2000)
}) }
.catch(e => { finally {
this.$message.error(e) this.saving = false
}) }
.finally(() => {
this.saving = false
})
}, },
}, },
} }

View File

@ -6,9 +6,9 @@
'has-light-text': !colorIsDark(task.hexColor) && task.hexColor !== `#${task.defaultColor}` && task.hexColor !== task.defaultColor, 'has-light-text': !colorIsDark(task.hexColor) && task.hexColor !== `#${task.defaultColor}` && task.hexColor !== task.defaultColor,
}" }"
:style="{'background-color': task.hexColor !== '#' && task.hexColor !== `#${task.defaultColor}` ? task.hexColor : false}" :style="{'background-color': task.hexColor !== '#' && task.hexColor !== `#${task.defaultColor}` ? task.hexColor : false}"
@click.ctrl="() => markTaskAsDone(task)" @click.ctrl="() => toggleTaskDone(task)"
@click.exact="() => $router.push({ name: 'task.kanban.detail', params: { id: task.id } })" @click.exact="() => $router.push({ name: 'task.kanban.detail', params: { id: task.id } })"
@click.meta="() => markTaskAsDone(task)" @click.meta="() => toggleTaskDone(task)"
class="task loader-container draggable" class="task loader-container draggable"
> >
<span class="task-id"> <span class="task-id">
@ -93,23 +93,19 @@ export default {
}, },
}, },
methods: { methods: {
markTaskAsDone(task) { async toggleTaskDone(task) {
this.loadingInternal = true this.loadingInternal = true
this.$store.dispatch('tasks/update', { try {
...task, await this.$store.dispatch('tasks/update', {
done: !task.done, ...task,
}) done: !task.done,
.then(() => {
if (task.done) {
playPop()
}
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.loadingInternal = false
}) })
if (task.done) {
playPop()
}
} finally {
this.loadingInternal = false
}
}, },
}, },
} }

View File

@ -32,44 +32,43 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
required: false, required: false,
}, },
}, },
emits: ['update:modelValue', 'selected'],
components: { components: {
Multiselect, Multiselect,
}, },
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.list = value this.list = value
}, },
immeditate: true, immeditate: true,
deep: true,
}, },
}, },
methods: { methods: {
findLists(query) { async findLists(query) {
if (query === '') { if (query === '') {
this.clearAll() this.clearAll()
return return
} }
this.listSerivce.getAll({}, {s: query}) this.foundLists = await this.listSerivce.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundLists', response)
})
.catch(e => {
this.$message.error(e)
})
}, },
clearAll() { clearAll() {
this.$set(this, 'foundLists', []) this.foundLists = []
}, },
select(list) { select(list) {
this.list = list this.list = list
this.$emit('selected', list) this.$emit('selected', list)
this.$emit('input', list) this.$emit('update:modelValue', list)
}, },
namespace(namespaceId) { namespace(namespaceId) {
const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId) const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId)
if (namespace !== null) { if (namespace !== null) {

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="select"> <div class="select">
<select :disabled="disabled || null" @change="updateData" v-model.number="percentDone"> <select :disabled="disabled || null" v-model.number="percentDone">
<option value="0">0%</option> <option value="0">0%</option>
<option value="0.1">10%</option> <option value="0.1">10%</option>
<option value="0.2">20%</option> <option value="0.2">20%</option>
@ -19,13 +19,8 @@
<script> <script>
export default { export default {
name: 'percentDoneSelect', name: 'percentDoneSelect',
data() {
return {
percentDone: 0,
}
},
props: { props: {
value: { modelValue: {
default: 0, default: 0,
type: Number, type: Number,
}, },
@ -33,19 +28,16 @@ export default {
default: false, default: false,
}, },
}, },
watch: { emits: ['update:modelValue', 'change'],
// Set the priority to the :value every time it changes from the outside computed: {
value(newVal) { percentDone: {
this.percentDone = newVal get() {
}, return this.modelValue
}, },
mounted() { set(percentDone) {
this.percentDone = this.value this.$emit('update:modelValue', percentDone)
}, this.$emit('change')
methods: { },
updateData() {
this.$emit('input', this.percentDone)
this.$emit('change')
}, },
}, },
} }

View File

@ -23,7 +23,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: 0, default: 0,
type: Number, type: Number,
}, },
@ -31,9 +31,10 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
// Set the priority to the :value every time it changes from the outside // Set the priority to the :value every time it changes from the outside
value: { modelValue: {
handler(value) { handler(value) {
this.priority = value this.priority = value
}, },
@ -42,7 +43,7 @@ export default {
}, },
methods: { methods: {
updateData() { updateData() {
this.$emit('input', this.priority) this.$emit('update:modelValue', this.priority)
this.$emit('change') this.$emit('change')
}, },
}, },

View File

@ -185,76 +185,62 @@ export default {
}, },
}, },
methods: { methods: {
findTasks(query) { async findTasks(query) {
this.taskService.getAll({}, {s: query}) this.foundTasks = await this.taskService.getAll({}, {s: query})
.then(response => {
this.$set(this, 'foundTasks', response)
})
.catch(e => {
this.$message.error(e)
})
}, },
addTaskRelation() {
let rel = new TaskRelationModel({ async addTaskRelation() {
const rel = new TaskRelationModel({
taskId: this.taskId, taskId: this.taskId,
otherTaskId: this.newTaskRelationTask.id, otherTaskId: this.newTaskRelationTask.id,
relationKind: this.newTaskRelationKind, relationKind: this.newTaskRelationKind,
}) })
this.taskRelationService.create(rel) await this.taskRelationService.create(rel)
.then(() => { if (!this.relatedTasks[this.newTaskRelationKind]) {
if (!this.relatedTasks[this.newTaskRelationKind]) { this.relatedTasks[this.newTaskRelationKind] = []
this.$set(this.relatedTasks, this.newTaskRelationKind, []) }
} this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask)
this.relatedTasks[this.newTaskRelationKind].push(this.newTaskRelationTask) this.newTaskRelationTask = null
this.newTaskRelationTask = null this.saved = true
this.saved = true this.showNewRelationForm = false
this.showNewRelationForm = false setTimeout(() => {
setTimeout(() => { this.saved = false
this.saved = false }, 2000)
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
}, },
removeTaskRelation() {
async removeTaskRelation() {
const rel = new TaskRelationModel({ const rel = new TaskRelationModel({
relationKind: this.relationToDelete.relationKind, relationKind: this.relationToDelete.relationKind,
taskId: this.taskId, taskId: this.taskId,
otherTaskId: this.relationToDelete.otherTaskId, otherTaskId: this.relationToDelete.otherTaskId,
}) })
this.taskRelationService.delete(rel) try {
.then(() => { await this.taskRelationService.delete(rel)
Object.keys(this.relatedTasks).forEach(relationKind => {
for (const t in this.relatedTasks[relationKind]) { Object.entries(this.relatedTasks).some(([relationKind, t]) => {
if (this.relatedTasks[relationKind][t].id === this.relationToDelete.otherTaskId && relationKind === this.relationToDelete.relationKind) { const found = this.relatedTasks[relationKind][t].id === this.relationToDelete.otherTaskId &&
this.relatedTasks[relationKind].splice(t, 1) relationKind === this.relationToDelete.relationKind
} if (!found) return false
}
}) this.relatedTasks[relationKind].splice(t, 1)
this.saved = true return true
setTimeout(() => {
this.saved = false
}, 2000)
})
.catch(e => {
this.$message.error(e)
})
.finally(() => {
this.showDeleteModal = false
}) })
this.saved = true
setTimeout(() => {
this.saved = false
}, 2000)
} finally {
this.showDeleteModal = false
}
}, },
createAndRelateTask(title) {
async createAndRelateTask(title) {
const newTask = new TaskModel({title: title, listId: this.listId}) const newTask = new TaskModel({title: title, listId: this.listId})
this.taskService.create(newTask) this.newTaskRelationTask = await this.taskService.create(newTask)
.then(r => { await this.addTaskRelation()
this.newTaskRelationTask = r
this.addTaskRelation()
})
.catch(e => {
this.$message.error(e)
})
}, },
relationKindTitle(kind, length) { relationKindTitle(kind, length) {
return this.$tc(`task.relation.kinds.${kind}`, length) return this.$tc(`task.relation.kinds.${kind}`, length)
}, },

View File

@ -37,7 +37,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: () => [], default: () => [],
validator: prop => { validator: prop => {
// This allows arrays of Dates and strings // This allows arrays of Dates and strings
@ -61,14 +61,15 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
components: { components: {
datepicker, datepicker,
}, },
mounted() { mounted() {
this.reminders = this.value this.reminders = this.modelValue
}, },
watch: { watch: {
value(newVal) { modelValue(newVal) {
for (const i in newVal) { for (const i in newVal) {
if (typeof newVal[i] === 'string') { if (typeof newVal[i] === 'string') {
newVal[i] = new Date(newVal[i]) newVal[i] = new Date(newVal[i])
@ -79,7 +80,7 @@ export default {
}, },
methods: { methods: {
updateData() { updateData() {
this.$emit('input', this.reminders) this.$emit('update:modelValue', this.reminders)
this.$emit('change') this.$emit('change')
}, },
addReminderDate(index = null) { addReminderDate(index = null) {

View File

@ -66,7 +66,7 @@ export default {
} }
}, },
props: { props: {
value: { modelValue: {
default: () => {}, default: () => {},
required: true, required: true,
}, },
@ -74,8 +74,9 @@ export default {
default: false, default: false,
}, },
}, },
emits: ['update:modelValue', 'change'],
watch: { watch: {
value: { modelValue: {
handler(value) { handler(value) {
this.task = value this.task = value
if (typeof value.repeatAfter !== 'undefined') { if (typeof value.repeatAfter !== 'undefined') {
@ -92,7 +93,7 @@ export default {
} }
this.task.repeatAfter = this.repeatAfter this.task.repeatAfter = this.repeatAfter
this.$emit('input', this.task) this.$emit('update:modelValue', this.task)
this.$emit('change') this.$emit('change')
}, },
setRepeatAfter(amount, type) { setRepeatAfter(amount, type) {

View File

@ -140,6 +140,7 @@ export default {
default: true, default: true,
}, },
}, },
emits: ['task-updated'],
watch: { watch: {
theTask(newVal) { theTask(newVal) {
this.task = newVal this.task = newVal
@ -149,7 +150,7 @@ export default {
this.task = this.theTask this.task = this.theTask
document.addEventListener('click', this.hideDeferDueDatePopup) document.addEventListener('click', this.hideDeferDueDatePopup)
}, },
beforeDestroy() { beforeUnmount() {
document.removeEventListener('click', this.hideDeferDueDatePopup) document.removeEventListener('click', this.hideDeferDueDatePopup)
}, },
computed: { computed: {
@ -165,56 +166,47 @@ export default {
}, },
}, },
methods: { methods: {
markAsDone(checked) { async markAsDone(checked) {
const updateFunc = () => { const updateFunc = async () => {
this.taskService.update(this.task) const task = await this.taskService.update(this.task)
.then(t => { if (this.task.done) {
if (this.task.done) { playPop()
playPop() }
} this.task = task
this.task = t this.$emit('task-updated', task)
this.$emit('task-updated', t) this.$message.success({
this.$message.success({ message: this.task.done ?
message: this.task.done ? this.$t('task.doneSuccess') :
this.$t('task.doneSuccess') : this.$t('task.undoneSuccess'),
this.$t('task.undoneSuccess'), }, [{
}, [{ title: 'Undo',
title: 'Undo', callback() {
callback: () => { this.task.done = !this.task.done
this.task.done = !this.task.done this.markAsDone(!checked)
this.markAsDone(!checked) },
}, }])
}])
})
.catch(e => {
this.$message.error(e)
})
} }
if (checked) { if (checked) {
setTimeout(updateFunc, 300) // Delay it to show the animation when marking a task as done setTimeout(updateFunc, 300) // Delay it to show the animation when marking a task as done
} else { } else {
updateFunc() // Don't delay it when un-marking it as it doesn't have an animation the other way around await updateFunc() // Don't delay it when un-marking it as it doesn't have an animation the other way around
} }
}, },
toggleFavorite() {
async toggleFavorite() {
this.task.isFavorite = !this.task.isFavorite this.task.isFavorite = !this.task.isFavorite
this.taskService.update(this.task) this.task = await this.taskService.update(this.task)
.then(t => { this.$emit('task-updated', this.task)
this.task = t this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
this.$emit('task-updated', t)
this.$store.dispatch('namespaces/loadNamespacesIfFavoritesDontExist')
})
.catch(e => {
this.$message.error(e)
})
}, },
hideDeferDueDatePopup(e) { hideDeferDueDatePopup(e) {
if (this.showDefer) { if (!this.showDefer) {
closeWhenClickedOutside(e, this.$refs.deferDueDate.$el, () => { return
this.showDefer = false
})
} }
closeWhenClickedOutside(e, this.$refs.deferDueDate.$el, () => {
this.showDefer = false
})
}, },
}, },
} }

View File

@ -1,5 +1,5 @@
<template> <template>
<a @click="click"> <a @click="$emit('click')">
<icon icon="sort-up" v-if="order === 'asc'"/> <icon icon="sort-up" v-if="order === 'asc'"/>
<icon icon="sort-up" rotation="180" v-else-if="order === 'desc'"/> <icon icon="sort-up" rotation="180" v-else-if="order === 'desc'"/>
<icon icon="sort" v-else/> <icon icon="sort" v-else/>
@ -15,10 +15,6 @@ export default {
default: 'none', default: 'none',
}, },
}, },
methods: { emits: ['click'],
click() {
this.$emit('click')
},
},
} }
</script> </script>

View File

@ -87,43 +87,38 @@ export default {
Cropper, Cropper,
}, },
methods: { methods: {
avatarStatus() { async avatarStatus() {
this.avatarService.get({}) const { avatarProvider } = await this.avatarService.get({})
.then(r => { this.avatarProvider = avatarProvider
this.avatarProvider = r.avatarProvider
})
.catch(e => this.$message.error(e))
}, },
updateAvatarStatus() {
async updateAvatarStatus() {
const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider}) const avatarStatus = new AvatarModel({avatarProvider: this.avatarProvider})
this.avatarService.update(avatarStatus) await this.avatarService.update(avatarStatus)
.then(() => { this.$message.success({message: this.$t('user.settings.avatar.statusUpdateSuccess')})
this.$message.success({message: this.$t('user.settings.avatar.statusUpdateSuccess')}) this.$store.commit('auth/reloadAvatar')
this.$store.commit('auth/reloadAvatar')
})
.catch(e => this.$message.error(e))
}, },
uploadAvatar() {
async uploadAvatar() {
this.loading = true this.loading = true
const {canvas} = this.$refs.cropper.getResult() const {canvas} = this.$refs.cropper.getResult()
if (canvas) { if (!canvas) {
canvas.toBlob(blob => {
this.avatarService.create(blob)
.then(() => {
this.$message.success({message: this.$t('user.settings.avatar.setSuccess')})
this.$store.commit('auth/reloadAvatar')
})
.catch(e => this.$message.error(e))
.finally(() => {
this.loading = false
this.isCropAvatar = false
})
})
} else {
this.loading = false this.loading = false
return
}
try {
const blob = await new Promise(resolve => canvas.toBlob(blob => resolve(blob)))
await this.avatarService.create(blob)
this.$message.success({message: this.$t('user.settings.avatar.setSuccess')})
this.$store.commit('auth/reloadAvatar')
} finally {
this.loading = false
this.isCropAvatar = false
} }
}, },
cropAvatar() { cropAvatar() {
const avatar = this.$refs.avatarUploadInput.files const avatar = this.$refs.avatarUploadInput.files

View File

@ -43,28 +43,22 @@ export default {
name: 'data-export', name: 'data-export',
data() { data() {
return { return {
dataExportService: DataExportService, dataExportService: new DataExportService(),
password: '', password: '',
errPasswordRequired: false, errPasswordRequired: false,
} }
}, },
created() {
this.dataExportService = new DataExportService()
},
methods: { methods: {
requestDataExport() { async requestDataExport() {
if (this.password === '') { if (this.password === '') {
this.errPasswordRequired = true this.errPasswordRequired = true
this.$refs.passwordInput.focus() this.$refs.passwordInput.focus()
return return
} }
this.dataExportService.request(this.password) await this.dataExportService.request(this.password)
.then(() => { this.$message.success({message: this.$t('user.export.success')})
this.$message.success({message: this.$t('user.export.success')}) this.password = ''
this.password = ''
})
.catch(e => this.$message.error(e))
}, },
}, },
} }

View File

@ -101,34 +101,29 @@ export default {
deletionScheduledAt: state => parseDateOrNull(state.auth.info.deletionScheduledAt), deletionScheduledAt: state => parseDateOrNull(state.auth.info.deletionScheduledAt),
}), }),
methods: { methods: {
deleteAccount() { async deleteAccount() {
if (this.password === '') { if (this.password === '') {
this.errPasswordRequired = true this.errPasswordRequired = true
this.$refs.passwordInput.focus() this.$refs.passwordInput.focus()
return return
} }
this.accountDeleteService.request(this.password) await this.accountDeleteService.request(this.password)
.then(() => { this.$message.success({message: this.$t('user.deletion.requestSuccess')})
this.$message.success({message: this.$t('user.deletion.requestSuccess')}) this.password = ''
this.password = ''
})
.catch(e => this.$message.error(e))
}, },
cancelDeletion() {
async cancelDeletion() {
if (this.password === '') { if (this.password === '') {
this.errPasswordRequired = true this.errPasswordRequired = true
this.$refs.passwordInput.focus() this.$refs.passwordInput.focus()
return return
} }
this.accountDeleteService.cancel(this.password) await this.accountDeleteService.cancel(this.password)
.then(() => { this.$message.success({message: this.$t('user.deletion.scheduledCancelSuccess')})
this.$message.success({message: this.$t('user.deletion.scheduledCancelSuccess')}) this.$store.dispatch('auth/refreshUserInfo')
this.$store.dispatch('auth/refreshUserInfo') this.password = ''
this.password = ''
})
.catch(e => this.$message.error(e))
}, },
}, },
} }

View File

@ -1,6 +1,6 @@
export default { export default {
// When the bound element is inserted into the DOM... // When the bound element is inserted into the DOM...
inserted: (el, {modifiers}) => { mounted: (el, {modifiers}) => {
// Focus the element only if the viewport is big enough // Focus the element only if the viewport is big enough
// auto focusing elements on mobile can be annoying since in these cases the // 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. // keyboard always pops up and takes half of the available space on the screen.

View File

@ -22,7 +22,7 @@ const calculateArrowTop = (top, tooltip) => {
const createdTooltips = {} const createdTooltips = {}
export default { export default {
inserted: (el, {value, modifiers}) => { mounted(el, {value, modifiers}) {
// First, we create the tooltip and arrow elements // First, we create the tooltip and arrow elements
const tooltip = document.createElement('div') const tooltip = document.createElement('div')
tooltip.style.position = 'fixed' tooltip.style.position = 'fixed'
@ -74,7 +74,7 @@ export default {
arrow: arrow, arrow: arrow,
} }
}, },
unbind: el => { unmounted(el) {
if (typeof createdTooltips[el] !== 'undefined') { if (typeof createdTooltips[el] !== 'undefined') {
createdTooltips[el].tooltip.remove() createdTooltips[el].tooltip.remove()
createdTooltips[el].arrow.remove() createdTooltips[el].arrow.remove()

View File

@ -11,24 +11,22 @@ export function uploadFile(taskId: number, file: FileModel, onSuccess: () => Fun
return uploadFiles(attachmentService, taskId, files, onSuccess) return uploadFiles(attachmentService, taskId, files, onSuccess)
} }
export function uploadFiles(attachmentService: AttachmentService, taskId: number, files: FileModel[], onSuccess : Function = () => {}) { export async function uploadFiles(attachmentService: AttachmentService, taskId: number, files: FileModel[], onSuccess : Function = () => {}) {
const attachmentModel = new AttachmentModel({taskId}) const attachmentModel = new AttachmentModel({taskId})
attachmentService.create(attachmentModel, files) const response = await attachmentService.create(attachmentModel, files)
.then(r => { console.debug(`Uploaded attachments for task ${taskId}, response was`, response)
console.debug(`Uploaded attachments for task ${taskId}, response was`, r)
if (r.success !== null) { response.success?.map((attachment: AttachmentModel) => {
r.success.forEach((attachment: AttachmentModel) => { store.dispatch('tasks/addTaskAttachment', {
store.dispatch('tasks/addTaskAttachment', { taskId,
taskId, attachment,
attachment,
})
onSuccess(generateAttachmentUrl(taskId, attachment.id))
})
}
if (r.errors !== null) {
throw Error(r.errors)
}
}) })
onSuccess(generateAttachmentUrl(taskId, attachment.id))
})
if (response.errors !== null) {
throw Error(response.errors)
}
} }
export function generateAttachmentUrl(taskId: number, attachmentId: number) : any { export function generateAttachmentUrl(taskId: number, attachmentId: number) : any {

View File

@ -41,21 +41,19 @@ export const removeToken = () => {
* Refreshes an auth token while ensuring it is updated everywhere. * Refreshes an auth token while ensuring it is updated everywhere.
* @returns {Promise<AxiosResponse<any>>} * @returns {Promise<AxiosResponse<any>>}
*/ */
export const refreshToken = (persist: boolean): Promise<AxiosResponse> => { export async function refreshToken(persist: boolean): Promise<AxiosResponse> {
const HTTP = HTTPFactory() const HTTP = HTTPFactory()
return HTTP.post('user/token', null, { try {
headers: { const response = await HTTP.post('user/token', null, {
Authorization: `Bearer ${getToken()}`, headers: {
}, Authorization: `Bearer ${getToken()}`,
}) },
.then(r => {
saveToken(r.data.token, persist)
return Promise.resolve(r)
})
.catch(e => {
// eslint-disable-next-line
console.log('Error renewing token: ', e)
return Promise.reject(e)
}) })
saveToken(response.data.token, persist)
return response
} catch(e) {
throw new Error('Error renewing token: ', { cause: e })
}
} }

View File

@ -1,10 +0,0 @@
export const filterObject = (obj, fn) => {
let key
for (key in obj) {
if (fn(obj[key])) {
return key
}
}
return null
}

View File

@ -1,6 +1,8 @@
export const getListTitle = (l, $t) => { import {i18n} from '@/i18n'
export const getListTitle = (l) => {
if (l.id === -1) { if (l.id === -1) {
return $t('list.pseudo.favorites.title') return i18n.global.t('list.pseudo.favorites.title')
} }
return l.title return l.title
} }

View File

@ -1,12 +1,14 @@
export const getNamespaceTitle = (n, $t) => { import {i18n} from '@/i18n'
export const getNamespaceTitle = (n) => {
if (n.id === -1) { if (n.id === -1) {
return $t('namespace.pseudo.sharedLists.title') return i18n.global.t('namespace.pseudo.sharedLists.title')
} }
if (n.id === -2) { if (n.id === -2) {
return $t('namespace.pseudo.favorites.title') return i18n.global.t('namespace.pseudo.favorites.title')
} }
if (n.id === -3) { if (n.id === -3) {
return $t('namespace.pseudo.savedFilters.title') return i18n.global.t('namespace.pseudo.savedFilters.title')
} }
return n.title return n.title
} }

View File

@ -27,3 +27,14 @@ export function filterLabelsByQuery(state: labelState, labelsToHide: label[], qu
return !labelIds.includes(id) && title.toLowerCase().includes(labelQuery) return !labelIds.includes(id) && title.toLowerCase().includes(labelQuery)
}) })
} }
/**
* Returns the labels by id if found
* @param {Object} state
* @param {Array} ids
* @returns {Array}
*/
export function getLabelsByIds(state: labelState, ids: number[]) {
return Object.values(state.labels).filter(({id}) => ids.includes(id))
}

View File

@ -33,7 +33,7 @@ export const getMigratorFromSlug = (slug: string): Migrator => {
isFileMigrator: true, isFileMigrator: true,
} }
default: default:
throw Error('Unknown migrator slug ' + slug) throw new Error('Unknown migrator slug ' + slug)
} }
} }

5
src/helpers/randomId.ts Normal file
View File

@ -0,0 +1,5 @@
const DEFAULT_ID_LENGTH = 9
export function createRandomID(idLength = DEFAULT_ID_LENGTH) {
return Math.random().toString(36).substr(2, idLength)
}

View File

@ -1,3 +1,5 @@
import {createRandomID} from '@/helpers/randomId'
interface Provider { interface Provider {
name: string name: string
key: string key: string
@ -6,7 +8,7 @@ interface Provider {
} }
export const redirectToProvider = (provider: Provider, redirectUrl: string) => { export const redirectToProvider = (provider: Provider, redirectUrl: string) => {
const state = Math.random().toString(36).substring(2, 24) const state = createRandomID(24)
localStorage.setItem('state', state) localStorage.setItem('state', state)
window.location.href = `${provider.authUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUrl}${provider.key}&response_type=code&scope=openid email profile&state=${state}` window.location.href = `${provider.authUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUrl}${provider.key}&response_type=code&scope=openid email profile&state=${state}`

View File

@ -2,6 +2,8 @@ import {createDateFromString} from '@/helpers/time/createDateFromString'
import {format, formatDistanceToNow} from 'date-fns' import {format, formatDistanceToNow} from 'date-fns'
import {enGB, de, fr, ru} from 'date-fns/locale' import {enGB, de, fr, ru} from 'date-fns/locale'
import {i18n} from '@/i18n'
const locales = {en: enGB, de, ch: de, fr, ru} const locales = {en: enGB, de, ch: de, fr, ru}
const dateIsValid = date => { const dateIsValid = date => {
@ -12,7 +14,7 @@ const dateIsValid = date => {
return date instanceof Date && !isNaN(date) return date instanceof Date && !isNaN(date)
} }
export const formatDate = (date, f, locale) => { export const formatDate = (date, f, locale = i18n.global.t('date.locale')) => {
if (!dateIsValid(date)) { if (!dateIsValid(date)) {
return '' return ''
} }
@ -22,7 +24,15 @@ export const formatDate = (date, f, locale) => {
return date ? format(date, f, {locale: locales[locale]}) : '' return date ? format(date, f, {locale: locales[locale]}) : ''
} }
export const formatDateSince = (date, $t) => { export function formatDateLong(date) {
return formatDate(date, 'PPPPpppp')
}
export function formatDateShort(date) {
return formatDate(date, 'PPpp')
}
export const formatDateSince = (date) => {
if (!dateIsValid(date)) { if (!dateIsValid(date)) {
return '' return ''
} }
@ -30,7 +40,7 @@ export const formatDateSince = (date, $t) => {
date = createDateFromString(date) date = createDateFromString(date)
return formatDistanceToNow(date, { return formatDistanceToNow(date, {
locale: locales[$t('date.locale')], locale: locales[i18n.global.t('date.locale')],
addSuffix: true, addSuffix: true,
}) })
} }

View File

@ -2,6 +2,10 @@ export function findIndexById(array : [], id : string | number) {
return array.findIndex(({id: currentId}) => currentId === id) return array.findIndex(({id: currentId}) => currentId === id)
} }
export function findById(array : [], id : string | number) {
return array.find(({id: currentId}) => currentId === id)
}
export function includesById(array: [], id: string | number) { export function includesById(array: [], id: string | number) {
return array.some(({id: currentId}) => currentId === id) return array.some(({id: currentId}) => currentId === id)
} }

View File

@ -1,12 +1,10 @@
import Vue from 'vue' import { createI18n } from 'vue-i18n'
import VueI18n from 'vue-i18n'
import langEN from './lang/en.json' import langEN from './lang/en.json'
Vue.use(VueI18n) export const i18n = createI18n({
export const i18n = new VueI18n({
locale: 'en', // set locale locale: 'en', // set locale
fallbackLocale: 'en', fallbackLocale: 'en',
globalInjection: true,
messages: { messages: {
en: langEN, en: langEN,
}, },
@ -23,26 +21,25 @@ export const availableLanguages = {
const loadedLanguages = ['en'] // our default language that is preloaded const loadedLanguages = ['en'] // our default language that is preloaded
const setI18nLanguage = lang => { const setI18nLanguage = lang => {
i18n.locale = lang i18n.global.locale = lang
document.querySelector('html').setAttribute('lang', lang) document.querySelector('html').setAttribute('lang', lang)
return lang return lang
} }
export const loadLanguageAsync = lang => { export const loadLanguageAsync = lang => {
// If the same language if (
if (i18n.locale === lang) { // If the same language
return Promise.resolve(setI18nLanguage(lang)) i18n.global.locale === lang ||
} // If the language was already loaded
loadedLanguages.includes(lang)
// If the language was already loaded ) {
if (loadedLanguages.includes(lang)) { return setI18nLanguage(lang)
return Promise.resolve(setI18nLanguage(lang))
} }
// If the language hasn't been loaded yet // If the language hasn't been loaded yet
return import(`./lang/${lang}.json`).then( return import(`./lang/${lang}.json`).then(
messages => { messages => {
i18n.setLocaleMessage(lang, messages.default) i18n.global.setLocaleMessage(lang, messages.default)
loadedLanguages.push(lang) loadedLanguages.push(lang)
return setI18nLanguage(lang) return setI18nLanguage(lang)
}, },

View File

@ -22,7 +22,7 @@
"usernameEmail": "Anmeldename oder E-Mail-Adresse", "usernameEmail": "Anmeldename oder E-Mail-Adresse",
"usernamePlaceholder": "z.B. frederick", "usernamePlaceholder": "z.B. frederick",
"email": "E-Mail-Adresse", "email": "E-Mail-Adresse",
"emailPlaceholder": "z.B. frederic@vikunja.io", "emailPlaceholder": "z.B. frederic{'@'}vikunja.io",
"password": "Passwort", "password": "Passwort",
"passwordRepeat": "Gib dein Passwort erneut ein", "passwordRepeat": "Gib dein Passwort erneut ein",
"passwordPlaceholder": "z.B. •••••••••••", "passwordPlaceholder": "z.B. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Benutzernamä oder E-Mail Adrässe", "usernameEmail": "Benutzernamä oder E-Mail Adrässe",
"usernamePlaceholder": "z.B. Hansruedi", "usernamePlaceholder": "z.B. Hansruedi",
"email": "E-Mail Adrässe", "email": "E-Mail Adrässe",
"emailPlaceholder": "z.B. hansruedi@vikunja.io", "emailPlaceholder": "z.B. hansruedi{'@'}vikunja.io",
"password": "Passwort", "password": "Passwort",
"passwordRepeat": "Gib dis Passwort nomal iih", "passwordRepeat": "Gib dis Passwort nomal iih",
"passwordPlaceholder": "z.B. •••••••••••", "passwordPlaceholder": "z.B. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Username Or Email Address", "usernameEmail": "Username Or Email Address",
"usernamePlaceholder": "e.g. frederick", "usernamePlaceholder": "e.g. frederick",
"email": "E-mail address", "email": "E-mail address",
"emailPlaceholder": "e.g. frederic@vikunja.io", "emailPlaceholder": "e.g. frederic{'@'}vikunja.io",
"password": "Password", "password": "Password",
"passwordRepeat": "Retype your password", "passwordRepeat": "Retype your password",
"passwordPlaceholder": "e.g. •••••••••••", "passwordPlaceholder": "e.g. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Username Or Email Address", "usernameEmail": "Username Or Email Address",
"usernamePlaceholder": "e.g. frederick", "usernamePlaceholder": "e.g. frederick",
"email": "E-mail address", "email": "E-mail address",
"emailPlaceholder": "e.g. frederic@vikunja.io", "emailPlaceholder": "e.g. frederic{'@'}vikunja.io",
"password": "Password", "password": "Password",
"passwordRepeat": "Retype your password", "passwordRepeat": "Retype your password",
"passwordPlaceholder": "e.g. •••••••••••", "passwordPlaceholder": "e.g. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Nom dutilisateur·rice ou adresse courriel", "usernameEmail": "Nom dutilisateur·rice ou adresse courriel",
"usernamePlaceholder": "p. ex. frederick", "usernamePlaceholder": "p. ex. frederick",
"email": "Adresse courriel", "email": "Adresse courriel",
"emailPlaceholder": "p. ex. frederic@vikunja.io", "emailPlaceholder": "p. ex. frederic{'@'}vikunja.io",
"password": "Mot de passe", "password": "Mot de passe",
"passwordRepeat": "Retape ton mot de passe", "passwordRepeat": "Retape ton mot de passe",
"passwordPlaceholder": "p. ex. •••••••••••", "passwordPlaceholder": "p. ex. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Username Or Email Address", "usernameEmail": "Username Or Email Address",
"usernamePlaceholder": "e.g. frederick", "usernamePlaceholder": "e.g. frederick",
"email": "E-mail address", "email": "E-mail address",
"emailPlaceholder": "e.g. frederic@vikunja.io", "emailPlaceholder": "e.g. frederic{'@'}vikunja.io",
"password": "Password", "password": "Password",
"passwordRepeat": "Retype your password", "passwordRepeat": "Retype your password",
"passwordPlaceholder": "e.g. •••••••••••", "passwordPlaceholder": "e.g. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Username Or Email Address", "usernameEmail": "Username Or Email Address",
"usernamePlaceholder": "e.g. frederick", "usernamePlaceholder": "e.g. frederick",
"email": "E-mail address", "email": "E-mail address",
"emailPlaceholder": "e.g. frederic@vikunja.io", "emailPlaceholder": "e.g. frederic{'@'}vikunja.io",
"password": "Password", "password": "Password",
"passwordRepeat": "Retype your password", "passwordRepeat": "Retype your password",
"passwordPlaceholder": "e.g. •••••••••••", "passwordPlaceholder": "e.g. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Username Or Email Address", "usernameEmail": "Username Or Email Address",
"usernamePlaceholder": "e.g. frederick", "usernamePlaceholder": "e.g. frederick",
"email": "E-mail address", "email": "E-mail address",
"emailPlaceholder": "e.g. frederic@vikunja.io", "emailPlaceholder": "e.g. frederic{'@'}vikunja.io",
"password": "Password", "password": "Password",
"passwordRepeat": "Retype your password", "passwordRepeat": "Retype your password",
"passwordPlaceholder": "e.g. •••••••••••", "passwordPlaceholder": "e.g. •••••••••••",

View File

@ -22,7 +22,7 @@
"usernameEmail": "Имя пользователя или Email", "usernameEmail": "Имя пользователя или Email",
"usernamePlaceholder": "напр. frederick", "usernamePlaceholder": "напр. frederick",
"email": "E-mail адрес", "email": "E-mail адрес",
"emailPlaceholder": "напр. frederic@vikunja.io", "emailPlaceholder": "напр. frederic{'@'}vikunja.io",
"password": "Пароль", "password": "Пароль",
"passwordRepeat": "Пароль ещё раз", "passwordRepeat": "Пароль ещё раз",
"passwordPlaceholder": "напр. •••••••••••", "passwordPlaceholder": "напр. •••••••••••",

View File

@ -1,4 +1,13 @@
import Vue from 'vue' import { createApp, configureCompat } from 'vue'
configureCompat({
COMPONENT_V_MODEL: false,
COMPONENT_ASYNC: false,
RENDER_FUNCTION: false,
WATCH_ARRAY: false, // TODO: check this again; this might lead to some problemes
TRANSITION_GROUP_ROOT: false,
})
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
@ -10,33 +19,24 @@ declare global {
} }
} }
import {formatDate, formatDateSince} from '@/helpers/time/formatDate' import {formatDate, formatDateShort, formatDateLong, formatDateSince} from '@/helpers/time/formatDate'
// @ts-ignore // @ts-ignore
import {VERSION} from './version.json' import {VERSION} from './version.json'
// Register the modal
// @ts-ignore
import Modal from './components/modal/modal'
// Add CSS // Add CSS
import './styles/vikunja.scss' import './styles/vikunja.scss'
// Notifications // Notifications
import Notifications from 'vue-notification' import Notifications from '@kyvg/vue3-notification'
// PWA // PWA
import './registerServiceWorker' import './registerServiceWorker'
// Shortcuts // Shortcuts
// @ts-ignore - no types available import shortkey from '@/plugins/shortkey'
import vueShortkey from 'vue-shortkey'
// Mixins
import {colorIsDark} from './helpers/color/colorIsDark'
import {setTitle} from './helpers/setTitle'
import {getNamespaceTitle} from './helpers/getNamespaceTitle'
import {getListTitle} from './helpers/getListTitle'
// Vuex // Vuex
import {store} from './store' import {store} from './store'
// i18n // i18n
import VueI18n from 'vue-i18n' // types import {i18n} from './i18n'
import {i18n} from './i18n/setup'
console.info(`Vikunja frontend version ${VERSION}`) console.info(`Vikunja frontend version ${VERSION}`)
@ -51,84 +51,83 @@ 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) window.API_URL = window.API_URL.substr(0, window.API_URL.length - 1)
} }
Vue.component('modal', Modal) const app = createApp(App)
Vue.config.productionTip = false app.use(Notifications)
Vue.use(Notifications)
import FontAwesomeIcon from './icons'
Vue.component('icon', FontAwesomeIcon)
Vue.use(vueShortkey, {prevent: ['input', 'textarea', '.input', '[contenteditable]']}) app.use(shortkey, {prevent: ['input', 'textarea', '.input', '[contenteditable]']})
// define as global property
const Message = {
install(Vue) {
if (this.installed) {
return
}
this.installed = true
const message = {
error(e, actions = []) {
return error(e, Vue.prototype, actions)
},
success(s, actions = []) {
return success(s, Vue.prototype, actions)
},
}
Vue.prototype['$message'] = message
},
}
Vue.use(Message)
// directives
import focus from './directives/focus' import focus from './directives/focus'
Vue.directive('focus', focus)
import tooltip from './directives/tooltip' import tooltip from './directives/tooltip'
app.directive('focus', focus)
app.directive('tooltip', tooltip)
// @ts-ignore // global components
Vue.directive('tooltip', tooltip) import FontAwesomeIcon from './icons'
import Button from './components/input/button.vue'
import Modal from './components/modal/modal.vue'
import Card from './components/misc/card.vue'
app.component('icon', FontAwesomeIcon)
app.component('x-button', Button)
app.component('modal', Modal)
app.component('card', Card)
// @ts-ignore // Mixins
import Button from './components/input/button' import {getNamespaceTitle} from './helpers/getNamespaceTitle'
Vue.component('x-button', Button) import {getListTitle} from './helpers/getListTitle'
import {colorIsDark} from './helpers/color/colorIsDark'
// @ts-ignore import {setTitle} from './helpers/setTitle'
import Card from './components/misc/card' app.mixin({
Vue.component('card', Card)
Vue.mixin({
methods: { methods: {
formatDateSince(date) { formatDateSince,
return formatDateSince(date, (p: VueI18n.Path, params?: VueI18n.Values) => this.$t(p, params)) format: formatDate,
}, formatDate: formatDateLong,
formatDate(date) { formatDateShort: formatDateShort,
return formatDate(date, 'PPPPpppp', this.$t('date.locale')) getNamespaceTitle,
}, getListTitle,
formatDateShort(date) { colorIsDark,
return formatDate(date, 'PPpp', this.$t('date.locale')) setTitle,
},
format(date, f) {
return formatDate(date, f, 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))
},
colorIsDark: colorIsDark,
setTitle: setTitle,
}, },
}) })
new Vue({ app.config.errorHandler = (err, vm, info) => {
router, // if (import.meta.env.PROD) {
store, // error(err)
i18n, // } else {
render: h => h(App), // console.error(err, vm, info)
}).$mount('#app') error(err)
// }
}
if (import.meta.env.DEV) {
app.config.warnHandler = (msg, vm, info) => {
error(msg)
}
}
// https://stackoverflow.com/a/52076738/15522256
window.addEventListener('error', (err) => {
error(err)
})
window.addEventListener('unhandledrejection', (err) => {
// event.promise contains the promise object
// event.reason contains the reason for the rejection
error(err)
})
app.config.globalProperties.$message = {
error,
success,
}
app.use(router)
app.use(store)
app.use(i18n)
app.mount('#app')

View File

@ -1,11 +1,12 @@
import {i18n} from '@/i18n/setup' import {i18n} from '@/i18n'
import { notify } from '@kyvg/vue3-notification'
export const getErrorText = (r) => { export const getErrorText = (r) => {
if (r.response && r.response.data) { if (r.response && r.response.data) {
if(r.response.data.code) { if(r.response.data.code) {
const path = `error.${r.response.data.code}` const path = `error.${r.response.data.code}`
const message = i18n.t(path) const message = i18n.global.t(path)
// If message and path are equal no translation exists for that error code // If message and path are equal no translation exists for that error code
if (path !== message) { if (path !== message) {
@ -27,20 +28,20 @@ export const getErrorText = (r) => {
return [r.message] return [r.message]
} }
export function error(e, context, actions = []) { export function error(e, actions = []) {
context.$notify({ notify({
type: 'error', type: 'error',
title: i18n.t('error.error'), title: i18n.global.t('error.error'),
text: getErrorText(e), text: getErrorText(e),
actions: actions, actions: actions,
}) })
console.error(e, actions) console.error(e, actions)
} }
export function success(e, context, actions = []) { export function success(e, actions = []) {
context.$notify({ notify({
type: 'success', type: 'success',
title: i18n.t('error.success'), title: i18n.global.t('error.success'),
text: getErrorText(e), text: getErrorText(e),
data: { data: {
actions: actions, actions: actions,

View File

@ -24,16 +24,12 @@ export default class TaskModel extends AbstractModel {
this.endDate = parseDateOrNull(this.endDate) this.endDate = parseDateOrNull(this.endDate)
this.doneAt = parseDateOrNull(this.doneAt) this.doneAt = parseDateOrNull(this.doneAt)
this.reminderDates = this.reminderDates.map(d => new Date(d))
// Cancel all scheduled notifications for this task to be sure to only have available notifications // Cancel all scheduled notifications for this task to be sure to only have available notifications
this.cancelScheduledNotifications() this.cancelScheduledNotifications().then(() => {
.then(() => { // Every time we see a reminder, we schedule a notification for it
this.reminderDates = this.reminderDates.map(d => { this.reminderDates.forEach(d => this.scheduleNotification(d))
d = new Date(d) })
// Every time we see a reminder, we schedule a notification for it
this.scheduleNotification(d)
return d
})
})
// Parse the repeat after into something usable // Parse the repeat after into something usable
this.parseRepeatAfter() this.parseRepeatAfter()
@ -218,27 +214,26 @@ export default class TaskModel extends AbstractModel {
} }
// Register the actual notification // Register the actual notification
registration.showNotification('Vikunja Reminder', { try {
tag: `vikunja-task-${this.id}`, // Group notifications by task id so we're only showing one notification per task registration.showNotification('Vikunja Reminder', {
body: this.title, tag: `vikunja-task-${this.id}`, // Group notifications by task id so we're only showing one notification per task
// eslint-disable-next-line no-undef body: this.title,
showTrigger: new TimestampTrigger(date), // eslint-disable-next-line no-undef
badge: '/images/icons/badge-monochrome.png', showTrigger: new TimestampTrigger(date),
icon: '/images/icons/android-chrome-512x512.png', badge: '/images/icons/badge-monochrome.png',
data: {taskId: this.id}, icon: '/images/icons/android-chrome-512x512.png',
actions: [ data: {taskId: this.id},
{ actions: [
action: 'show-task', {
title: 'Show task', action: 'show-task',
}, title: 'Show task',
], },
}) ],
.then(() => {
console.debug('Notification scheduled for ' + date)
})
.catch(e => {
console.debug('Error scheduling notification', e)
}) })
console.debug('Notification scheduled for ' + date)
} catch(e) {
throw new Error('Error scheduling notification', e)
}
} }
} }

View File

@ -0,0 +1,78 @@
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1)
}
const MODIFIER_KEYS = ['shift', 'ctrl', 'meta', 'alt']
const SHORT_CUT_INDEX = [
{ key: 'ArrowUp', value: 'arrowup' },
{ key: 'ArrowLeft', value: 'arrowlef' },
{ key: 'ArrowRight', value: 'arrowright' },
{ key: 'ArrowDown', value: 'arrowdown' },
{ key: 'AltGraph', value: 'altgraph' },
{ key: 'Escape', value: 'esc' },
{ key: 'Enter', value: 'enter' },
{ key: 'Tab', value: 'tab' },
{ key: ' ', value: 'space' },
{ key: 'PageUp', value: 'pagup' },
{ key: 'PageDown', value: 'pagedow' },
{ key: 'Home', value: 'home' },
{ key: 'End', value: 'end' },
{ key: 'Delete', value: 'del' },
{ key: 'Backspace', value: 'bacspace' },
{ key: 'Insert', value: 'insert' },
{ key: 'NumLock', value: 'numlock' },
{ key: 'CapsLock', value: 'capslock' },
{ key: 'Pause', value: 'pause' },
{ key: 'ContextMenu', value: 'cotextmenu' },
{ key: 'ScrollLock', value: 'scrolllock' },
{ key: 'BrowserHome', value: 'browserhome' },
{ key: 'MediaSelect', value: 'mediaselect' },
]
export function encodeKey(pKey) {
const shortKey = {}
MODIFIER_KEYS.forEach((key) => {
shortKey[`${key}Key`] = pKey.includes(key)
})
let indexedKeys = createShortcutIndex(shortKey)
const vKey = pKey.filter(
(item) => !MODIFIER_KEYS.includes(item),
)
indexedKeys += vKey.join('')
return indexedKeys
}
function createShortcutIndex(pKey) {
let k = ''
MODIFIER_KEYS.forEach((key) => {
if (pKey.key === capitalizeFirstLetter(key) || pKey[`${key}Key`]) {
k += key
}
})
SHORT_CUT_INDEX.forEach(({ key, value }) => {
if (pKey.key === key) {
k += value
}
})
if (
(pKey.key && pKey.key !== ' ' && pKey.key.length === 1) ||
/F\d{1,2}|\//g.test(pKey.key)
) {
k += pKey.key.toLowerCase()
}
return k
}
export { createShortcutIndex as decodeKey }
export function parseValue(value) {
value = typeof value === 'string' ? JSON.parse(value.replace(/'/gi, '"')) : value
return value instanceof Array ? { '': value } : value
}

View File

@ -0,0 +1,186 @@
import { parseValue, decodeKey, encodeKey } from './helpers'
let mapFunctions = {}
let objAvoided = []
let elementAvoided = []
let keyPressed = false
function dispatchShortkeyEvent(pKey) {
const e = new CustomEvent('shortkey', { bubbles: false })
if (mapFunctions[pKey].key) {
e.srcKey = mapFunctions[pKey].key
}
const elm = mapFunctions[pKey].el
if (!mapFunctions[pKey].propagte) {
elm[elm.length - 1].dispatchEvent(e)
} else {
elm.forEach((elmItem) => elmItem.dispatchEvent(e))
}
}
function keyDown(pKey) {
if (
(!mapFunctions[pKey].once && !mapFunctions[pKey].push) ||
(mapFunctions[pKey].push && !keyPressed)
) {
dispatchShortkeyEvent(pKey)
}
}
function fillMappingFunctions(
mappingFunctions,
{ b, push, once, focus, propagte, el },
) {
for (let key in b) {
const k = encodeKey(b[key])
const propagated = mappingFunctions[k] && mappingFunctions[k].propagte
const elm =
mappingFunctions[k] && mappingFunctions[k].el
? mappingFunctions[k].el
: []
elm.push(el)
mappingFunctions[k] = {
push,
once,
focus,
key,
propagte: propagated || propagte,
el: elm,
}
}
}
function bindValue(value, el, binding, vnode) {
const { modifiers } = binding
const push = !!modifiers.push
const avoid = !!modifiers.avoid
const focus = !modifiers.focus
const once = !!modifiers.once
const propagte = !!modifiers.propagte
if (avoid) {
objAvoided = objAvoided.filter((itm) => !itm === el)
objAvoided.push(el)
} else {
fillMappingFunctions(mapFunctions, {
b: value,
push,
once,
focus,
propagte,
el: vnode.el,
})
}
}
function unbindValue(value, el) {
for (let key in value) {
const k = encodeKey(value[key])
const idxElm = mapFunctions[k].el.indexOf(el)
if (mapFunctions[k].el.length > 1 && idxElm > -1) {
mapFunctions[k].el.splice(idxElm, 1)
} else {
delete mapFunctions[k]
}
}
}
function availableElement(decodedKey) {
const objectIsAvoided = !!objAvoided.find(
(r) => r === document.activeElement,
)
const filterAvoided = !!elementAvoided.find(
(selector) =>
document.activeElement && document.activeElement.matches(selector),
)
return !!mapFunctions[decodedKey] && !(objectIsAvoided || filterAvoided)
}
function keyDownListener(pKey) {
const decodedKey = decodeKey(pKey)
// Check avoidable elements
if (!availableElement(decodedKey)) {
return
}
if (!mapFunctions[decodedKey].propagte) {
pKey.preventDefault()
pKey.stopPropagation()
}
if (mapFunctions[decodedKey].focus) {
keyDown(decodedKey)
keyPressed = true
} else if (!keyPressed) {
const elm = mapFunctions[decodedKey].el
elm[elm.length - 1].focus()
keyPressed = true
}
}
function keyUpListener(pKey) {
const decodedKey = decodeKey(pKey)
if (!availableElement(decodedKey)) {
keyPressed = false
return
}
if (!mapFunctions[decodedKey].propagte) {
pKey.preventDefault()
pKey.stopPropagation()
}
if (mapFunctions[decodedKey].once || mapFunctions[decodedKey].push) {
dispatchShortkeyEvent(decodedKey)
}
keyPressed = false
}
// register key presses that happen before mounting of directive
// if (process?.env?.NODE_ENV !== 'test') {
// (() => {
document.addEventListener('keydown', keyDownListener, true)
document.addEventListener('keyup', keyUpListener, true)
// })()
// }
function install(app, options) {
elementAvoided = [...(options && options.prevent ? options.prevent : [])]
app.directive('shortkey', {
beforeMount(el, binding, vnode) {
// Mapping the commands
const value = parseValue(binding.value)
bindValue(value, el, binding, vnode)
},
updated(el, binding, vnode) {
const oldValue = parseValue(binding.oldValue)
unbindValue(oldValue, el)
const newValue = parseValue(binding.value)
bindValue(newValue, el, binding, vnode)
},
unmounted(el, binding) {
const value = parseValue(binding.value)
unbindValue(value, el)
},
})
}
export default {
install,
encodeKey,
decodeKey,
keyDown,
}

View File

@ -1,10 +1,7 @@
import Vue from 'vue' import { createRouter, createWebHistory } from 'vue-router'
import Router from 'vue-router'
import HomeComponent from '../views/Home' import HomeComponent from '../views/Home'
import NotFoundComponent from '../views/404' import NotFoundComponent from '../views/404'
import LoadingComponent from '../components/misc/loading'
import ErrorComponent from '../components/misc/error'
import About from '../views/About' import About from '../views/About'
// User Handling // User Handling
import LoginComponent from '../views/user/Login' import LoginComponent from '../views/user/Login'
@ -48,56 +45,21 @@ import NamespaceSettingDelete from '../views/namespaces/settings/delete'
// Saved Filters // Saved Filters
import CreateSavedFilter from '../views/filters/CreateSavedFilter' import CreateSavedFilter from '../views/filters/CreateSavedFilter'
const PasswordResetComponent = () => ({ const PasswordResetComponent = () => import('../views/user/PasswordReset')
component: import('../views/user/PasswordReset'), const GetPasswordResetComponent = () => import('../views/user/RequestPasswordReset')
loading: LoadingComponent, const UserSettingsComponent = () => import('../views/user/Settings')
error: ErrorComponent,
timeout: 60000,
})
const GetPasswordResetComponent = () => ({
component: import('../views/user/RequestPasswordReset'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
const UserSettingsComponent = () => ({
component: import('../views/user/Settings'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
// List Handling // List Handling
const NewListComponent = () => ({ const NewListComponent = () => import('../views/list/NewList')
component: import('../views/list/NewList'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
// Namespace Handling // Namespace Handling
const NewNamespaceComponent = () => ({ const NewNamespaceComponent = () => import('../views/namespaces/NewNamespace')
component: import('../views/namespaces/NewNamespace'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
const EditTeamComponent = () => ({ const EditTeamComponent = () => import('../views/teams/EditTeam')
component: import('../views/teams/EditTeam'), const NewTeamComponent = () => import('../views/teams/NewTeam')
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
const NewTeamComponent = () => ({
component: import('../views/teams/NewTeam'),
loading: LoadingComponent,
error: ErrorComponent,
timeout: 60000,
})
Vue.use(Router) const router = createRouter({
history: createWebHistory(),
export default new Router({
mode: 'history',
scrollBehavior(to, from, savedPosition) { scrollBehavior(to, from, savedPosition) {
// If the user is using their forward/backward keys to navigate, we want to restore the scroll view // If the user is using their forward/backward keys to navigate, we want to restore the scroll view
if (savedPosition) { if (savedPosition) {
@ -106,13 +68,11 @@ export default new Router({
// Scroll to anchor should still work // Scroll to anchor should still work
if (to.hash) { if (to.hash) {
return { return {el: document.getElementById(to.hash.slice(1))}
selector: to.hash,
}
} }
// Otherwise just scroll to the top // Otherwise just scroll to the top
return {x: 0, y: 0} return {left: 0, top: 0}
}, },
routes: [ routes: [
{ {
@ -121,8 +81,14 @@ export default new Router({
component: HomeComponent, component: HomeComponent,
}, },
{ {
path: '*', path: '/:pathMatch(.*)*',
name: '404', name: 'not-found',
component: NotFoundComponent,
},
// if you omit the last `*`, the `/` character in params will be encoded when resolving or pushing
{
path: '/:pathMatch(.*)',
name: 'bad-not-found',
component: NotFoundComponent, component: NotFoundComponent,
}, },
{ {
@ -540,4 +506,18 @@ export default new Router({
component: About, component: About,
}, },
], ],
}) })
// bad example if using named routes:
router.resolve({
name: 'bad-not-found',
params: { pathMatch: 'not/found' },
}).href // '/not%2Ffound'
// good example:
router.resolve({
name: 'not-found',
params: { pathMatch: ['not', 'found'] },
}).href // '/not/found'
export default router

View File

@ -105,19 +105,6 @@ export default class AbstractService {
return true return true
} }
/////////////////////
// Global error handler
///////////////////
/**
* Handles the error and rejects the promise.
* @param error
* @returns {Promise<never>}
*/
errorHandler(error) {
return Promise.reject(error)
}
///////////////// /////////////////
// Helper functions // Helper functions
/////////////// ///////////////
@ -156,7 +143,7 @@ export default class AbstractService {
getReplacedRoute(path, pathparams) { getReplacedRoute(path, pathparams) {
let replacements = this.getRouteReplacements(path, pathparams) let replacements = this.getRouteReplacements(path, pathparams)
return Object.entries(replacements).reduce( return Object.entries(replacements).reduce(
(result, [parameter, value]) => result.replace(parameter, value), (result, [parameter, value]) => result.replace(parameter, value),
path, path,
) )
} }
@ -284,7 +271,7 @@ export default class AbstractService {
*/ */
get(model, params = {}) { get(model, params = {}) {
if (this.paths.get === '') { if (this.paths.get === '') {
return Promise.reject({message: 'This model is not able to get data.'}) throw new Error('This model is not able to get data.')
} }
return this.getM(this.paths.get, model, params) return this.getM(this.paths.get, model, params)
@ -298,35 +285,30 @@ export default class AbstractService {
* @param params * @param params
* @returns {Q.Promise<unknown>} * @returns {Q.Promise<unknown>}
*/ */
getM(url, model = {}, params = {}) { async getM(url, model = {}, params = {}) {
const cancel = this.setLoading() const cancel = this.setLoading()
model = this.beforeGet(model) model = this.beforeGet(model)
const finalUrl = this.getReplacedRoute(url, model) const finalUrl = this.getReplacedRoute(url, model)
return this.http.get(finalUrl, {params: params}) try {
.catch(error => { const response = await this.http.get(finalUrl, {params})
return this.errorHandler(error) const result = this.modelGetFactory(response.data)
}) result.maxRight = Number(response.headers['x-max-right'])
.then(response => { return result
const result = this.modelGetFactory(response.data) } finally {
result.maxRight = Number(response.headers['x-max-right']) cancel()
return Promise.resolve(result) }
})
.finally(() => {
cancel()
})
} }
getBlobUrl(url, method = 'GET', data = {}) { async getBlobUrl(url, method = 'GET', data = {}) {
return this.http({ const response = await this.http({
url: url, url: url,
method: method, method: method,
responseType: 'blob', responseType: 'blob',
data: data, data: data,
}).then(response => {
return window.URL.createObjectURL(new Blob([response.data]))
}) })
return window.URL.createObjectURL(new Blob([response.data]))
} }
/** /**
@ -337,9 +319,9 @@ export default class AbstractService {
* @param page The page to get * @param page The page to get
* @returns {Q.Promise<any>} * @returns {Q.Promise<any>}
*/ */
getAll(model = {}, params = {}, page = 1) { async getAll(model = {}, params = {}, page = 1) {
if (this.paths.getAll === '') { if (this.paths.getAll === '') {
return Promise.reject({message: 'This model is not able to get data.'}) throw new Error('This model is not able to get data.')
} }
params.page = page params.page = page
@ -348,27 +330,22 @@ export default class AbstractService {
model = this.beforeGet(model) model = this.beforeGet(model)
const finalUrl = this.getReplacedRoute(this.paths.getAll, model) const finalUrl = this.getReplacedRoute(this.paths.getAll, model)
return this.http.get(finalUrl, {params: params}) try {
.catch(error => { const response = await this.http.get(finalUrl, {params: params})
return this.errorHandler(error) this.resultCount = Number(response.headers['x-pagination-result-count'])
}) this.totalPages = Number(response.headers['x-pagination-total-pages'])
.then(response => {
this.resultCount = Number(response.headers['x-pagination-result-count'])
this.totalPages = Number(response.headers['x-pagination-total-pages'])
if (Array.isArray(response.data)) { if (response.data === null) {
return Promise.resolve(response.data.map(entry => { return []
return this.modelGetAllFactory(entry) }
}))
} if (Array.isArray(response.data)) {
if (response.data === null) { return response.data.map(entry => this.modelGetAllFactory(entry))
return Promise.resolve([]) }
} return this.modelGetAllFactory(response.data)
return Promise.resolve(this.modelGetAllFactory(response.data)) } finally {
}) cancel()
.finally(() => { }
cancel()
})
} }
/** /**
@ -376,28 +353,24 @@ export default class AbstractService {
* @param model * @param model
* @returns {Promise<any | never>} * @returns {Promise<any | never>}
*/ */
create(model) { async create(model) {
if (this.paths.create === '') { if (this.paths.create === '') {
return Promise.reject({message: 'This model is not able to create data.'}) throw new Error('This model is not able to create data.')
} }
const cancel = this.setLoading() const cancel = this.setLoading()
const finalUrl = this.getReplacedRoute(this.paths.create, model) const finalUrl = this.getReplacedRoute(this.paths.create, model)
return this.http.put(finalUrl, model) try {
.catch(error => { const response = await this.http.put(finalUrl, model)
return this.errorHandler(error) const result = this.modelCreateFactory(response.data)
}) if (typeof model.maxRight !== 'undefined') {
.then(response => { result.maxRight = model.maxRight
const result = this.modelCreateFactory(response.data) }
if (typeof model.maxRight !== 'undefined') { return result
result.maxRight = model.maxRight } finally {
} cancel()
return Promise.resolve(result) }
})
.finally(() => {
cancel()
})
} }
/** /**
@ -407,23 +380,19 @@ export default class AbstractService {
* @param model * @param model
* @returns {Q.Promise<unknown>} * @returns {Q.Promise<unknown>}
*/ */
post(url, model) { async post(url, model) {
const cancel = this.setLoading() const cancel = this.setLoading()
return this.http.post(url, model) try {
.catch(error => { const response = await this.http.post(url, model)
return this.errorHandler(error) const result = this.modelUpdateFactory(response.data)
}) if (typeof model.maxRight !== 'undefined') {
.then(response => { result.maxRight = model.maxRight
const result = this.modelUpdateFactory(response.data) }
if (typeof model.maxRight !== 'undefined') { return result
result.maxRight = model.maxRight } finally {
} cancel()
return Promise.resolve(result) }
})
.finally(() => {
cancel()
})
} }
/** /**
@ -433,7 +402,7 @@ export default class AbstractService {
*/ */
update(model) { update(model) {
if (this.paths.update === '') { if (this.paths.update === '') {
return Promise.reject({message: 'This model is not able to update data.'}) throw new Error('This model is not able to update data.')
} }
const finalUrl = this.getReplacedRoute(this.paths.update, model) const finalUrl = this.getReplacedRoute(this.paths.update, model)
@ -445,24 +414,20 @@ export default class AbstractService {
* @param model * @param model
* @returns {Q.Promise<any>} * @returns {Q.Promise<any>}
*/ */
delete(model) { async delete(model) {
if (this.paths.delete === '') { if (this.paths.delete === '') {
return Promise.reject({message: 'This model is not able to delete data.'}) throw new Error('This model is not able to delete data.')
} }
const cancel = this.setLoading() const cancel = this.setLoading()
const finalUrl = this.getReplacedRoute(this.paths.delete, model) const finalUrl = this.getReplacedRoute(this.paths.delete, model)
return this.http.delete(finalUrl, model) try {
.catch(error => { const {data} = await this.http.delete(finalUrl, model)
return this.errorHandler(error) return data
}) } finally {
.then(response => { cancel()
return Promise.resolve(response.data) }
})
.finally(() => {
cancel()
})
} }
/** /**
@ -496,32 +461,26 @@ export default class AbstractService {
* @param formData * @param formData
* @returns {Q.Promise<unknown>} * @returns {Q.Promise<unknown>}
*/ */
uploadFormData(url, formData) { async uploadFormData(url, formData) {
console.log(formData, formData._boundary)
const cancel = this.setLoading() const cancel = this.setLoading()
return this.http.put( try {
url, const response = await this.http.put(
formData, url,
{ formData,
headers: { {
'Content-Type': headers: {
'multipart/form-data; boundary=' + formData._boundary, 'Content-Type':
'multipart/form-data; boundary=' + formData._boundary,
},
onUploadProgress: progressEvent => {
this.uploadProgress = Math.round((progressEvent.loaded * 100) / progressEvent.total)
},
}, },
onUploadProgress: progressEvent => { )
this.uploadProgress = Math.round((progressEvent.loaded * 100) / progressEvent.total) return this.modelCreateFactory(response.data)
}, } finally {
}, this.uploadProgress = 0
) cancel()
.catch(error => { }
return this.errorHandler(error)
})
.then(response => {
return Promise.resolve(this.modelCreateFactory(response.data))
})
.finally(() => {
this.uploadProgress = 0
cancel()
})
} }
} }

View File

@ -37,9 +37,9 @@ export default class AttachmentService extends AbstractService {
return AbstractService.prototype.getBlobUrl.call(this, '/tasks/' + model.taskId + '/attachments/' + model.id) return AbstractService.prototype.getBlobUrl.call(this, '/tasks/' + model.taskId + '/attachments/' + model.id)
} }
download(model) { async download(model) {
this.getBlobUrl(model) const url = await this.getBlobUrl(model)
.then(url => downloadBlob(url, model.file.name)) return downloadBlob(url, model.file.name)
} }
/** /**

View File

@ -18,17 +18,12 @@ export default class BackgroundUnsplashService extends AbstractService {
return new ListModel(data) return new ListModel(data)
} }
thumb(model) { async thumb(model) {
return this.http({ const response = await this.http({
url: `/backgrounds/unsplash/images/${model.id}/thumb`, url: `/backgrounds/unsplash/images/${model.id}/thumb`,
method: 'GET', method: 'GET',
responseType: 'blob', responseType: 'blob',
}) })
.then(response => { return window.URL.createObjectURL(new Blob([response.data]))
return window.URL.createObjectURL(new Blob([response.data]))
})
.catch(e => {
return e
})
} }
} }

View File

@ -18,7 +18,7 @@ export default class BucketService extends AbstractService {
beforeUpdate(model) { beforeUpdate(model) {
const taskService = new TaskService() const taskService = new TaskService()
model.tasks = model.tasks.map(t => taskService.processModel(t)) model.tasks = model.tasks?.map(t => taskService.processModel(t))
return model return model
} }
} }

View File

@ -6,10 +6,13 @@ export default class DataExportService extends AbstractService {
return this.post('/user/export/request', {password: password}) return this.post('/user/export/request', {password: password})
} }
download(password) { async download(password) {
const clear = this.setLoading() const clear = this.setLoading()
return this.getBlobUrl('/user/export/download', 'POST', {password}) try {
.then(url => downloadBlob(url, 'vikunja-export.zip')) const url = await this.getBlobUrl('/user/export/download', 'POST', {password})
.finally(() => clear()) downloadBlob(url, 'vikunja-export.zip')
} finally {
clear()
}
} }
} }

View File

@ -44,36 +44,27 @@ export default class ListService extends AbstractService {
return super.update(newModel) return super.update(newModel)
} }
background(list) { async background(list) {
if (list.background === null) { if (list.background === null) {
return Promise.resolve('') return ''
} }
return this.http({ const response = await this.http({
url: `/lists/${list.id}/background`, url: `/lists/${list.id}/background`,
method: 'GET', method: 'GET',
responseType: 'blob', responseType: 'blob',
}) })
.then(response => { return window.URL.createObjectURL(new Blob([response.data]))
return window.URL.createObjectURL(new Blob([response.data]))
})
.catch(e => {
return e
})
} }
removeBackground(list) { async removeBackground(list) {
const cancel = this.setLoading() const cancel = this.setLoading()
return this.http.delete(`/lists/${list.id}/background`, list) try {
.then(response => { const response = await this.http.delete(`/lists/${list.id}/background`, list)
return Promise.resolve(response.data) return response.data
}) } finally {
.catch(error => { cancel()
return this.errorHandler(error) }
})
.finally(() => {
cancel()
})
} }
} }

Some files were not shown because too many files have changed in this diff Show More