diff --git a/components/Announcement.vue b/components/Announcement.vue index 62a14fa0..1eb45080 100644 --- a/components/Announcement.vue +++ b/components/Announcement.vue @@ -10,11 +10,6 @@ export default { props: { announcement: { type: Object, default: () => ({}) } }, - computed: { - ...mapState(['announcements']), - description () { - return this.announcement.announcement.replace(/(
)+/g, '
') - } - } + computed: mapState(['announcements']) } diff --git a/components/admin/Announcement.vue b/components/admin/Announcement.vue index 1ca0cf38..5edba461 100644 --- a/components/admin/Announcement.vue +++ b/components/admin/Announcement.vue @@ -6,14 +6,16 @@ v-card v-card-title {{$t('admin.new_announcement')}} v-card-text.px-0 - v-form(v-model='valid' ref='announcement' @submit.prevent='save') - v-text-field.col-12(v-model='announcement.title' :label='$t("common.title")') + v-form(v-model='valid' ref='announcement' @submit.prevent='save' lazy-validation) + 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' border no-save max-height='400px' :placeholder="$t('common.description')") v-card-actions v-spacer 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') mdi-plus {{$t('common.add')}} v-card-text @@ -86,6 +88,7 @@ export default { }) }, async save () { + if (!this.$refs.announcement.validate()) { return } this.loading = true try { let announcement = null diff --git a/components/admin/Federation.vue b/components/admin/Federation.vue index aa21a10e..c5311c63 100644 --- a/components/admin/Federation.vue +++ b/components/admin/Federation.vue @@ -55,7 +55,7 @@ v-btn(color='error' @click='dialogAddInstance=false') {{$t('common.cancel')}} v-btn(color='primary' :disabled='!valid' @click='createTrustedInstance') {{$t('common.ok')}} - v-btn.mt-4(@click='dialogAddInstance = true' color='primary' text) mdi-plus Add instance + v-btn.mt-4(@click='dialogAddInstance = true' color='primary' text) mdi-plus {{$t('admin.add_instance')}} v-data-table( v-if='settings.trusted_instances.length' :hide-default-footer='settings.trusted_instances.length<10' diff --git a/locales/en.json b/locales/en.json index 96b49c13..ed28218d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -172,6 +172,7 @@ "federation": "Federation / ActivityPub", "enable_federation": "Turn on federation", "enable_federation_help": "It will be possible to follow this instance from the fediverse", + "add_instance": "Add instance", "select_instance_timezone": "Time zone", "enable_resources": "Turn on resources", "enable_resources_help": "Allows adding resources to the event from the fediverse", diff --git a/locales/it.json b/locales/it.json index 72ca2ab5..a8396c01 100644 --- a/locales/it.json +++ b/locales/it.json @@ -176,6 +176,7 @@ "federation": "Federazione / ActivityPub", "enable_federation": "Abilita la federazione", "enable_federation_help": "Sarà possibile seguire questa istanza dal fediverso", + "add_instance": "Aggiungi istanza", "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.", "enable_resources": "Abilita risorse", diff --git a/pages/announcement/_id.vue b/pages/announcement/_id.vue index 33c2ed09..27022ea3 100644 --- a/pages/announcement/_id.vue +++ b/pages/announcement/_id.vue @@ -14,6 +14,9 @@ export default { try { const id = Number(params.id) const announcement = store.state.announcements.find(a => a.id === id) + if (!announcement) { + error({ statusCode: 404, message: 'Announcement not found' }) + } return { announcement } } catch (e) { error({ statusCode: 404, message: 'Announcement not found' }) @@ -22,50 +25,14 @@ export default { data () { return { announcement: { title: '' } } }, - computed: mapState(['announcements']), - methods: { - showResource (resource) { - this.showResources = true - this.selectedResource = resource - document.getElementById('resourceDialog').focus() + head () { + if (!this.announcement) { + return {} } - } + return { + title: `${this.settings.title} - ${this.announcement.title}` + } + }, + computed: mapState(['announcements', 'settings']) } - diff --git a/pages/index.vue b/pages/index.vue index 54ae87ac..07af17a8 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -2,7 +2,7 @@ v-container#home(fluid) //- 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') //- Calendar and search bar diff --git a/server/migrations/20210530211850-announcement_description.js b/server/migrations/20210530211850-announcement_description.js new file mode 100644 index 00000000..762f1db2 --- /dev/null +++ b/server/migrations/20210530211850-announcement_description.js @@ -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 + }) + } +}