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

Automatic slug creation for Idea Spaces

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