Skip to content

Commit

Permalink
Info page, support custom title
Browse files Browse the repository at this point in the history
This patch adds the ability to set a custom title for the member info
page.
  • Loading branch information
thibaudgg committed Nov 12, 2023
1 parent 9175ecf commit 7cabc71
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 16 deletions.
5 changes: 5 additions & 0 deletions app/admin/acp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
*I18n.available_locales.map { |l| "basket_price_extra_label_#{l}" },
*I18n.available_locales.map { |l| "basket_price_extra_label_detail_#{l}" },
*I18n.available_locales.map { |l| "membership_update_text_#{l}" },
*I18n.available_locales.map { |l| "member_information_title_#{l}" },
*I18n.available_locales.map { |l| "member_information_text_#{l}" },
*I18n.available_locales.map { |l| "new_member_fee_description_#{l}" },
billing_year_divisions: [],
Expand Down Expand Up @@ -204,6 +205,10 @@
required: false,
as: :action_text,
input_html: { class: 'long-text' })
translated_input(f, :member_information_titles,
hint: t('formtastic.hints.acp.member_information_title'),
required: false,
input_html: { placeholder: t('members.information.default_title') })
end
end
tab Membership.model_name.human, id: 'membership' do
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/members_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,8 @@ def member_features_sentence
features << t('.features.billing_text')
features.to_sentence
end

def member_information_title
Current.acp.member_information_title.presence || t('members.information.default_title')
end
end
1 change: 1 addition & 0 deletions app/models/acp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class ACP < ApplicationRecord
translated_rich_texts :absence_extra_text
translated_rich_texts :membership_update_text
translated_rich_texts :member_information_text
translated_attributes :member_information_title
translated_rich_texts :member_form_extra_text
translated_rich_texts :member_form_complements_text
translated_attributes :new_member_fee_description
Expand Down
3 changes: 1 addition & 2 deletions app/views/layouts/members/_footer.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ footer class="w-full flex flex-col text-base text-gray-400 mt-16 dark:text-gray-
li class="mx-auto px-4 md:mx-0 md:px-0 mb-4"
= link_to members_info_path, class: 'flex items-center hover:text-green-500 py-1 px-4 md:px-0' do
= inline_svg_tag 'members/information-circle.svg', class: 'h-6 w-6 flex-shrink-0 fill-stroke'
span class='ml-2'
= t('.information')
span class='ml-2' = member_information_title
- if Current.acp.phone?
li class="mx-auto px-4 #{'md:mx-0 md:px-0' if current_member}"
= link_to "tel:#{Current.acp.phone.phony_formatted(spaces: '', format: :international)}", class: 'flex items-center hover:text-green-500 py-1 px-4 md:px-0' do
Expand Down
2 changes: 1 addition & 1 deletion app/views/members/infos/show.html.slim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
h1 class="mt-2 mb-8 text-xl sm:text-2xl font-extrabold text-gray-900 dark:text-gray-100"
= t('.title')
= member_information_title

section
== Current.acp.member_information_text
8 changes: 6 additions & 2 deletions config/locales/activerecord.yml
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,12 @@ _:
_it: Mostra solo spiegazioni supplementari
member_information_text:
_de: Informationsseite
_fr: Page d'informations
_it: Pagina di informazioni
_fr: Page d'information
_it: Pagina d'informazione
member_information_title:
_de: Titel der Informationsseite
_fr: Intitulé de la page d'information
_it: Titolo della pagina d'informazione
membership_complements_update_allowed:
_de: Änderung der Zusätze erlauben
_fr: Permettre la modification des compléments
Expand Down
4 changes: 4 additions & 0 deletions config/locales/formtastic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ _:
_de: Wenn vorhanden, wird der Inhalt dieses Feldes im Mitgliederkonto unter dem Punkt "Informationen" angezeigt. Sie können es z.B. verwenden, um vertrauliche Informationen mit Ihren Mitgliedern zu teilen.
_fr: Si présent, le contenu de ce champ sera affiché sur le compte du membre sous la section "Informations". Vous pouvez l'utiliser, par exemple, pour partager des informations confidentielles avec vos membres.
_it: Se presente, il contenuto di questo campo verrà visualizzato sul conto del socio sotto la sezione "Informazioni". Puoi usarlo, ad esempio, per condividere informazioni riservate con i tuoi soci.
member_information_title:
_de: Lassen Sie es leer, um den Standardtitel zu verwenden.
_fr: Laisser blanc pour utiliser l'intitulé par défaut.
_it: Lasciare vuoto per utilizzare il titolo predefinito.
member_order_priority_html:
_de: Ermöglicht das Erzwingen der Position, bevor die in <a href='/settings#registration'>den Einstellungen</a> festgelegte Reihenfolge angewendet wird.
_fr: Permet de forcer la position avant l'application de l'ordre défini dans <a href='/settings#registration'>les paramètres</a>.
Expand Down
4 changes: 0 additions & 4 deletions config/locales/layouts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ _:
_de: Kontakt
_fr: Contact
_it: Contatti
information:
_de: Informationen
_fr: Informations
_it: Informazioni
header:
absences_subtitle:
_de: "⤷ Informieren Sie uns!"
Expand Down
11 changes: 5 additions & 6 deletions config/locales/members.yml
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,11 @@ _:
_de: Vielen Dank, dass Sie sich wieder für unseren Newsletter angemeldet haben!
_fr: Merci de vous être à nouveau inscrit à nos newsletters!
_it: Grazie per esservi nuovamente iscritti alla nostra newsletter!
infos:
show:
title:
_de: Informationen
_fr: Informations
_it: Informazioni
information:
default_title:
_de: Informationen
_fr: Informations
_it: Informazioni
members:
form_modes:
membership:
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20231112095735_add_member_information_titles.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMemberInformationTitles < ActiveRecord::Migration[7.1]
def change
add_column :acps, :member_information_titles, :jsonb, default: {}, null: false
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_11_11_103455) do
ActiveRecord::Schema[7.1].define(version: 2023_11_12_095735) do
# These are extensions that must be enabled in order to support this database
enable_extension "hstore"
enable_extension "plpgsql"
Expand Down Expand Up @@ -114,6 +114,7 @@
t.string "membership_renewed_attributes", default: ["baskets_annual_price_change", "basket_complements_annual_price_change", "activity_participations_demanded_annualy", "activity_participations_annual_price_change"], array: true
t.decimal "new_member_fee", precision: 8, scale: 2
t.jsonb "new_member_fee_descriptions", default: {}, null: false
t.jsonb "member_information_titles", default: {}, null: false
t.index ["host"], name: "index_acps_on_host"
t.index ["tenant_name"], name: "index_acps_on_tenant_name"
end
Expand Down
17 changes: 17 additions & 0 deletions spec/system/members/infos_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@
expect(page).to have_content('Some confidential infos')
end

specify 'show informations with custom title' do
Current.acp.update!(
member_information_title: 'Archive',
member_information_text: 'Some confidential archive infos')
login(create(:member))

visit '/'

expect(page).to have_link('Archive')

click_on 'Archive'

expect(current_path).to eq('/info')
expect(page).to have_content('Archive')
expect(page).to have_content('Some confidential archive infos')
end

specify 'do not show informations when not set' do
Current.acp.update!(member_information_text: nil)
login(create(:member))
Expand Down

0 comments on commit 7cabc71

Please sign in to comment.