From df2c3dd661ef13cbbc8a5463a98b1c37cec050b7 Mon Sep 17 00:00:00 2001 From: Felix Wolfsteller Date: Fri, 9 Oct 2020 17:09:30 +0200 Subject: [PATCH] use partial for 'new' forms, i18n (#31) --- app/controllers/admin/places_controller.rb | 2 +- .../admin/site_settings_controller.rb | 2 ++ app/views/admin/courses/new.html.haml | 10 ++++------ app/views/admin/places/new.html.haml | 10 ++++------ app/views/admin/shared/_new.html.haml | 17 +++++++++++++++++ app/views/admin/styles/new.html.haml | 9 ++++----- config/locales/admin.de.yml | 10 ++++++++++ config/locales/de.yml | 2 -- config/locales/models.de.yml | 12 +++++++++++- 9 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 app/views/admin/shared/_new.html.haml diff --git a/app/controllers/admin/places_controller.rb b/app/controllers/admin/places_controller.rb index 4bc4cb6..df3a136 100644 --- a/app/controllers/admin/places_controller.rb +++ b/app/controllers/admin/places_controller.rb @@ -43,7 +43,7 @@ def create def update respond_to do |format| if @place.update(place_params) - format.html { redirect_to [:admin, @place], notice: t('place.update-success') } + format.html { redirect_to admin_places_path, notice: t('place.update-success') } else format.html { render :edit } end diff --git a/app/controllers/admin/site_settings_controller.rb b/app/controllers/admin/site_settings_controller.rb index 2d228de..c0d2955 100644 --- a/app/controllers/admin/site_settings_controller.rb +++ b/app/controllers/admin/site_settings_controller.rb @@ -137,6 +137,8 @@ def find_or_create_image_site_settings value: t("site_settings.#{key.to_s}.default"), kind: 'image') end + # i18n-tasks-use t('site_settings.blog_background.help') + # i18n-tasks-use t('site_settings.favicon-png.help') # i18n-tasks-use t('site_settings.favicon-apple-touch.help') # i18n-tasks-use t('site_settings.favicon-png.help') # i18n-tasks-use t('site_settings.favicon.help') diff --git a/app/views/admin/courses/new.html.haml b/app/views/admin/courses/new.html.haml index f6a5998..a01dd85 100644 --- a/app/views/admin/courses/new.html.haml +++ b/app/views/admin/courses/new.html.haml @@ -2,9 +2,7 @@ -# -# SPDX-License-Identifier: AGPL-3.0-or-later -%h1.title - = t('New course') - -= render 'form' - -= link_to 'Back', admin_courses_path += render layout: 'admin/shared/new', + locals: { new_title: t('admin.courses.new'), + back_target: admin_courses_path } do + = render 'form' diff --git a/app/views/admin/places/new.html.haml b/app/views/admin/places/new.html.haml index 9125eed..285a2c2 100644 --- a/app/views/admin/places/new.html.haml +++ b/app/views/admin/places/new.html.haml @@ -2,9 +2,7 @@ -# -# SPDX-License-Identifier: AGPL-3.0-or-later -%h1.title - = t('New place') - -= render 'form' - -= link_to t('Back'), admin_places_path += render layout: 'admin/shared/new', + locals: { new_title: t('admin.places.new'), + back_target: admin_places_path } do + = render 'form' diff --git a/app/views/admin/shared/_new.html.haml b/app/views/admin/shared/_new.html.haml new file mode 100644 index 0000000..2f74463 --- /dev/null +++ b/app/views/admin/shared/_new.html.haml @@ -0,0 +1,17 @@ +-# SPDX-FileCopyrightText: 2020 Felix Wolfsteller +-# +-# SPDX-License-Identifier: AGPL-3.0-or-later + +%h1.title + = new_title + += yield + +.backmatter.is-clearfix.has-clearfix + %hr.has-clearfix.is-clearfix + + = link_to back_target, class: 'has-text-danger' do + %span.icon + %i.fa.fa-arrow-left + = t('actions.Back') + diff --git a/app/views/admin/styles/new.html.haml b/app/views/admin/styles/new.html.haml index 10c83cf..daafbc8 100644 --- a/app/views/admin/styles/new.html.haml +++ b/app/views/admin/styles/new.html.haml @@ -2,8 +2,7 @@ -# -# SPDX-License-Identifier: AGPL-3.0-or-later -%h1.title New course - -= render 'form' - -= link_to 'Back', courses_path += render layout: 'admin/shared/new', + locals: { new_title: t('admin.styles.new'), + back_target: admin_styles_path } do + = render 'form' diff --git a/config/locales/admin.de.yml b/config/locales/admin.de.yml index 12482fd..0cf52e0 100644 --- a/config/locales/admin.de.yml +++ b/config/locales/admin.de.yml @@ -11,8 +11,14 @@ de: creation_success: Blog Post erstellt. deletion_success: Post gelöscht. update_success: Post aktualisiert. + courses: + edit: Kurs bearbeiten + new: Neuer Kurs places: add_course: Kurs hinzufügen + all: Alle Orte + edit: Ort bearbeiten + new: Neuer Ort site_settings: index: listing: Alle Seiten-Einstellungen @@ -20,4 +26,8 @@ de: key: Einstellung value: Wert styles: + edit: Style bearbeiten + index: + listing: Alle Styles + new: Neuer Style new-video: Neues Video diff --git a/config/locales/de.yml b/config/locales/de.yml index a77ead2..4704e70 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -28,7 +28,6 @@ de: cannot-delete-with-videos: Termin kann nicht gelöscht werden (hat noch Videos). creation-succes: Kurs erstellt. deletion-success: Kurs gelöscht. - edit: Bearbeiten name: Name number_courses: Anzahl Kurse number_lessons: Anzahl Videos @@ -122,7 +121,6 @@ de: apointments: time: till: bis - are_you_sure?: Bist du dir sicher? attendence: Attendence blog: title: Blog diff --git a/config/locales/models.de.yml b/config/locales/models.de.yml index 1b7c651..8635afb 100644 --- a/config/locales/models.de.yml +++ b/config/locales/models.de.yml @@ -24,7 +24,17 @@ de: content: Inhalt image: Bild published_at: Veröffentlichung - Active: aktiv + active: aktiv + course: + dayofweek: Wochentag + description: Beschreibung + name: Name + note: Notiz + place: Ort + start_time: Anfangszeit + style: Style + end_time: Endzeit + active: Aktiv lesson: date_end: End-Zeit date_start: Start-Zeit