Commit 136e3681 authored by Edgar Z. Alvarenga's avatar Edgar Z. Alvarenga

Add component for simple html pages administration

parent fe45f921
......@@ -15951,6 +15951,11 @@
"is-plain-obj": "1.1.0"
}
},
"sortablejs": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.8.2.tgz",
"integrity": "sha512-Opa3q1nVMBM/XVrh9pCDh/BJFYCNuoFLLzT4FOVzgXocGrb4QpC/u0E4WVpUoIfhUfMSvP6c5SA5nK22vPqbFA=="
},
"source-list-map": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.0.tgz",
......@@ -17350,6 +17355,14 @@
"resolved": "https://registry.npmjs.org/vue-router/-/vue-router-3.0.1.tgz",
"integrity": "sha512-vLLoY452L+JBpALMP5UHum9+7nzR9PeIBCghU9ZtJ1eWm6ieUI8Zb/DI3MYxH32bxkjzYV1LRjNv4qr8d+uX/w=="
},
"vue-sortable": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/vue-sortable/-/vue-sortable-0.1.3.tgz",
"integrity": "sha1-N7iJ4vLVTGFI1dG5WIBsZwQiHrk=",
"requires": {
"sortablejs": "1.8.2"
}
},
"vue-style-loader": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/vue-style-loader/-/vue-style-loader-4.1.0.tgz",
......
......@@ -12,6 +12,21 @@ function getConfig (schoolId) {
return service.post('/rpc/config', {'space_id': schoolId})
}
function addPage (newPage) {
const config = {
headers: {
PREFER: 'return=representation'
}
}
return service.post('/page', newPage, config)
}
function deletePage (pageId) {
const params = { id: 'eq.' + pageId }
return service.delete('/page', { params })
}
function getPages (schoolId) {
const params = {
school_id: 'eq.' + schoolId
......@@ -53,6 +68,8 @@ export default {
getConfig,
updateConfig,
getPage,
addPage,
deletePage,
getPages,
updatePage
}
......@@ -10,7 +10,31 @@
class="elevation-1"
>
<template slot="items" slot-scope="props">
<td @click="openEditPage(props.item.name)" >{{ props.item.name }}</td>
<td >{{ props.item.name }}</td>
<td>
<v-checkbox
v-model="props.item.public"
@change="updatePublic(props.item)"
label="is Public"
></v-checkbox>
</td>
<td class="justify-center layout px-0">
<v-icon
small
class="mr-2"
@click="openEditPage(props.item.name)"
>
edit
</v-icon>
<v-icon
small
class="mr-2"
@click="pageToDelete = props.item ; confirmDeletePageDialog = true"
>
delete
</v-icon>
</td>
</template>
</v-data-table>
</v-card-text>
......@@ -18,15 +42,49 @@
</v-flex>
<v-flex d-flex xs12 sm12 pa-2>
<v-btn
@click="openPageEditor"
@click="addPageDialog = true"
>
{{ $vuetify.t('$vuetify.AdminIdeaSpace.add') }}
{{ $vuetify.t('$vuetify.AdminPages.add') }}
</v-btn>
</v-flex>
</v-layout>
<v-dialog v-model="openPageEditor" v-if="pageName !== ''">
<PageEditor :pageName="pageName" @close-page-editor="openPageEditor = false"/>
</v-dialog>
<v-dialog v-model="confirmDeletePageDialog" width="300">
<v-card>
<v-card-text>
<v-alert type="error" :value="true">{{ $vuetify.t('$vuetify.AdminPages.confirmDelete', pageToDelete ? pageToDelete.name : '') }}</v-alert>
<v-btn @click="deletePage" color="error">
{{ $vuetify.t('$vuetify.Form.delete') }}
</v-btn>
<v-btn
@click="confirmDeletePageDialog = false"
>
{{ $vuetify.t('$vuetify.Form.cancel') }}
</v-btn>
</v-card-text>
</v-card>
</v-dialog>
<v-dialog v-model="addPageDialog" width="400">
<v-card>
<v-card-text>
<v-text-field
name="pageName"
:label="$vuetify.t('$vuetify.AdminPages.pageName')"
v-model="newPage.name">
</v-text-field>
<v-btn @click="addPage" color="primary">
{{ $vuetify.t('$vuetify.AdminPages.add') }}
</v-btn>
<v-btn
@click="addPageDialog = false"
>
{{ $vuetify.t('$vuetify.Form.cancel') }}
</v-btn>
</v-card-text>
</v-card>
</v-dialog>
</v-container>
</template>
......@@ -40,13 +98,24 @@ export default {
components: { PageEditor },
data: function () {
return {
addPageDialog: false,
confirmDeletePageDialog: false,
newPage: {name: ''},
pageToDelete: null,
headers: [
{
text: this.$vuetify.t('$vuetify.AdminPages.pageName'),
align: 'left',
sortable: true,
value: 'name'
}
},
{
text: 'Public',
align: 'left',
sortable: false,
value: 'public'
},
{ text: 'Actions', value: 'name', sortable: false }
],
pages: [],
pageName: '',
......@@ -65,11 +134,31 @@ export default {
},
methods: {
deletePage: function () {
const pageId = this.pageToDelete.id
api.school.deletePage(pageId).then(res => {
this.pages = this.pages.filter(p => p.id !== pageId)
this.confirmDeletePageDialog = false
})
},
addPage: function () {
this.newPage.created_by = this.$store.getters.user.profile.id
this.newPage.school_id = this.$store.getters.selected_school
this.newPage.content = ''
api.school.addPage(this.newPage).then(res => {
this.pages.push(res.data[0])
this.addPageDialog = false
})
},
openEditPage: function (pageName) {
this.pageName = pageName
this.openPageEditor = true
},
updatePublic: function (page) {
console.log(page.id, page.public)
},
getPages: function () {
api.school.getPages(this.$store.getters.selected_school).then(response => {
this.pages = response.data
......
......@@ -375,7 +375,9 @@ export default {
'csvClose': 'Schließen'
},
AdminPages: {
pageName: 'Page name'
pageName: 'Page name',
confirmDelete: '"{0}" wirklich löschen?',
add: 'Page hinzufügen'
},
AdminPassList: {
title: 'Passwortliste',
......
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