Skip to content

Commit

Permalink
refactor fields to 0.28
Browse files Browse the repository at this point in the history
  • Loading branch information
Crashillo committed Apr 3, 2024
1 parent ef262d6 commit 81a4449
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 98 deletions.
87 changes: 41 additions & 46 deletions app/views/decidim/extra_user_fields/_registration_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,49 +1,44 @@
<% if current_organization.extra_user_fields_enabled? %>
<div class="card">
<div class="card__content card__extra_user_fields">
<div class="legend">
<h3><%= t(".signup.legend") %></h3>
</div>

<% if current_organization.activated_extra_field?(:date_of_birth) %>
<div class="field">
<%= f.date_field :date_of_birth %>
</div>
<% end %>
<% if current_organization.activated_extra_field?(:gender) %>
<div class="field">
<%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %>
</div>
<% end %>
<% if current_organization.activated_extra_field?(:country) %>
<div class="field">
<%= f.custom_country_select :country %>
</div>
<% end %>
<% if current_organization.activated_extra_field?(:postal_code) %>
<div class="field">
<%= f.text_field :postal_code %>
</div>
<% end %>
<% if current_organization.activated_extra_field?(:phone_number) %>
<div class="field">
<%= f.text_field :phone_number %>
</div>
<% end %>
<% if current_organization.activated_extra_field?(:location) %>
<div class="field">
<%= f.text_field :location %>
</div>
<% end %>
<%# Block ExtraUserFields SignUpFormFields %>
<%# EndBlock %>
</div>
<div id="card__extra_user_fields" class="form__wrapper form__wrapper-block">
<h4 class="h4"><%= t(".signup.legend") %></h4>

<% if current_organization.activated_extra_field?(:date_of_birth) %>
<%= f.date_field :date_of_birth %>
<% end %>
<% if current_organization.activated_extra_field?(:gender) %>
<%= f.collection_select :gender, f.object.gender_options_for_select, :first, :last %>
<% end %>
<% if current_organization.activated_extra_field?(:country) %>
<%= f.custom_country_select :country %>
<% end %>
<% if current_organization.activated_extra_field?(:postal_code) %>
<%= f.text_field :postal_code %>
<% end %>
<%
# TODO: move wherever it takes
def telephone_pattern
"^(\\+34)?[0-9]{9}$"
end

def telephone_placeholder
"+34987654321"
end
%>
<% if current_organization.activated_extra_field?(:phone_number) %>
<%= f.telephone_field :phone_number, placeholder: telephone_placeholder, pattern: telephone_pattern %>
<% end %>
<% if current_organization.activated_extra_field?(:location) %>
<%= f.text_field :location %>
<% end %>
<%# Block ExtraUserFields SignUpFormFields %>
<%# EndBlock %>

</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
<p class="callout success"><%== t(".callout.help") %></p>
<div class="card">
<div class="card-section extra_user_fields">
<div>
<h3><%= t(".global.title") %></h3>
<%= cell("decidim/announcement", t(".callout.help"), callout_class: "success" ) %>

<div class="form__wrapper">
<div class="card" data-component="accordion" id="accordion-global">
<div class="card-divider">
<button class="card-divider-button" data-open="true" data-controls="panel-global" type="button">
<%= icon "arrow-right-s-line" %>
<h2 class="card-title"><%= t(".global.title") %></h2>
</button>
</div>
<div class="row column">
<%= form.check_box :enabled, label: t(".extra_user_fields.extra_user_fields_enabled") %>

<div id="panel-global" class="card-section">
<div class="row column">
<%= form.check_box :enabled, label: t(".extra_user_fields.extra_user_fields_enabled") %>
</div>
</div>
</div>
</div>

<div class="card extra_fields_setup">
<div class="card-section">
<div>
<h3><%= t(".extra_user_fields.section") %></h3>
<div class="card" data-component="accordion" id="accordion-setup">
<div class="card-divider">
<button class="card-divider-button" data-open="true" data-controls="panel-setup" type="button">
<%= icon "arrow-right-s-line" %>
<h2 class="card-title"><%= t(".extra_user_fields.section") %></h2>
</button>
</div>

<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/date_of_birth", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/country", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/postal_code", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/gender", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %>
<%# Block ExtraUserFields ExtraFields %>
<%# EndBlock %>
<div id="panel-setup" class="card-section">
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/date_of_birth", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/country", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/postal_code", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/gender", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/phone_number", locals: { form: form } %>
<%= render partial: "decidim/extra_user_fields/admin/extra_user_fields/fields/location", locals: { form: form } %>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :country, label: t(".label") %>
<%= form.check_box :country, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :date_of_birth, label: t(".label") %>
<%= form.check_box :date_of_birth, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :gender, label: t(".label") %>
<%= form.check_box :gender, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :location, label: t(".label") %>
<%= form.check_box :location, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :phone_number, label: t(".label") %>
<%= form.check_box :phone_number, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<div class="card-section">
<div class="row column">
<p><%= t(".description") %></p>
<%= form.check_box :postal_code, label: t(".label") %>
<%= form.check_box :postal_code, label: t(".label"), help_text: t(".description") %>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<div class="card" id="extra_user_fields">
<div class="card-divider">
<h2 class="card-title">
<%= t ".title" %>
</h2>
</div>
<div class="card-section">
<%= decidim_form_for(@form, url: "/admin/extra_user_fields/extra_user_fields", html: { class: "form edit_extra_user_fields" }, method: :patch) do |f| %>
<%= render partial: "form", object: f %>
<% add_decidim_page_title(t(".title")) %>
<div class="item_show__header">
<h1 class="item_show__header-title">
<%= t ".title" %>
</h1>
</div>
<div id="extra_user_fields" class="item__edit-form">
<%= decidim_form_for(@form, url: "/admin/extra_user_fields/extra_user_fields", html: { class: "form-defaults form edit_extra_user_fields" }, method: :patch) do |f| %>
<%= render partial: "form", object: f %>

<div class="button--double form-general-submit">
<%= f.submit t(".save") %>
<div class="item__edit-sticky">
<div class="item__edit-sticky-container">
<%= f.submit t(".save"), class: "button button__sm button__secondary" %>
</div>
<% end %>
</div>
</div>
<% end %>
</div>
2 changes: 1 addition & 1 deletion lib/decidim/extra_user_fields/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.version
end

def self.decidim_version
[">= 0.27.0", "< 0.28"].freeze
[">= 0.28"].freeze
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
end

it "allows to enable extra user fields functionality" do
within ".extra_user_fields" do
within "#extra_user_fields" do
expect(page).to have_content("Enable extra user fields")
end

within ".extra_fields_setup" do
expect(page).to have_content("Available extra fields for signup form")
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/system/registration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def fill_extra_user_fields
end

it "contains extra user fields" do
within ".card__extra_user_fields" do
within "#card__extra_user_fields" do
expect(page).to have_content("Date of birth")
expect(page).to have_content("Gender")
expect(page).to have_content("Country")
Expand Down

0 comments on commit 81a4449

Please sign in to comment.