Commit b191b893 authored by Edgar Z. Alvarenga's avatar Edgar Z. Alvarenga

Automatic slug creation for Idea Spaces

parent 1f18b2f6
...@@ -15691,6 +15691,11 @@ ...@@ -15691,6 +15691,11 @@
"integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=", "integrity": "sha1-VusCfWW00tzmyy4tMsTUr8nh1wc=",
"dev": true "dev": true
}, },
"slugify": {
"version": "1.3.4",
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.3.4.tgz",
"integrity": "sha512-KP0ZYk5hJNBS8/eIjGkFDCzGQIoZ1mnfQRYS5WM3273z+fxGWXeN0fkwf2ebEweydv9tioZIHGZKoF21U07/nw=="
},
"smart-buffer": { "smart-buffer": {
"version": "1.1.15", "version": "1.1.15",
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz",
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
"moment": "^2.24.0", "moment": "^2.24.0",
"papaparse": "4.6.2", "papaparse": "4.6.2",
"sass-loader": "7.1.0", "sass-loader": "7.1.0",
"slugify": "^1.3.4",
"uuid": "3.2.1", "uuid": "3.2.1",
"vee-validate": "^2.1.6", "vee-validate": "^2.1.6",
"vue": "2.5.16", "vue": "2.5.16",
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<v-expansion-panel> <v-expansion-panel>
<v-expansion-panel-content v-if="$auth.user().role.indexOf('admin') >= 0"> <v-expansion-panel-content v-if="$auth.user().role.indexOf('admin') >= 0">
<div slot="header">School<span v-if="hasSelectedSchool">: {{ $store.getters.schoolName }}</span></div> <div slot="header">{{ $vuetify.t('$vuetify.AdminCommunity.community') }}<span v-if="hasSelectedSchool">: {{ $store.getters.schoolName }}</span></div>
<School></School> <School></School>
</v-expansion-panel-content> </v-expansion-panel-content>
......
...@@ -25,8 +25,9 @@ ...@@ -25,8 +25,9 @@
<v-flex d-flex xs12 sm12 pa-2> <v-flex d-flex xs12 sm12 pa-2>
<v-text-field <v-text-field
name="slug" name="slug"
v-model="newIdeaSpace.slug" v-model="slug"
v-validate="'required'" v-validate="'required'"
readonly
:label="this.$vuetify.t('$vuetify.AdminIdeaSpace.formIdeaSpaceUrlName')" :label="this.$vuetify.t('$vuetify.AdminIdeaSpace.formIdeaSpaceUrlName')"
required required
></v-text-field> ></v-text-field>
...@@ -73,7 +74,7 @@ ...@@ -73,7 +74,7 @@
</v-flex> </v-flex>
<v-flex d-flex xs12 sm12 pa-2> <v-flex d-flex xs12 sm12 pa-2>
<v-btn <v-btn
@click="ideaSpaceCreationDialog = true" @click="openIdeaSpaceEditor"
> >
{{ $vuetify.t('$vuetify.AdminIdeaSpace.add') }} {{ $vuetify.t('$vuetify.AdminIdeaSpace.add') }}
</v-btn> </v-btn>
...@@ -85,6 +86,7 @@ ...@@ -85,6 +86,7 @@
<script> <script>
import api from '@/api' import api from '@/api'
import slugify from 'slugify'
export default { export default {
name: 'IdeaSpacesAdmin', name: 'IdeaSpacesAdmin',
...@@ -116,6 +118,9 @@ export default { ...@@ -116,6 +118,9 @@ export default {
}, },
computed: { computed: {
slug: function () {
return slugify(this.newIdeaSpace.title)
}
}, },
props: { props: {
...@@ -126,6 +131,16 @@ export default { ...@@ -126,6 +131,16 @@ export default {
}, },
methods: { methods: {
openIdeaSpaceEditor: function () {
this.newIdeaSpace = {
school_id: this.$store.getters.selected_school,
title: '',
image: '/static/img/svg/door1.svg'
}
this.ideaSpaceCreationDialog = true
},
getIdeaSpaces: function () { getIdeaSpaces: function () {
api.ideaSpace.getIdeaSpaces(this.$store.getters.selected_school).then(response => { api.ideaSpace.getIdeaSpaces(this.$store.getters.selected_school).then(response => {
this.ideaSpaces = response.data this.ideaSpaces = response.data
...@@ -134,11 +149,13 @@ export default { ...@@ -134,11 +149,13 @@ export default {
addIdeaSpace: function () { addIdeaSpace: function () {
if (!this.isEditing) { if (!this.isEditing) {
this.newIdeaSpace.created_by = this.$store.getters.userId this.newIdeaSpace.created_by = this.$store.getters.userId
this.newIdeaSpace.slug = this.slug
api.ideaSpace.createIdeaSpace(this.newIdeaSpace).then(() => { api.ideaSpace.createIdeaSpace(this.newIdeaSpace).then(() => {
this.getIdeaSpaces() this.getIdeaSpaces()
this.ideaSpaceCreationDialog = false this.ideaSpaceCreationDialog = false
}) })
} else { } else {
this.newIdeaSpace.slug = this.slug
api.ideaSpace.updateIdeaSpace(this.newIdeaSpace).then(() => { api.ideaSpace.updateIdeaSpace(this.newIdeaSpace).then(() => {
this.getIdeaSpaces() this.getIdeaSpaces()
this.ideaSpaceCreationDialog = false this.ideaSpaceCreationDialog = false
......
...@@ -309,6 +309,7 @@ export default { ...@@ -309,6 +309,7 @@ export default {
'add': 'Klasse hinzufügen' 'add': 'Klasse hinzufügen'
}, },
AdminCommunity: { AdminCommunity: {
'community': 'Schule',
'tableHeaderName': 'Name', 'tableHeaderName': 'Name',
'mainSpaceName': 'Main Ideas space name', 'mainSpaceName': 'Main Ideas space name',
'impressumEdit': 'Impressum bearbeiten' 'impressumEdit': 'Impressum bearbeiten'
......
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