improve announcement management

This commit is contained in:
les 2021-05-31 00:08:13 +02:00
parent 54c5d2aa41
commit 91311b49ef
No known key found for this signature in database
GPG key ID: 352918250B012177
8 changed files with 36 additions and 55 deletions

View file

@ -10,11 +10,6 @@ export default {
props: { props: {
announcement: { type: Object, default: () => ({}) } announcement: { type: Object, default: () => ({}) }
}, },
computed: { computed: mapState(['announcements'])
...mapState(['announcements']),
description () {
return this.announcement.announcement.replace(/(<br>)+/g, '<br>')
}
}
} }
</script> </script>

View file

@ -6,14 +6,16 @@
v-card v-card
v-card-title {{$t('admin.new_announcement')}} v-card-title {{$t('admin.new_announcement')}}
v-card-text.px-0 v-card-text.px-0
v-form(v-model='valid' ref='announcement' @submit.prevent='save') v-form(v-model='valid' ref='announcement' @submit.prevent='save' lazy-validation)
v-text-field.col-12(v-model='announcement.title' :label='$t("common.title")') v-text-field.col-12(v-model='announcement.title'
:rules="[$validators.required('common.title')]"
:label='$t("common.title")')
Editor.col-12(v-model='announcement.announcement' Editor.col-12(v-model='announcement.announcement'
border no-save max-height='400px' :placeholder="$t('common.description')") border no-save max-height='400px' :placeholder="$t('common.description')")
v-card-actions v-card-actions
v-spacer v-spacer
v-btn(@click='dialog=false' color='error') {{$t('common.cancel')}} v-btn(@click='dialog=false' color='error') {{$t('common.cancel')}}
v-btn(@click='save' color='primary' :disabled='loading' :loading='loading') {{$t(`common.${editing?'save':'send'}`)}} v-btn(@click='save' color='primary' :disabled='!valid || loading' :loading='loading') {{$t(`common.${editing?'save':'send'}`)}}
v-btn(@click='openDialog' text color='primary') <v-icon>mdi-plus</v-icon> {{$t('common.add')}} v-btn(@click='openDialog' text color='primary') <v-icon>mdi-plus</v-icon> {{$t('common.add')}}
v-card-text v-card-text
@ -86,6 +88,7 @@ export default {
}) })
}, },
async save () { async save () {
if (!this.$refs.announcement.validate()) { return }
this.loading = true this.loading = true
try { try {
let announcement = null let announcement = null

View file

@ -55,7 +55,7 @@
v-btn(color='error' @click='dialogAddInstance=false') {{$t('common.cancel')}} v-btn(color='error' @click='dialogAddInstance=false') {{$t('common.cancel')}}
v-btn(color='primary' :disabled='!valid' @click='createTrustedInstance') {{$t('common.ok')}} v-btn(color='primary' :disabled='!valid' @click='createTrustedInstance') {{$t('common.ok')}}
v-btn.mt-4(@click='dialogAddInstance = true' color='primary' text) <v-icon>mdi-plus</v-icon> Add instance v-btn.mt-4(@click='dialogAddInstance = true' color='primary' text) <v-icon>mdi-plus</v-icon> {{$t('admin.add_instance')}}
v-data-table( v-data-table(
v-if='settings.trusted_instances.length' v-if='settings.trusted_instances.length'
:hide-default-footer='settings.trusted_instances.length<10' :hide-default-footer='settings.trusted_instances.length<10'

View file

@ -172,6 +172,7 @@
"federation": "Federation / ActivityPub", "federation": "Federation / ActivityPub",
"enable_federation": "Turn on federation", "enable_federation": "Turn on federation",
"enable_federation_help": "It will be possible to follow this instance from the fediverse", "enable_federation_help": "It will be possible to follow this instance from the fediverse",
"add_instance": "Add instance",
"select_instance_timezone": "Time zone", "select_instance_timezone": "Time zone",
"enable_resources": "Turn on resources", "enable_resources": "Turn on resources",
"enable_resources_help": "Allows adding resources to the event from the fediverse", "enable_resources_help": "Allows adding resources to the event from the fediverse",

View file

@ -176,6 +176,7 @@
"federation": "Federazione / ActivityPub", "federation": "Federazione / ActivityPub",
"enable_federation": "Abilita la federazione", "enable_federation": "Abilita la federazione",
"enable_federation_help": "Sarà possibile seguire questa istanza dal fediverso", "enable_federation_help": "Sarà possibile seguire questa istanza dal fediverso",
"add_instance": "Aggiungi istanza",
"select_instance_timezone": "Fuso orario", "select_instance_timezone": "Fuso orario",
"instance_timezone_description": "Gancio è pensato per raccogliere gli eventi di un luogo specifico come ad esempio una città. Scrivendo e selezionando il fuso orario di questo luogo, tutti gli orari saranno mostrati e inseriti secondo quanto scelto.", "instance_timezone_description": "Gancio è pensato per raccogliere gli eventi di un luogo specifico come ad esempio una città. Scrivendo e selezionando il fuso orario di questo luogo, tutti gli orari saranno mostrati e inseriti secondo quanto scelto.",
"enable_resources": "Abilita risorse", "enable_resources": "Abilita risorse",

View file

@ -14,6 +14,9 @@ export default {
try { try {
const id = Number(params.id) const id = Number(params.id)
const announcement = store.state.announcements.find(a => a.id === id) const announcement = store.state.announcements.find(a => a.id === id)
if (!announcement) {
error({ statusCode: 404, message: 'Announcement not found' })
}
return { announcement } return { announcement }
} catch (e) { } catch (e) {
error({ statusCode: 404, message: 'Announcement not found' }) error({ statusCode: 404, message: 'Announcement not found' })
@ -22,50 +25,14 @@ export default {
data () { data () {
return { announcement: { title: '' } } return { announcement: { title: '' } }
}, },
computed: mapState(['announcements']), head () {
methods: { if (!this.announcement) {
showResource (resource) { return {}
this.showResources = true
this.selectedResource = resource
document.getElementById('resourceDialog').focus()
} }
} return {
title: `${this.settings.title} - ${this.announcement.title}`
}
},
computed: mapState(['announcements', 'settings'])
} }
</script> </script>
<style lang='less'>
// .announcement-page {
// .el-header {
// height: auto !important;
// padding-top: 1em;
// border-bottom: 1px solid lightgray;
// }
// .title {
// max-width: 80%;
// max-height: 0.1rem;
// overflow: hidden;
// font-size: 1.6rem;
// line-height: 1;
// padding-right: 40px;
// }
// pre {
// white-space: pre-line;
// word-break: break-word;
// color: #aaa;
// font-size: 1.2em;
// font-family: inherit;
// }
// }
// @media only screen and (max-width: 768px) {
// #eventDetail {
// .title {
// font-size: 1em;
// font-weight: bold;
// }
// }
// }
</style>

View file

@ -2,7 +2,7 @@
v-container#home(fluid) v-container#home(fluid)
//- Announcements //- Announcements
#announcements.mr-1 #announcements.mx-1.mt-1(v-if='announcements.length')
Announcement(v-for='announcement in announcements' :key='`a_${announcement.id}`' :announcement='announcement') Announcement(v-for='announcement in announcements' :key='`a_${announcement.id}`' :announcement='announcement')
//- Calendar and search bar //- Calendar and search bar

View file

@ -0,0 +1,14 @@
module.exports = {
up: (queryInterface, Sequelize) => {
return queryInterface.changeColumn('announcements', 'announcement', {
type: Sequelize.TEXT
})
},
down: (queryInterface, Sequelize) => {
return queryInterface.changeColumn('announcements', 'announcement', {
type: Sequelize.STRING
})
}
}