Skip to content

Commit

Permalink
Publishing module assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nWidart committed Sep 16, 2017
1 parent 7950d0d commit 7f59680
Show file tree
Hide file tree
Showing 9 changed files with 776 additions and 0 deletions.
97 changes: 97 additions & 0 deletions public/modules/core/js/components/CkEditor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<template>
<div class="ckeditor">
<textarea
:name="name"
:id="id"
:value="value"
:types="types"
:config="config">
</textarea>
</div>
</template>

<script>
// Source: https://github.com/dangvanthanh/vue-ckeditor2
let inc = 0
export default {
name: 'vue-ckeditor',
props: {
name: {
type: String,
default: () => `editor-${++inc}`
},
value: {
type: String
},
id: {
type: String,
default: () => `editor-${inc}`
},
types: {
type: String,
default: () => `classic`
},
config: {
type: Object,
default: () => {}
}
},
data () {
return { destroyed: false }
},
computed: {
instance () {
return CKEDITOR.instances[this.id]
}
},
watch: {
value (val) {
let html = this.instance.getData();
if (val !== html) {
this.instance.setData(val);
}
}
},
mounted () {
if (typeof CKEDITOR === 'undefined') {
console.log('CKEDITOR is missing (http://ckeditor.com/)')
} else {
if (this.types === 'inline') {
CKEDITOR.inline(this.id, this.config)
} else {
CKEDITOR.replace(this.id, this.config)
}
this.instance.on('change', () => {
let html = this.instance.getData()
if (html !== this.value) {
this.$emit('input', html)
this.$emit('update:value', html)
}
})
this.instance.on('blur', () => {
this.$emit('blur', this.instance)
})
this.instance.on('focus', () => {
this.$emit('focus', this.instance)
})
}
},
beforeDestroy () {
if (!this.destroyed) {
this.instance.focusManager.blur(true)
this.instance.removeAllListeners()
try {
this.instance.destroy()
} catch (e) { }
this.destroyed = true
}
}
}
</script>
<style>
.ckeditor::after {
content: "";
display: table;
clear: both;
}
</style>
57 changes: 57 additions & 0 deletions public/modules/core/js/components/DeleteComponent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<template>
<button class="btn btn-danger btn-flat" @click="deleteRow"><i class="fa fa-trash"></i></button>
</template>

<script>
import Translate from '../../../../Core/Assets/js/mixins/Translate'
export default {
mixins: [Translate],
props: {
rows: {default: null},
scope: {default: null},
},
data() {
return {
deleteMessage: '',
deleteTitle: '',
}
},
methods: {
deleteRow(event) {
this.$confirm(this.deleteMessage, this.deleteTitle, {
confirmButtonText: this.translate('core', 'button.delete'),
cancelButtonText: this.translate('core', 'button.cancel'),
type: 'warning'
}).then(() => {
let vm = this;
axios.delete(this.scope.row.urls.delete_url)
.then(response => {
if (response.data.errors === false) {
vm.$message({
type: 'success',
message: response.data.message
});
vm.rows.splice(vm.scope.$index, 1);
}
})
.catch(error => {
vm.$message({
type: 'error',
message: response.data.message
});
});
}).catch(() => {
this.$message({
type: 'info',
message: this.translate('core', 'delete cancelled')
});
});
}
},
mounted() {
this.deleteMessage = this.translate('core', 'modal.confirmation-message');
this.deleteTitle = this.translate('core', 'modal.title');
}
}
</script>
22 changes: 22 additions & 0 deletions public/modules/core/js/mixins/Slugify.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
methods: {
slugify(string) {
let value;
value = string.replace(/^\s+|\s+$/g, ''); // trim
value = value.toLowerCase();

// remove accents, swap ñ for n, etc
var from = "ãàáäâẽèéëêìíïîõòóöôùúüûñç·/_,:;";
var to = "aaaaaeeeeeiiiiooooouuuunc------";
for (var i = 0, l = from.length; i < l; i++) {
value = value.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
}

value = value.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
.replace(/\s+/g, '-') // collapse whitespace and replace by -
.replace(/-+/g, '-'); // collapse dashes

return value;
}
}
}
10 changes: 10 additions & 0 deletions public/modules/core/js/mixins/Translate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
props: {
translations: {default: null}
},
methods: {
translate(namespace, name) {
return _.get(this.translations[namespace], name);
}
}
}
37 changes: 37 additions & 0 deletions public/modules/page/js/PageRoutes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import PageTable from './components/PageTable.vue'
import PageTableServerSide from './components/PageTableServerSide.vue'
import PageForm from './components/PageForm.vue'

const translations = window.translations;
const locales = window.locales;

export default [
{
path: '/page/pages',
name: 'admin.page.page.index',
component: PageTableServerSide,
props: {
translations,
}
},
{
path: '/page/pages/create',
name: 'admin.page.page.create',
component: PageForm,
props: {
translations,
locales,
pageTitle: 'create page',
}
},
{
path: '/page/pages/:pageId/edit',
name: 'admin.page.page.edit',
component: PageForm,
props: {
translations,
locales,
pageTitle: 'edit page',
}
},
];
Loading

0 comments on commit 7f59680

Please sign in to comment.