More Eslint configuration and customisations

parent 14c219f2
module.exports = {
"extends": [
"airbnb-base",
'plugin:vue/recommended'
]
extends: [
'airbnb-base',
'plugin:vue/recommended',
],
rules: {
indent: [2, 4],
'no-undef': 'off',
'max-len': 'off',
'no-console': 'off',
},
overrides: [
{
files: ['*.vue', '**/*.vue'],
rules: {
indent: 'off',
},
},
],
};
......@@ -152,19 +152,18 @@
</template>
<script>
import axios from 'axios'
import Slugify from '../../../../Core/Assets/js/mixins/Slugify'
import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper'
import ActiveEditor from '../../../../Core/Assets/js/mixins/ActiveEditor'
import SingleFileSelector from '../../../../Media/Assets/js/mixins/SingleFileSelector'
import Form from 'form-backend-validation'
import axios from 'axios';
import Form from 'form-backend-validation';
import Slugify from '../../../../Core/Assets/js/mixins/Slugify';
import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper';
import ActiveEditor from '../../../../Core/Assets/js/mixins/ActiveEditor';
import SingleFileSelector from '../../../../Media/Assets/js/mixins/SingleFileSelector';
export default {
mixins: [Slugify, ShortcutHelper, ActiveEditor, SingleFileSelector],
props: {
locales: {default: null},
pageTitle: {default: null, String},
locales: { default: null },
pageTitle: { default: null, String },
},
data() {
return {
......@@ -181,49 +180,49 @@
og_type: '',
}])
.fromPairs()
.merge({template: 'default', is_home: 0, medias_single: []})
.merge({ template: 'default', is_home: 0, medias_single: [] })
.value(),
templates: {
'index': 'index',
'home': 'home',
'default': 'default',
index: 'index',
home: 'home',
default: 'default',
},
form: new Form(),
loading: false,
tags: {},
activeTab: window.AsgardCMS.currentLocale || 'en',
}
};
},
methods: {
onSubmit() {
this.form = new Form(_.merge(this.page, {tags: this.tags}));
this.form = new Form(_.merge(this.page, { tags: this.tags }));
this.loading = true;
this.form.post(this.getRoute())
.then(response => {
.then((response) => {
this.loading = false;
this.$message({
type: 'success',
message: response.message
message: response.message,
});
this.$router.push({name: 'admin.page.page.index'});
this.$router.push({ name: 'admin.page.page.index' });
})
.catch(error => {
.catch((error) => {
console.log(error);
this.loading = false;
this.$notify.error({
title: 'Error',
message: 'There are some errors in the form.'
message: 'There are some errors in the form.',
});
});
},
onCancel() {
this.$router.push({name: 'admin.page.page.index'});
this.$router.push({ name: 'admin.page.page.index' });
},
fetchTemplates() {
axios.get(route('api.page.page-templates.index'))
.then(response => {
.then((response) => {
this.templates = response.data;
});
},
......@@ -232,19 +231,17 @@
},
fetchPage() {
this.loading = true;
axios.post(route('api.page.page.find', {page: this.$route.params.pageId}))
.then(response => {
axios.post(route('api.page.page.find', { page: this.$route.params.pageId }))
.then((response) => {
this.loading = false;
this.page = response.data.data;
this.tags = response.data.data.tags;
$('.publicUrl').attr('href', this.page.urls.public_url).show();
})
.catch(error => {
})
});
},
getRoute() {
if (this.$route.params.pageId !== undefined) {
return route('api.page.page.update', {page: this.$route.params.pageId});
return route('api.page.page.update', { page: this.$route.params.pageId });
}
return route('api.page.page.store');
},
......@@ -258,6 +255,6 @@
},
destroyed() {
$('.publicUrl').hide();
}
}
},
};
</script>
<template>
</template>
<script>
export default {
data() {
return {
};
},
methods: {},
mounted() {
},
};
</script>
......@@ -11,11 +11,11 @@ import VueSimplemde from 'vue-simplemde';
import PageRoutes from '../../../Modules/Page/Assets/js/PageRoutes';
import MediaRoutes from '../../../Modules/Media/Assets/js/MediaRoutes';
Vue.use(ElementUI, {locale});
Vue.use(DataTables, {locale});
Vue.use(ElementUI, { locale });
Vue.use(DataTables, { locale });
Vue.use(VueI18n);
Vue.use(VueRouter);
Vue.use(require('vue-shortkey'), {prevent: ['input', 'textarea']});
Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] });
Vue.use(VueEvents);
Vue.use(VueSimplemde);
......@@ -34,54 +34,54 @@ const currentLocale = window.AsgardCMS.currentLocale;
const adminPrefix = window.AsgardCMS.adminPrefix;
function makeBaseUrl() {
if (window.AsgardCMS.hideDefaultLocaleInURL == 1) {
return adminPrefix;
}
return `${currentLocale}/${adminPrefix}`;
if (window.AsgardCMS.hideDefaultLocaleInURL == 1) {
return adminPrefix;
}
return `${currentLocale}/${adminPrefix}`;
}
const router = new VueRouter({
mode: 'history',
base: makeBaseUrl(),
routes: [
...PageRoutes,
...MediaRoutes,
],
mode: 'history',
base: makeBaseUrl(),
routes: [
...PageRoutes,
...MediaRoutes,
],
});
const messages = {
[currentLocale]: window.AsgardCMS.translations,
[currentLocale]: window.AsgardCMS.translations,
};
const i18n = new VueI18n({
locale: currentLocale,
messages,
locale: currentLocale,
messages,
});
const app = new Vue({
el: '#app',
router,
i18n,
el: '#app',
router,
i18n,
});
window.axios.interceptors.response.use(null, (error) => {
if (error.response === undefined) {
console.log(error);
return;
}
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'),
});
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'),
});
window.location = route('login');
}
return Promise.reject(error);
if (error.response === undefined) {
console.log(error);
return;
}
if (error.response.status === 403) {
app.$notify.error({
title: app.$t('core.unauthorized'),
message: app.$t('core.unauthorized-access'),
});
window.location = route('dashboard.index');
}
if (error.response.status === 401) {
app.$notify.error({
title: app.$t('core.unauthenticated'),
message: app.$t('core.unauthenticated-message'),
});
window.location = route('login');
}
return Promise.reject(error);
});
......@@ -32,25 +32,25 @@ window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
const token = document.head.querySelector('meta[name="csrf-token"]');
if (token) {
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content;
} else {
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
console.error('CSRF token not found: https://laravel.com/docs/csrf#csrf-x-csrf-token');
}
const userApiToken = document.head.querySelector('meta[name="user-api-token"]');
if (userApiToken) {
window.axios.defaults.headers.common.Authorization = `Bearer ${userApiToken.content}`;
window.axios.defaults.headers.common.Authorization = `Bearer ${userApiToken.content}`;
} else {
console.error('User API token not found in a meta tag.');
console.error('User API token not found in a meta tag.');
}
const currentLocale = document.head.querySelector('meta[name="current-locale"]');
if (currentLocale) {
window.AsgardCMS.currentLocale = currentLocale.content;
window.AsgardCMS.currentLocale = currentLocale.content;
} else {
console.error('Current locale token not found in a meta tag.');
console.error('Current locale token not found in a meta tag.');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment