Skip to content

Commit

Permalink
Merge pull request #2351 from hitobito/feature/2329-abo-settings-cleanup
Browse files Browse the repository at this point in the history
fixes #2329
  • Loading branch information
daniel-illi committed Jan 10, 2024
2 parents 26a85bb + 2d597e5 commit c21c83b
Show file tree
Hide file tree
Showing 15 changed files with 266 additions and 128 deletions.
8 changes: 6 additions & 2 deletions app/helpers/format_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ def format_type_attr_method(obj, attr)
############## STANDARD HTML SECTIONS ############################

# Renders an arbitrary content with the given label. Used for uniform presentation.
def labeled(label, content = nil, &block)
def labeled(label, content = nil, tooltip: nil, &block)
content = capture(&block) if block_given?
render 'shared/labeled', label: label, content: content
render 'shared/labeled', label: label, content: content, tooltip: tooltip
end

# Transform the given text into a form as used by labels or table headers.
Expand Down Expand Up @@ -112,6 +112,10 @@ def labeled_attr(obj, attr)
labeled(captionize(attr, object_class(obj)), format_attr(obj, attr))
end

def labeled_attrs(obj, *attrs)
safe_join(attrs.map { |a| labeled_attr(obj, a) })
end

def present_labeled_attr(obj, attr)
labeled_attr(obj, attr) if attr_present?(obj, attr)
end
Expand Down
14 changes: 6 additions & 8 deletions app/helpers/sheet/mailing_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ module Sheet
class MailingList < Base
self.parent_sheet = Sheet::Group

tab 'activerecord.models.message.other',
:group_mailing_list_messages_path,
if: (lambda do |view, _group, mailing_list|
view.can?(:update, mailing_list)
end)

tab 'global.tabs.settings',
tab 'global.tabs.info',
:group_mailing_list_path,
alt: [:edit_group_mailing_list_path]
alt: [:edit_group_mailing_list_path],
if: :show

tab 'activerecord.models.message.other',
:group_mailing_list_messages_path,
if: :update
tab 'activerecord.models.subscription.other',
:group_mailing_list_subscriptions_path,
if: :index_subscriptions,
Expand Down
23 changes: 23 additions & 0 deletions app/helpers/tabs_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# frozen_string_literal: true

# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of
# hitobito and licensed under the Affero General Public License version 3
# or later. See the COPYING file at the top-level directory or at
# https://github.com/hitobito/hitobito.
#
module TabsHelper

def tab_header(label, id, default_active: false)
tab = params[:active_tab]
classes = %w(nav-link)
classes += %w(active) if default_active && tab.blank? || tab == id.to_s
link_to(label, "##{id}", data: { bs_toggle: 'tab' }, class: classes)
end

def tab_content(id, default_active: false, &block)
tab = params[:active_tab]
classes = %w(tab-pane)
classes += %w(active) if default_active && tab.blank? || tab == id.to_s
content_tag(:div, capture(&block), id: id, class: classes)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ class app.MailingListLabels
e.preventDefault()
form = $(this).closest("form")
$(this).closest('.chip').remove()
form.load(window.location.href + '.js', form.serialize())
@updateForm()

update: (e)=>
label = $("#{@selector} input[name=label]")
label.attr('name', 'mailing_list[preferred_labels][]')
@updateForm()

updateForm: (e) =>
form = $("#{@selector}")
form.load(window.location.href + '.js', form.serialize())
id = $('.tab-pane.active')[0].id
form.load(window.location.href + '.js', form.serialize() + "&active_tab=#{id}")

preventEnterSubmit: (event) =>
if event.keyCode == 13
Expand Down
2 changes: 0 additions & 2 deletions app/views/mailing_lists/_actions_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
= button_action_edit if can?(:edit, entry)
= button_action_destroy if can?(:destroy, entry)
= button_toggle_subscription
- if can?(:create_invoices_from_list, entry.group)
= invoice_button(mailing_list: Draper.undecorate(entry))
34 changes: 18 additions & 16 deletions app/views/mailing_lists/_attrs.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@
-# https://github.com/hitobito/hitobito.
#main.row-fluid
%article
= format_attr(entry, :description)
= render_attrs(entry, :mail_address_link, :publisher)
- if can?(:edit, entry)
= render_attrs(entry, :mailchimp_api_key,
:mailchimp_list_id,
:mailchimp_include_additional_emails)
- if entry.mailchimp? && entry.mailchimp_result
= render_attrs(entry, :mailchimp_sync)
= render_attrs(entry, :additional_sender)
%dl.dl-horizontal.m-0.p-2.border-top
= labeled_attrs(entry, :description, :publisher)
= labeled(nil, entry.subscribable_info) if entry.subscribable_info.present?

- if entry.mail_address.present?
%h2.pt-2= t('mailing_lists.form_tabs.email')
%dl.dl-horizontal.m-0.p-2.border-top
= labeled_attrs(entry, :mail_address_link)
= labeled(nil, entry.subscribers_may_post_info) if entry.subscribers_may_post_info.present?
= labeled(nil, entry.anyone_may_post_info) if entry.anyone_may_post_info.present?
= labeled(nil, entry.delivery_report_info) if entry.delivery_report_info.present?
= labeled_attrs(entry, :additional_sender, :main_email, :preferred_labels)

= render_attrs(entry, :main_email, :preferred_labels)
= render_extensions :attrs
- if can?(:edit, entry)
%h2.pt-2= t('mailing_lists.form_tabs.mailchimp')
%dl.dl-horizontal.m-0.p-2.border-top
= labeled_attrs(entry, :mailchimp_list_id, :mailchimp_include_additional_emails)
- if entry.mailchimp? && entry.mailchimp_result
= labeled_attrs(entry, :mailchimp_sync)

= entry.subscribable_info
= entry.subscribers_may_post_info
= entry.anyone_may_post_info
= entry.delivery_report_info
= render_extensions :attrs
110 changes: 57 additions & 53 deletions app/views/mailing_lists/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,60 @@
-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito.
= entry_form(data: { mailing_list_labels: true }, html: { class: 'form-striped'}) do |f|
%fieldset
= f.labeled_input_fields(:name, :description, :publisher)

= f.labeled(:mail_name, class: 'd-flex') do
.col-4
.input-group.input-group-sm
= f.input_field(:mail_name)
%span.input-group-text= "@#{entry.mail_domain}"

= f.labeled_input_field(:additional_sender, help: t('.help_additional_sender'), placeholder: "hans.muster@pfadi-beispiel.ch; *@pfadi-muster.ch")

%fieldset
= f.labeled(:preferred_labels) do
%div
= link_to '#', class: 'chip chip-add' do
= ti('associations.add')
= icon(:plus)
= text_field_tag(:label, nil, style: 'display: none', class: 'form-control form-control-sm mw-100 mw-md-60ch mb-1', data: { provide: :typeahead, source: @labels })

= hidden_field_tag('mailing_list[preferred_labels][]')

%div
- @preferred_labels.each do |label|
%span.chip
= label
= link_to(icon(:times), '#')
= hidden_field_tag('mailing_list[preferred_labels][]', label)

%span.form-text= t('.help_preferred_labels')

= f.indented do
- if entry.preferred_labels.present?
= f.boolean_field(:main_email, caption: t('.caption_main_email_with_preferred_labels').html_safe)
- else
= f.boolean_field(:main_email, caption: t('.caption_main_email').html_safe)

%fieldset
= f.labeled_input_fields(:mailchimp_list_id, help: t('.help_mailchimp_sync'))
= f.labeled_input_fields(:mailchimp_api_key)
= f.labeled_boolean_field(:mailchimp_include_additional_emails)

%fieldset
= f.indented do
= f.boolean_field(:subscribable, caption: t('.caption_subscribable'))
= f.indented do
= f.boolean_field(:subscribers_may_post, caption: t('.caption_subscribers_may_post'))
= f.indented do
= f.boolean_field(:anyone_may_post, caption: t('.caption_anyone_may_post'))
= f.indented do
= f.boolean_field(:delivery_report, caption: t('.caption_delivery_report'))

= render_extensions :fields, locals: { f: f }
= entry_form(data: { mailing_list_labels: true }, html: { class: 'form-striped'}, buttons_top: false) do |f|
= render 'form_tabs'

.tab-content
= tab_content(:general, default_active: true) do
%fieldset
= f.labeled_input_fields(:name, :description, :publisher)
= f.indented do
= f.boolean_field(:subscribable, caption: t('.caption_subscribable'))

= tab_content(:email) do
%fieldset
= f.labeled(:mail_name, class: 'd-flex') do
.col-4
.input-group.input-group-sm
= f.input_field(:mail_name)
%span.input-group-text= "@#{entry.mail_domain}"

= f.labeled_input_field(:additional_sender, help: t('.help_additional_sender'), placeholder: "hans.muster@pfadi-beispiel.ch; *@pfadi-muster.ch")

%fieldset
= f.labeled(:preferred_labels) do
%div
= link_to '#', class: 'chip chip-add' do
= ti('associations.add')
= icon(:plus)
= text_field_tag(:label, nil, style: 'display: none', class: 'form-control form-control-sm mw-100 mw-md-60ch mb-1', data: { provide: :typeahead, source: @labels })

= hidden_field_tag('mailing_list[preferred_labels][]')

%div
- @preferred_labels.each do |label|
%span.chip
= label
= link_to(icon(:times), '#')
= hidden_field_tag('mailing_list[preferred_labels][]', label)

%span.form-text= t('.help_preferred_labels')

= f.indented do
- if entry.preferred_labels.present?
= f.boolean_field(:main_email, caption: t('.caption_main_email_with_preferred_labels').html_safe)
- else
= f.boolean_field(:main_email, caption: t('.caption_main_email').html_safe)

%fieldset
= f.indented do
= f.boolean_field(:subscribers_may_post, caption: t('.caption_subscribers_may_post'))
= f.indented do
= f.boolean_field(:anyone_may_post, caption: t('.caption_anyone_may_post'))
= f.indented do
= f.boolean_field(:delivery_report, caption: t('.caption_delivery_report'))
= tab_content(:mailchimp) do
%fieldset
= f.labeled_input_fields(:mailchimp_list_id, help: t('.help_mailchimp_sync'))
= f.labeled_input_fields(:mailchimp_api_key)
= f.labeled_boolean_field(:mailchimp_include_additional_emails)
11 changes: 11 additions & 0 deletions app/views/mailing_lists/_form_tabs.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-# Copyright (c) 2023, Schweizer Alpen-Club. This file is part of
-# hitobito and licensed under the Affero General Public License version 3
-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito
%ul.nav.nav-tabs
%li.nav-item= tab_header(t('mailing_lists.form_tabs.general'), :general, default_active: true)
%li.nav-item= tab_header(t('mailing_lists.form_tabs.email'), :email)
%li.nav-item= tab_header(t('mailing_lists.form_tabs.mailchimp'), :mailchimp)

= render_extensions :form_tabs
5 changes: 4 additions & 1 deletion app/views/shared/_labeled.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
-# or later. See the COPYING file at the top-level directory or at
-# https://github.com/hitobito/hitobito.
%dt.muted.float-start.text-end= label.presence || raw(FormatHelper::EMPTY_STRING)
- if local_assigns[:tooltip].present?
%dt.muted.float-start.text-end{title: tooltip}= label.presence || raw(FormatHelper::EMPTY_STRING)
- else
%dt.muted.float-start.text-end= label.presence || raw(FormatHelper::EMPTY_STRING)
%dd.mb-2= content.presence || raw(FormatHelper::EMPTY_STRING)
3 changes: 3 additions & 0 deletions app/views/subscriptions/_actions_index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@

- if can?(:export_subscriptions, @mailing_list)
= dropdown_subscriptions_export

- if can?(:create_invoices_from_list, @mailing_list.group)
= invoice_button(mailing_list: Draper.undecorate(parent))
75 changes: 39 additions & 36 deletions config/locales/views.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -991,40 +991,6 @@ de:
flash:
success: Zahlung über %{amount} wurde erfasst.

payment_processes:
description:
header: camt.054 XML Datei
explain_xml_format: 'Eine camt.054 XML Datei ist die Sammelbuchungs-auflösung und Belastungs- und Gutschriftsanzeige.
Diese enthält eine Reihe verschiedene Buchungspositionen welche automatisiert auf Basis der ESR Nummer bestehenden
Rechnungen zugeordnet werden.'

invalid_file: Die hochgeladene Datei ist nicht gültig.
parsing_error: Die hochgeladene kann nicht verarbeitet werden (%{error}).
created: Es wurden %{count} Zahlungen erfasst.
payments:
valid:
one: Es wurde eine gültige Zahlung erkannt.
other: Es wurden %{count} gültige Zahlungen erkannt.
invalid:
one: Es wurde eine ungültige Zahlung erkannt.
other: Es wurden %{count} ungültige Zahlungen erkannt.
show:
payments_with_invoice: Zuordenbare Zahlungen
payments_with_invoice_and_dates: Zuordenbare Zahlungen vom %{from} bis %{to}
payments_without_invoice: Nicht Zuordenbar
amount_open: Offen
create:
zero: Zahlung importieren
one: Zahlung importieren
other: '%{count} Zahlungen importieren'
icon_tooltip_invoice_missing: Kann keiner Rechnung zugeordnet werden
icon_tooltip_settles: Begleicht die offene Rechnung
icon_tooltip_exceeds: Übersteigt die offene Rechnung um %{difference}
icon_tooltip_undercuts: Unterschreitet die offene Rechnung um %{difference}
new:
upload_button: 'Hochladen'
xml_file: 'XML Datei'

label_formats:
global_labels: "Globale Etikettenformate"
own_labels: Meine Etikettenformate
Expand Down Expand Up @@ -1084,6 +1050,10 @@ de:
caption_delivery_report: 'E-Mail mit Bestätigung an Absender schicken'
help_preferred_labels: 'E-Mails werden falls vorhanden, nur an E-Mailadressen mit dieser Bezeichnung verschickt. Dabei werden auch E-Mail Adressen verwendet, die nicht als Versand-Adresse markiert sind.'
help_mailchimp_sync: 'Abonnenten können an die MailChimp-Liste exportiert werden. Diese Aktion überschreibt die MailChimp-Liste und bestehende Kontakte werden gelöscht.'
form_tabs:
general: Allgemein
email: Mailing-Liste (E-Mail)
mailchimp: MailChimp
imap_mails:
manage: Mails
mailboxes:
Expand Down Expand Up @@ -1281,6 +1251,39 @@ de:
grants: Autorisierungen
tokens: Zugangstoken

payment_processes:
description:
header: camt.054 XML Datei
explain_xml_format: 'Eine camt.054 XML Datei ist die Sammelbuchungs-auflösung und Belastungs- und Gutschriftsanzeige.
Diese enthält eine Reihe verschiedene Buchungspositionen welche automatisiert auf Basis der ESR Nummer bestehenden
Rechnungen zugeordnet werden.'

invalid_file: Die hochgeladene Datei ist nicht gültig.
parsing_error: Die hochgeladene kann nicht verarbeitet werden (%{error}).
created: Es wurden %{count} Zahlungen erfasst.
payments:
valid:
one: Es wurde eine gültige Zahlung erkannt.
other: Es wurden %{count} gültige Zahlungen erkannt.
invalid:
one: Es wurde eine ungültige Zahlung erkannt.
other: Es wurden %{count} ungültige Zahlungen erkannt.
show:
payments_with_invoice: Zuordenbare Zahlungen
payments_with_invoice_and_dates: Zuordenbare Zahlungen vom %{from} bis %{to}
payments_without_invoice: Nicht Zuordenbar
amount_open: Offen
create:
zero: Zahlung importieren
one: Zahlung importieren
other: '%{count} Zahlungen importieren'
icon_tooltip_invoice_missing: Kann keiner Rechnung zugeordnet werden
icon_tooltip_settles: Begleicht die offene Rechnung
icon_tooltip_exceeds: Übersteigt die offene Rechnung um %{difference}
icon_tooltip_undercuts: Unterschreitet die offene Rechnung um %{difference}
new:
upload_button: 'Hochladen'
xml_file: 'XML Datei'

qualifications:
in_years: '%{years} Jahre'
Expand Down Expand Up @@ -1700,9 +1703,9 @@ de:
greater: grösser als
smaller: kleiner als

language:
language:
title: Sprache
word_connector: ' oder '
word_connector: ' oder '
one_of: Sprache ist %{languages}

tag:
Expand Down

0 comments on commit c21c83b

Please sign in to comment.