CS: Eslint

parent 28aea032
...@@ -8,7 +8,7 @@ export default { ...@@ -8,7 +8,7 @@ export default {
if (configuredEditor === 'ckeditor') { if (configuredEditor === 'ckeditor') {
return 'ckeditor'; return 'ckeditor';
} }
return 'ckeditor' return 'ckeditor';
}, },
} },
} };
...@@ -2,6 +2,6 @@ export default { ...@@ -2,6 +2,6 @@ export default {
methods: { methods: {
pushRoute(route) { pushRoute(route) {
this.$router.push(route); this.$router.push(route);
} },
} },
} };
...@@ -6,9 +6,9 @@ export default { ...@@ -6,9 +6,9 @@ export default {
value = value.toLowerCase(); value = value.toLowerCase();
// remove accents, swap ñ for n, etc // remove accents, swap ñ for n, etc
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;"; const from = 'ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;';
var to = "aaaaaeeeeeiiiiooooouuuunc------"; const to = 'aaaaaeeeeeiiiiooooouuuunc------';
for (var i = 0, l = from.length; i < l; i++) { for (let i = 0, l = from.length; i < l; i++) {
value = value.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i)); value = value.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
} }
...@@ -17,6 +17,6 @@ export default { ...@@ -17,6 +17,6 @@ export default {
.replace(/-+/g, '-'); // collapse dashes .replace(/-+/g, '-'); // collapse dashes
return value; return value;
} },
} },
} };
<template> <template>
<div></div>
</template> </template>
<script> <script>
...@@ -8,8 +9,8 @@ ...@@ -8,8 +9,8 @@
return string[0].toUpperCase() + string.substr(1); return string[0].toUpperCase() + string.substr(1);
}, },
ucwords(string) { ucwords(string) {
return string.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); return string.replace(/\w\S*/g, txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
} },
}, },
} };
</script> </script>
...@@ -3,14 +3,14 @@ export default { ...@@ -3,14 +3,14 @@ export default {
trans(string) { trans(string) {
// Makes a string: core.button.cancel | core.button.created at // Makes a string: core.button.cancel | core.button.created at
// to: core["button.cancel"] | core["button.created at"] // to: core["button.cancel"] | core["button.created at"]
let array = string.split('.'); const array = string.split('.');
if (array.length < 2) { return this.$t(string) } if (array.length < 2) { return this.$t(string); }
let first = array.splice(0,1); const first = array.splice(0, 1);
let key = array.join('.'); const key = array.join('.');
return this.$t(`${first}['${key}']`); return this.$t(`${first}['${key}']`);
}, },
} },
} };
...@@ -12,7 +12,7 @@ export default [ ...@@ -12,7 +12,7 @@ export default [
{ {
path: '', path: '',
component: MediaList, component: MediaList,
name: 'admin.media.media.index' name: 'admin.media.media.index',
}, },
{ {
path: ':mediaId/edit', path: ':mediaId/edit',
...@@ -20,8 +20,8 @@ export default [ ...@@ -20,8 +20,8 @@ export default [
name: 'admin.media.media.edit', name: 'admin.media.media.edit',
props: { props: {
locales, locales,
} },
}, },
] ],
} },
]; ];
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<img :src="media.path" alt="" v-if="media.is_image" style="width: 100%;"/> <img :src="media.path" alt="" v-if="media.is_image" style="width: 100%;"/>
<i class="fa fa-file" style="font-size: 50px;" v-else=""></i> <i class="fa fa-file" style="font-size: 50px;" v-else></i>
</div> </div>
</div> </div>
</el-form> </el-form>
...@@ -84,12 +84,12 @@ ...@@ -84,12 +84,12 @@
</template> </template>
<script> <script>
import Form from 'form-backend-validation' import Form from 'form-backend-validation';
import axios from 'axios' import axios from 'axios';
export default { export default {
props: { props: {
locales: {default: null}, locales: { default: null },
}, },
data() { data() {
return { return {
...@@ -101,62 +101,60 @@ ...@@ -101,62 +101,60 @@
keywords: '', keywords: '',
}]) }])
.fromPairs() .fromPairs()
//.merge({template: 'default', is_home: 0, medias_single: []}) // .merge({template: 'default', is_home: 0, medias_single: []})
.value(), .value(),
form: new Form(), form: new Form(),
loading: false, loading: false,
tags: {}, tags: {},
activeTab: window.AsgardCMS.currentLocale || 'en', activeTab: window.AsgardCMS.currentLocale || 'en',
} };
}, },
methods: { methods: {
fetchMedia() { fetchMedia() {
this.loading = true; this.loading = true;
axios.get(route('api.media.media.find', {media: this.$route.params.mediaId})) axios.get(route('api.media.media.find', { media: this.$route.params.mediaId }))
.then(response => { .then((response) => {
this.loading = false; this.loading = false;
this.media = response.data.data; this.media = response.data.data;
this.tags = response.data.data.tags; this.tags = response.data.data.tags;
}) });
.catch(error => {
})
}, },
onSubmit() { onSubmit() {
this.form = new Form(_.merge(this.media, {tags: this.tags})); this.form = new Form(_.merge(this.media, { tags: this.tags }));
this.loading = true; this.loading = true;
this.form.put(route('api.media.media.update', {file: this.media.id})) this.form.put(route('api.media.media.update', { file: this.media.id }))
.then(response => { .then((response) => {
this.loading = false; this.loading = false;
this.$message({ this.$message({
type: 'success', type: 'success',
message: response.message message: response.message,
}); });
this.$router.push({name: 'admin.media.media.index', query: {folder_id: this.media.folder_id}}) this.$router.push({ name: 'admin.media.media.index', query: { folder_id: this.media.folder_id } });
}) })
.catch(error => { .catch((error) => {
console.log(error); console.log(error);
this.loading = false; this.loading = false;
this.$notify.error({ this.$notify.error({
title: 'Error', title: 'Error',
message: 'There are some errors in the form.' message: 'There are some errors in the form.',
}); });
}); });
}, },
onCancel() { onCancel() {
if (this.media.folder_id == 0) { if (this.media.folder_id == 0) {
this.$router.push({name: 'admin.media.media.index', query: {}}); this.$router.push({ name: 'admin.media.media.index', query: {} });
return; return;
} }
this.$router.push({name: 'admin.media.media.index', query: {folder_id: this.media.folder_id}}) this.$router.push({ name: 'admin.media.media.index', query: { folder_id: this.media.folder_id } });
}, },
}, },
mounted() { mounted() {
if (this.$route.params.mediaId !== undefined) { if (this.$route.params.mediaId !== undefined) {
this.fetchMedia(); this.fetchMedia();
} }
} },
} };
</script> </script>
<style> <style>
.el-select{ .el-select{
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<el-button type="primary" :disabled="selectedMedia.length === 0">Move</el-button> <el-button type="primary" :disabled="selectedMedia.length === 0">Move</el-button>
</el-button-group> </el-button-group>
<el-button type="danger" :disabled="selectedMedia.length === 0" <el-button type="danger" :disabled="selectedMedia.length === 0"
@click.preent="batchDelete" :loading="filesAreDeleting"> @click.prevent="batchDelete" :loading="filesAreDeleting">
Delete Delete
</el-button> </el-button>
</div> </div>
...@@ -128,7 +128,7 @@ ...@@ -128,7 +128,7 @@
</template> </template>
<script> <script>
import axios from 'axios' import axios from 'axios';
import NewFolder from './NewFolder.vue'; import NewFolder from './NewFolder.vue';
import UploadButton from './UploadButton.vue'; import UploadButton from './UploadButton.vue';
import RenameFolder from './RenameFolder.vue'; import RenameFolder from './RenameFolder.vue';
...@@ -140,7 +140,7 @@ ...@@ -140,7 +140,7 @@
'rename-folder': RenameFolder, 'rename-folder': RenameFolder,
}, },
props: { props: {
singleModal: {type: Boolean}, singleModal: { type: Boolean },
eventName: {}, eventName: {},
}, },
data() { data() {
...@@ -160,15 +160,15 @@ ...@@ -160,15 +160,15 @@
folderId: 0, folderId: 0,
selectedMedia: {}, selectedMedia: {},
folderBreadcrumb: [ folderBreadcrumb: [
{id: 0, name: 'Home'}, { id: 0, name: 'Home' },
], ],
filesAreDeleting: false, filesAreDeleting: false,
canEditFolders: true, canEditFolders: true,
} };
}, },
methods: { methods: {
queryServer(customProperties) { queryServer(customProperties) {
let properties = { const properties = {
page: this.meta.current_page, page: this.meta.current_page,
per_page: this.meta.per_page, per_page: this.meta.per_page,
order_by: this.order_meta.order_by, order_by: this.order_meta.order_by,
...@@ -178,7 +178,7 @@ ...@@ -178,7 +178,7 @@
}; };
axios.get(route('api.media.all-vue', _.merge(properties, customProperties))) axios.get(route('api.media.all-vue', _.merge(properties, customProperties)))
.then(response => { .then((response) => {
this.tableIsLoading = false; this.tableIsLoading = false;
this.data = response.data.data; this.data = response.data.data;
this.meta = response.data.meta; this.meta = response.data.meta;
...@@ -191,7 +191,7 @@ ...@@ -191,7 +191,7 @@
fetchMediaData() { fetchMediaData() {
this.tableIsLoading = true; this.tableIsLoading = true;
if (this.$route.query.folder_id !== undefined) { if (this.$route.query.folder_id !== undefined) {
this.queryServer({folder_id: this.$route.query.folder_id}); this.queryServer({ folder_id: this.$route.query.folder_id });
this.fetchFolderBreadcrumb(this.$route.query.folder_id); this.fetchFolderBreadcrumb(this.$route.query.folder_id);
return; return;
} }
...@@ -200,40 +200,40 @@ ...@@ -200,40 +200,40 @@
fetchFolderBreadcrumb(folderId) { fetchFolderBreadcrumb(folderId) {
if (folderId === 0) { if (folderId === 0) {
this.folderBreadcrumb = [ this.folderBreadcrumb = [
{id: 0, name: 'Home'}, { id: 0, name: 'Home' },
]; ];
return; return;
} }
axios.get(route('api.media.folders.breadcrumb', {folder: folderId})) axios.get(route('api.media.folders.breadcrumb', { folder: folderId }))
.then(response => { .then((response) => {
this.folderBreadcrumb = response.data; this.folderBreadcrumb = response.data;
}); });
}, },
handleSizeChange(event) { handleSizeChange(event) {
console.log('per page :' + event); console.log(`per page :${event}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({per_page: event}); this.queryServer({ per_page: event });
}, },
handleCurrentChange(event) { handleCurrentChange(event) {
console.log('current page :' + event); console.log(`current page :${event}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({page: event}); this.queryServer({ page: event });
}, },
handleSortChange(event) { handleSortChange(event) {
console.log('sorting', event); console.log('sorting', event);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({order_by: event.prop, order: event.order,}); this.queryServer({ order_by: event.prop, order: event.order });
}, },
performSearch(query) { performSearch(query) {
console.log('searching:' + query); console.log(`searching:${query}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({search: query}); this.queryServer({ search: query });
}, },
enterFolder(scope) { enterFolder(scope) {
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: scope.row.id}); this.queryServer({ folder_id: scope.row.id });
this.folderId = scope.row.id; this.folderId = scope.row.id;
this.$router.push({ query: { folder_id: scope.row.id }}); this.$router.push({ query: { folder_id: scope.row.id } });
this.fetchFolderBreadcrumb(scope.row.id); this.fetchFolderBreadcrumb(scope.row.id);
}, },
insertMedia(scope) { insertMedia(scope) {
...@@ -245,14 +245,14 @@ ...@@ -245,14 +245,14 @@
showEditFolder(scope) { showEditFolder(scope) {
this.$events.emit('editFolderWasClicked', scope); this.$events.emit('editFolderWasClicked', scope);
}, },
changeRoot(folderId, index) { changeRoot(folderId) {
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: folderId}); this.queryServer({ folder_id: folderId });
this.folderId = folderId; this.folderId = folderId;
if (folderId === 0) { if (folderId === 0) {
this.$router.push({ query: {}}); this.$router.push({ query: {} });
} else { } else {
this.$router.push({ query: { folder_id: folderId }}); this.$router.push({ query: { folder_id: folderId } });
} }
this.fetchFolderBreadcrumb(folderId); this.fetchFolderBreadcrumb(folderId);
...@@ -261,17 +261,17 @@ ...@@ -261,17 +261,17 @@
this.$confirm(this.trans('core.modal.confirmation-message'), this.trans('core.modal.title'), { this.$confirm(this.trans('core.modal.confirmation-message'), this.trans('core.modal.title'), {
confirmButtonText: this.trans('core.button.delete'), confirmButtonText: this.trans('core.button.delete'),
cancelButtonText: this.trans('core.button.cancel'), cancelButtonText: this.trans('core.button.cancel'),
type: 'warning' type: 'warning',
}) })
.then(() => { .then(() => {
this.filesAreDeleting = true; this.filesAreDeleting = true;
axios.post(route('api.media.media.batch-destroy'), { axios.post(route('api.media.media.batch-destroy'), {
files: this.selectedMedia files: this.selectedMedia,
}) })
.then(response => { .then((response) => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: response.data.message message: response.data.message,
}); });
this.filesAreDeleting = false; this.filesAreDeleting = false;
this.$refs.mediaTable.clearSelection(); this.$refs.mediaTable.clearSelection();
...@@ -281,12 +281,12 @@ ...@@ -281,12 +281,12 @@
.catch(() => { .catch(() => {
this.$message({ this.$message({
type: 'info', type: 'info',
message: this.trans('core.delete cancelled') message: this.trans('core.delete cancelled'),
}); });
}); });
}, },
goToEdit(scope) { goToEdit(scope) {
this.$router.push({name: 'admin.media.media.edit', params: {mediaId: scope.row.id}}) this.$router.push({ name: 'admin.media.media.edit', params: { mediaId: scope.row.id } });
}, },
}, },
mounted() { mounted() {
...@@ -295,18 +295,18 @@ ...@@ -295,18 +295,18 @@
} }
this.selectedMedia.length = 0; this.selectedMedia.length = 0;
this.fetchMediaData(); this.fetchMediaData();
this.$events.listen('fileWasUploaded', eventData => { this.$events.listen('fileWasUploaded', (eventData) => {
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: eventData.data.folder_id}); this.queryServer({ folder_id: eventData.data.folder_id });
}); });
this.$events.listen('folderWasCreated', eventData => { this.$events.listen('folderWasCreated', (eventData) => {
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: eventData.data.folder_id}); this.queryServer({ folder_id: eventData.data.folder_id });
}); });
this.$events.listen('folderWasUpdated', eventData => { this.$events.listen('folderWasUpdated', (eventData) => {
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({folder_id: eventData.data.folder_id}); this.queryServer({ folder_id: eventData.data.folder_id });
}); });
} },
} };
</script> </script>
...@@ -7,9 +7,9 @@ ...@@ -7,9 +7,9 @@
<script> <script>
export default { export default {
data() { data() {
return {} return {};
}, },
methods: {}, methods: {},
mounted() {} mounted() {},
} };
</script> </script>
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
</template> </template>
<script> <script>
import Form from 'form-backend-validation' import Form from 'form-backend-validation';
export default { export default {
props: { props: {
parentId: {type: Number} parentId: { type: Number },
}, },
data() { data() {
return { return {
...@@ -36,29 +36,29 @@ ...@@ -36,29 +36,29 @@
}, },
form: new Form(), form: new Form(),
loading: false, loading: false,
} };
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.form = new Form(_.merge(this.folder, {parent_id: this.parentId})); this.form = new Form(_.merge(this.folder, { parent_id: this.parentId }));
this.loading = true; this.loading = true;
this.form.post(route('api.media.folders.store')) this.form.post(route('api.media.folders.store'))
.then(response => { .then((response) => {
this.loading = false; this.loading = false;
this.$message({ this.$message({
type: 'success', type: 'success',
message: response.message message: response.message,
}); });
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.folder.name = ''; this.folder.name = '';
this.$events.emit('folderWasCreated', response); this.$events.emit('folderWasCreated', response);
}) })
.catch(error => { .catch((error) => {
console.log(error); console.log(error);
this.loading = false; this.loading = false;
this.$notify.error({ this.$notify.error({
title: 'Error', title: 'Error',
message: 'There are some errors in the form.' message: 'There are some errors in the form.',
}); });
}); });
}, },
...@@ -68,8 +68,8 @@ ...@@ -68,8 +68,8 @@
}, },
}, },
mounted() { mounted() {
} },
} };
</script> </script>
<style> <style>
.new-folder { .new-folder {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</template> </template>
<script> <script>
import Form from 'form-backend-validation' import Form from 'form-backend-validation';
export default { export default {
// props: { // props: {
...@@ -33,28 +33,28 @@ ...@@ -33,28 +33,28 @@
}, },
form: new Form(), form: new Form(),
loading: false, loading: false,
} };
}, },
methods: { methods: {
onSubmit() { onSubmit() {
this.form = new Form(this.folder); this.form = new Form(this.folder);
this.loading = true; this.loading = true;
this.form.post(route('api.media.folders.update', {folder: this.folder.id})) this.form.post(route('api.media.folders.update', { folder: this.folder.id }))
.then(response => { .then((response) => {
this.loading = false; this.loading = false;
this.$message({ this.$message({
type: 'success', type: 'success',
message: response.message message: response.message,
}); });
this.dialogFormVisible = false; this.dialogFormVisible = false;
this.$events.emit('folderWasUpdated', response); this.$events.emit('folderWasUpdated', response);
}) })
.catch(error => { .catch((error) => {
console.log(error); console.log(error);
this.loading = false; this.loading = false;
this.$notify.error({ this.$notify.error({
title: 'Error', title: 'Error',
message: 'There are some errors in the form.' message: 'There are some errors in the form.',
}); });
}); });
}, },
...@@ -64,12 +64,12 @@ ...@@ -64,12 +64,12 @@
}, },
}, },
mounted() { mounted() {
this.$events.listen('editFolderWasClicked', eventData => { this.$events.listen('editFolderWasClicked', (eventData) => {
this.folder.name = eventData.filename; this.folder.name = eventData.filename;
this.folder.id = eventData.id; this.folder.id = eventData.id;
this.folder.parent_id = eventData.folder_id; this.folder.parent_id = eventData.folder_id;
this.dialogFormVisible = true; this.dialogFormVisible = true;
}); });
} },
} };
</script> </script>
...@@ -29,18 +29,18 @@ ...@@ -29,18 +29,18 @@
</template> </template>
<script> <script>
import axios from 'axios';
import UploadZone from './UploadZone.vue'; import UploadZone from './UploadZone.vue';
import MediaList from './MediaList.vue'; import MediaList from './MediaList.vue';
import StringHelpers from '../../../../Core/Assets/js/mixins/StringHelpers' import StringHelpers from '../../../../Core/Assets/js/mixins/StringHelpers.vue';
import axios from 'axios'
export default { export default {
mixins: [StringHelpers], mixins: [StringHelpers],
props: { props: {
zone: {type: String, required: true}, zone: { type: String, required: true },
entity: {type: String, required: true}, entity: { type: String, required: true },
entityId: {type: Number}, entityId: { type: Number },
label: {type: String}, label: { type: String },
}, },
components: { components: {
'upload-zone': UploadZone, 'upload-zone': UploadZone,
...@@ -58,11 +58,11 @@ ...@@ -58,11 +58,11 @@
dialogVisible: false, dialogVisible: false,
selectedMedia: {}, selectedMedia: {},
eventName: '', eventName: '',
} };
}, },
computed: { computed: {
hasSelectedMedia() { hasSelectedMedia() {
return ! _.isEmpty(this.selectedMedia); return !_.isEmpty(this.selectedMedia);
}, },
}, },
methods: { methods: {
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
}, },
unSelectMedia() { unSelectMedia() {
this.selectedMedia = {}; this.selectedMedia = {};
this.$emit('singleFileSelected', _.merge({id: null}, {zone: this.zone})); this.$emit('singleFileSelected', _.merge({ id: null }, { zone: this.zone }));
}, },
fetchMedia() { fetchMedia() {
axios.get(route('api.media.find-first-by-zone-and-entity', { axios.get(route('api.media.find-first-by-zone-and-entity', {
...@@ -79,32 +79,31 @@ ...@@ -79,32 +79,31 @@
entity: this.entity, entity: this.entity,
entity_id: this.entityId, entity_id: this.entityId,
})) }))
.then(response => { .then((response) => {
this.$emit('singleFileSelected', _.merge(response.data.data, {zone: this.zone})); this.$emit('singleFileSelected', _.merge(response.data.data, { zone: this.zone }));
this.selectedMedia = response.data.data; this.selectedMedia = response.data.data;
}) });
}, },
getFieldLabel() { getFieldLabel() {
return this.label || this.ucwords(this.zone.replace('_', ' ')); return this.label || this.ucwords(this.zone.replace('_', ' '));
}, },
makeId() { makeId() {
let text = ""; let text = '';
let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 5; i++) for (let i = 0; i < 5; i++) { text += possible.charAt(Math.floor(Math.random() * possible.length)); }
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text; return text;
}, },
}, },
mounted() { mounted() {
this.eventName = 'fileWasSelected' + this.makeId() + Math.floor(Math.random() * 999999); this.eventName = `fileWasSelected${this.makeId()}${Math.floor(Math.random() * 999999)}`;
this.$events.listen(this.eventName, mediaData => { this.$events.listen(this.eventName, (mediaData) => {
this.dialogVisible = false; this.dialogVisible = false;
this.selectedMedia = mediaData; this.selectedMedia = mediaData;
this.$emit('singleFileSelected', _.merge(mediaData, {zone: this.zone})); this.$emit('singleFileSelected', _.merge(mediaData, { zone: this.zone }));
}); });
} },
} };
</script> </script>
...@@ -13,56 +13,56 @@ ...@@ -13,56 +13,56 @@
</template> </template>
<script> <script>
import axios from 'axios' import axios from 'axios';
export default { export default {
props: { props: {
parentId: {type: Number} parentId: { type: Number },
}, },
data() { data() {
return { return {
fileIsUploading: false, fileIsUploading: false,
} };
}, },
computed: { computed: {
uploadUrl() { uploadUrl() {
return route('api.media.store').domain + route('api.media.store').url; return route('api.media.store').domain + route('api.media.store').url;
}, },
requestHeaders() { requestHeaders() {
let userApiToken = document.head.querySelector('meta[name="user-api-token"]'); const userApiToken = document.head.querySelector('meta[name="user-api-token"]');
return { return {
'Authorization': 'Bearer ' + userApiToken.content Authorization: `Bearer ${userApiToken.content}`,
}; };
}, },
}, },
methods: { methods: {
handleSuccess(response, file, fileList) { handleSuccess(response) {
this.$events.emit('fileWasUploaded', response); this.$events.emit('fileWasUploaded', response);
}, },
uploadFile(event) { uploadFile(event) {
this.fileIsUploading = true; this.fileIsUploading = true;
let data = new FormData(); const data = new FormData();
data.append('parent_id', this.parentId); data.append('parent_id', this.parentId);
data.append('file', event.file); data.append('file', event.file);
axios.post(route('api.media.store'), data) axios.post(route('api.media.store'), data)
.then(response => { .then((response) => {
this.$events.emit('fileWasUploaded', response); this.$events.emit('fileWasUploaded', response);
this.fileIsUploading = false; this.fileIsUploading = false;
}) })
.catch(error => { .catch((error) => {
console.log(error.response.data); console.log(error.response.data);
this.fileIsUploading = false; this.fileIsUploading = false;
this.$notify.error({ this.$notify.error({
title: 'Error', title: 'Error',
message: error.response.data.errors.file[0] message: error.response.data.errors.file[0],
}); });
}); });
}, },
handleRemove() {}, handleRemove() {},
}, },
mounted() { mounted() {
} },
} };
</script> </script>
<style> <style>
.el-upload__input { .el-upload__input {
......
...@@ -23,29 +23,29 @@ ...@@ -23,29 +23,29 @@
data() { data() {
return { return {
fileList: [], fileList: [],
} };
}, },
computed: { computed: {
uploadUrl() { uploadUrl() {
return route('api.media.store').domain + route('api.media.store').url; return route('api.media.store').domain + route('api.media.store').url;
}, },
requestHeaders() { requestHeaders() {
let userApiToken = document.head.querySelector('meta[name="user-api-token"]'); const userApiToken = document.head.querySelector('meta[name="user-api-token"]');
return { return {
'Authorization': 'Bearer ' + userApiToken.content Authorization: `Bearer ${userApiToken.content}`,
}; };
}, },
}, },
methods: { methods: {
handleSuccess(response, file, fileList) { handleSuccess(response) {
this.$events.emit('fileWasUploaded', response); this.$events.emit('fileWasUploaded', response);
this.fileList = []; this.fileList = [];
}, },
handlePreview() {}, handlePreview() {},
handleRemove() {}, handleRemove() {},
}, },
mounted() {} mounted() {},
} };
</script> </script>
<style> <style>
.el-upload__input { .el-upload__input {
......
import PageTable from './components/PageTable.vue' import PageTable from './components/PageTable.vue';
import PageTableServerSide from './components/PageTableServerSide.vue' import PageTableServerSide from './components/PageTableServerSide.vue';
import PageForm from './components/PageForm.vue' import PageForm from './components/PageForm.vue';
const locales = window.AsgardCMS.locales; const locales = window.AsgardCMS.locales;
...@@ -17,7 +17,7 @@ export default [ ...@@ -17,7 +17,7 @@ export default [
props: { props: {
locales, locales,
pageTitle: 'create page', pageTitle: 'create page',
} },
}, },
{ {
path: '/page/pages/:pageId/edit', path: '/page/pages/:pageId/edit',
...@@ -26,6 +26,6 @@ export default [ ...@@ -26,6 +26,6 @@ export default [
props: { props: {
locales, locales,
pageTitle: 'edit page', pageTitle: 'edit page',
} },
}, },
]; ];
...@@ -105,9 +105,9 @@ ...@@ -105,9 +105,9 @@
</template> </template>
<script> <script>
import axios from 'axios' import axios from 'axios';
import _ from "lodash"; import _ from 'lodash';
import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper' import ShortcutHelper from '../../../../Core/Assets/js/mixins/ShortcutHelper';
let data; let data;
...@@ -129,16 +129,16 @@ ...@@ -129,16 +129,16 @@
tableIsLoading: false, tableIsLoading: false,
showExtraButtons: false, showExtraButtons: false,
selectedPages: {}, selectedPages: {},
} };
}, },
watch: { watch: {
selectedPages() { selectedPages() {
this.selectedPages.length >= 1 ? this.showExtraButtons = true : this.showExtraButtons = false; this.selectedPages.length >= 1 ? this.showExtraButtons = true : this.showExtraButtons = false;
} },
}, },
methods: { methods: {
queryServer(customProperties) { queryServer(customProperties) {
let properties = { const properties = {
page: this.meta.current_page, page: this.meta.current_page,
per_page: this.meta.per_page, per_page: this.meta.per_page,
order_by: this.order_meta.order_by, order_by: this.order_meta.order_by,
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
}; };
axios.get(route('api.page.page.indexServerSide', _.merge(properties, customProperties))) axios.get(route('api.page.page.indexServerSide', _.merge(properties, customProperties)))
.then(response => { .then((response) => {
this.tableIsLoading = false; this.tableIsLoading = false;
this.data = response.data.data; this.data = response.data.data;
this.meta = response.data.meta; this.meta = response.data.meta;
...@@ -162,58 +162,56 @@ ...@@ -162,58 +162,56 @@
this.queryServer(); this.queryServer();
}, },
handleSizeChange(event) { handleSizeChange(event) {
console.log('per page :' + event); console.log(`per page :${event}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({per_page: event}); this.queryServer({ per_page: event });
}, },
handleCurrentChange(event) { handleCurrentChange(event) {
console.log('current page :' + event); console.log(`current page :${event}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({page: event}); this.queryServer({ page: event });
}, },
handleSortChange(event) { handleSortChange(event) {
console.log('sorting', event); console.log('sorting', event);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({order_by: event.prop, order: event.order,}); this.queryServer({ order_by: event.prop, order: event.order });
}, },
performSearch(query) { performSearch(query) {
console.log('searching:' + query); console.log(`searching:${query}`);
this.tableIsLoading = true; this.tableIsLoading = true;
this.queryServer({search: query}); this.queryServer({ search: query });
}, },
handleExtraActions(action) { handleExtraActions(action) {
let pageIds = _.map(this.selectedPages, function(elem) { const pageIds = _.map(this.selectedPages, elem => elem.id);
return elem.id; axios.get(route('api.page.page.mark-status', { action, pageIds: JSON.stringify(pageIds) }))
}); .then((response) => {
axios.get(route('api.page.page.mark-status', {action: action, pageIds: JSON.stringify(pageIds)}))
.then(response => {
this.$message({ this.$message({
type: 'success', type: 'success',
message: response.data.message message: response.data.message,
}); });
this.$refs.pageTable.clearSelection(); this.$refs.pageTable.clearSelection();
this.data.find(function (page) { this.data.find((page) => {
if (pageIds.indexOf(page.id) >= 0) { if (pageIds.indexOf(page.id) >= 0) {
page.translations.status = action === 'mark-online'; page.translations.status = action === 'mark-online';
} }
}); });
}) })
.catch(error => { .catch(() => {
this.$message({ this.$message({
type: 'error', type: 'error',
message: this.trans('core.something went wrong'), message: this.trans('core.something went wrong'),
}); });
}) });
}, },
handleSelectionChange(selectedPages) { handleSelectionChange(selectedPages) {
this.selectedPages = selectedPages; this.selectedPages = selectedPages;
}, },
goToEdit(scope) { goToEdit(scope) {
this.$router.push({name: 'admin.page.page.edit', params: {pageId: scope.row.id}}) this.$router.push({ name: 'admin.page.page.edit', params: { pageId: scope.row.id } });
}, },
}, },
mounted() { mounted() {
this.fetchData(); this.fetchData();
} },
} };
</script> </script>
require('./bootstrap'); require('./bootstrap');
import Vue from 'vue' import Vue from 'vue';
import VueI18n from 'vue-i18n' import VueI18n from 'vue-i18n';
import VueRouter from 'vue-router' import VueRouter from 'vue-router';
import ElementUI from 'element-ui' import ElementUI from 'element-ui';
import DataTables from 'vue-data-tables' import DataTables from 'vue-data-tables';
import VueEvents from 'vue-events' import VueEvents from 'vue-events';
import locale from 'element-ui/lib/locale/lang/en' import locale from 'element-ui/lib/locale/lang/en';
import VueSimplemde from 'vue-simplemde' import VueSimplemde from 'vue-simplemde';
Vue.use(ElementUI, { locale }); Vue.use(ElementUI, { locale });
Vue.use(DataTables, { locale }); Vue.use(DataTables, { locale });
Vue.use(VueI18n); Vue.use(VueI18n);
Vue.use(VueRouter); Vue.use(VueRouter);
Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] }); Vue.use(require('vue-shortkey'), { prevent: ['input', 'textarea'] });
Vue.use(VueEvents); Vue.use(VueEvents);
Vue.use(VueSimplemde); Vue.use(VueSimplemde);
require('./mixins'); require('./mixins');
...@@ -24,17 +25,18 @@ Vue.component('DeleteButton', require('../../../../../Modules/Core/Assets/js/com ...@@ -24,17 +25,18 @@ Vue.component('DeleteButton', require('../../../../../Modules/Core/Assets/js/com
Vue.component('TagsInput', require('../../../../../Modules/Tag/Assets/js/components/TagInput.vue')); Vue.component('TagsInput', require('../../../../../Modules/Tag/Assets/js/components/TagInput.vue'));
Vue.component('SingleMedia', require('../../../../../Modules/Media/Assets/js/components/SingleMedia.vue')); Vue.component('SingleMedia', require('../../../../../Modules/Media/Assets/js/components/SingleMedia.vue'));
Vue.component('MediaManager', require('../../../../../Modules/Media/Assets/js/components/MediaManager.vue')); Vue.component('MediaManager', require('../../../../../Modules/Media/Assets/js/components/MediaManager.vue'));
import PageRoutes from '../../../../../Modules/Page/Assets/js/PageRoutes'; import PageRoutes from '../../../../../Modules/Page/Assets/js/PageRoutes';
import MediaRoutes from '../../../../../Modules/Media/Assets/js/MediaRoutes'; import MediaRoutes from '../../../../../Modules/Media/Assets/js/MediaRoutes';
const currentLocale = window.AsgardCMS.currentLocale; const currentLocale = window.AsgardCMS.currentLocale;
const adminPrefix = window.AsgardCMS.adminPrefix; const adminPrefix = window.AsgardCMS.adminPrefix;
const router = new VueRouter({ const router = new VueRouter({
mode: 'history', mode: 'history',
base: makeBaseUrl(), base: makeBaseUrl(),
routes : [ routes: [
...PageRoutes, ...PageRoutes,
...MediaRoutes, ...MediaRoutes,
], ],
...@@ -47,7 +49,7 @@ function makeBaseUrl() { ...@@ -47,7 +49,7 @@ function makeBaseUrl() {
return `${currentLocale}/${adminPrefix}`; return `${currentLocale}/${adminPrefix}`;
} }
let messages = { const messages = {
[currentLocale]: window.AsgardCMS.translations, [currentLocale]: window.AsgardCMS.translations,
}; };
...@@ -62,7 +64,7 @@ const app = new Vue({ ...@@ -62,7 +64,7 @@ const app = new Vue({
i18n, i18n,
}); });
window.axios.interceptors.response.use(null, function(error) { window.axios.interceptors.response.use(null, (error) => {
if (error.response === undefined) { if (error.response === undefined) {
console.log(error); console.log(error);
return; return;
......
import Vue from 'vue' import Vue from 'vue';
import TranslationHelper from '../../../../../Modules/Core/Assets/js/mixins/TranslationHelper'; import TranslationHelper from '../../../../../Modules/Core/Assets/js/mixins/TranslationHelper';
Vue.mixin(TranslationHelper); Vue.mixin(TranslationHelper);
This diff is collapsed.
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