-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
776 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
} | ||
}, | ||
]; |
Oops, something went wrong.