Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/app.js
/** | /** | ||||
* First we will load all of this project's JavaScript dependencies which | * First we will load all of this project's JavaScript dependencies which | ||||
* includes Vue and other libraries. It is a great starting point when | * includes Vue and other libraries. It is a great starting point when | ||||
* building robust, powerful web applications using Vue and Laravel. | * building robust, powerful web applications using Vue and Laravel. | ||||
*/ | */ | ||||
require('./bootstrap') | require('./bootstrap') | ||||
import AppComponent from '../vue/App' | import AppComponent from '../vue/App' | ||||
import MenuComponent from '../vue/Widgets/Menu' | import MenuComponent from '../vue/Widgets/Menu' | ||||
import SupportForm from '../vue/Widgets/SupportForm' | import SupportForm from '../vue/Widgets/SupportForm' | ||||
import { Tab } from 'bootstrap' | |||||
import { loadLangAsync, i18n } from './locale' | import { loadLangAsync, i18n } from './locale' | ||||
import { clearFormValidation, pick, startLoading, stopLoading } from './utils' | import { clearFormValidation, pick, startLoading, stopLoading } from './utils' | ||||
const routerState = { | const routerState = { | ||||
afterLogin: null, | afterLogin: null, | ||||
isLoggedIn: !!localStorage.getItem('token') | isLoggedIn: !!localStorage.getItem('token') | ||||
} | } | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | methods: { | ||||
logo(mode) { | logo(mode) { | ||||
let src = this.appUrl + this.themeDir + '/images/logo_' + (mode || 'header') + '.png' | let src = this.appUrl + this.themeDir + '/images/logo_' + (mode || 'header') + '.png' | ||||
return `<img src="${src}" alt="${this.appName}">` | return `<img src="${src}" alt="${this.appName}">` | ||||
}, | }, | ||||
pick, | pick, | ||||
startLoading, | startLoading, | ||||
stopLoading, | stopLoading, | ||||
tab(e) { | |||||
e.preventDefault() | |||||
new Tab(e.target).show() | |||||
}, | |||||
errorPage(code, msg, hint) { | errorPage(code, msg, hint) { | ||||
// Until https://github.com/vuejs/vue-router/issues/977 is implemented | // Until https://github.com/vuejs/vue-router/issues/977 is implemented | ||||
// we can't really use router to display error page as it has two side | // we can't really use router to display error page as it has two side | ||||
// effects: it changes the URL and adds the error page to browser history. | // effects: it changes the URL and adds the error page to browser history. | ||||
// For now we'll be replacing current view with error page "manually". | // For now we'll be replacing current view with error page "manually". | ||||
if (!msg) msg = this.$te('error.' + code) ? this.$t('error.' + code) : this.$t('error.unknown') | if (!msg) msg = this.$te('error.' + code) ? this.$t('error.' + code) : this.$t('error.unknown') | ||||
if (!hint) hint = '' | if (!hint) hint = '' | ||||
Show All 17 Lines | methods: { | ||||
// Remember requested route to come back to it after log in | // Remember requested route to come back to it after log in | ||||
if (this.$route.meta.requiresAuth) { | if (this.$route.meta.requiresAuth) { | ||||
routerState.afterLogin = this.$route | routerState.afterLogin = this.$route | ||||
this.logoutUser() | this.logoutUser() | ||||
} else { | } else { | ||||
this.logoutUser(false) | this.logoutUser(false) | ||||
} | } | ||||
} else { | } else { | ||||
if (!error.response) { | |||||
console.error(error) | |||||
} | |||||
this.errorPage(status, message) | this.errorPage(status, message) | ||||
} | } | ||||
}, | }, | ||||
price(price, currency) { | price(price, currency) { | ||||
// TODO: Set locale argument according to the currently used locale | // TODO: Set locale argument according to the currently used locale | ||||
return ((price || 0) / 100).toLocaleString('de-DE', { style: 'currency', currency: currency || 'CHF' }) | return ((price || 0) / 100).toLocaleString('de-DE', { style: 'currency', currency: currency || 'CHF' }) | ||||
}, | }, | ||||
priceLabel(cost, discount, currency) { | priceLabel(cost, discount, currency) { | ||||
▲ Show 20 Lines • Show All 239 Lines • Show Last 20 Lines |