Skip to content

Commit

Permalink
Layout finalization + translation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ahukkanen committed Oct 2, 2023
1 parent 269b413 commit 7c639ab
Show file tree
Hide file tree
Showing 22 changed files with 167 additions and 160 deletions.
6 changes: 5 additions & 1 deletion app/cells/decidim/plans/plan_form/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

<%= contents_edit %>

<%= render :buttons %>
<div class="row medium-unstack">
<div class="columns medium-11">
<%= render :buttons %>
</div>
</div>

<%
js_options = {
Expand Down
5 changes: 3 additions & 2 deletions app/cells/decidim/plans/section_edit_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ def help_text
@help_text ||= translated_attribute(section.help).strip
end

def field_info_classes
classes = %w(field-info)
def field_label_classes
classes = []
classes << "with-tooltip" if show_tooltip?
return if classes.blank?

classes.join(" ")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<div class="field">
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<%= scopes_picker_field form, :scope_id, options: { label: false, include_blank: true }, html_options: { disabled: field_disabled? } %>
</div>
<% if show_info_link? %>
<div class="columns medium-5 large-4">
<div class="columns medium-5">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
<%= content_tag :div, class: "field attachments-section margin-bottom-2" do %>
<div class="row medium-unstack field-label-with-info">
<div class="columns medium-7 large-8">
<%= content_tag :div, class: field_info_classes do %>
<div class="columns medium-7">
<%= content_tag :div, class: field_label_classes do %>
<%= plain_label form, :attachments %>
<%= render :tooltip %>
<% end %>
</div>
<% if show_info_link? %>
<div class="columns medium-5 large-4">
<div class="columns medium-5">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
<% end %>
</div>

<div class="row medium-unstack">
<div class="columns columns medium-7 large-8">
<div class="columns columns medium-7">
<% if field_disabled? %>
<%= t(".disabled") %>
<% else %>
Expand Down
30 changes: 15 additions & 15 deletions app/cells/decidim/plans/section_type_edit/field_category/show.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<div class="field field-category" id="<%= field_id %>">
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<%= content_tag :div, class: field_info_classes do %>
<%= content_tag :div, class: field_label_classes do %>
<%= plain_label form, "body_#{current_locale}".to_sym %>
<%= render :tooltip %>
<% end %>
</div>
</div>

<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="field">
<div class="field">
<div class="row medium-unstack">
<div class="columns medium-7">
<%= categories_select(
form,
:category_id,
Expand All @@ -25,22 +25,22 @@
}
) %>
</div>
</div>
<% if show_info_link? %>
<div class="columns medium-5 large-4">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<% end %>
<% if show_info_link? %>
<div class="columns medium-5">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
</div>

<div class="field">
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<div class="field-subcategory">
<% top_categories.each do |category| %>
<% next if category.subcategories.blank? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% if show_input? %>
<div class="field field-checkbox field-terms">
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<label>
<%= form.check_box(:value, field_options.merge(label_options: { for: nil })) %>
<%= translated_attribute(section.body) %>
Expand All @@ -11,8 +11,8 @@
<% if show_info_link? %>
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
<% end %>
Expand Down
23 changes: 15 additions & 8 deletions app/cells/decidim/plans/section_type_edit/field_map_point/show.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="address-input">
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<div class="field" id="<%= address_id %>">
<%= form.geocoding_field :address, object: model, label: false, class: "input-group-field address-input-address", data: {
"coordinates-url": geocoding_path,
Expand All @@ -19,14 +19,21 @@
%>
</div>
</div>
<div class="columns medium-5 large-4">
<%= form.button t(".address_lookup_button"), type: :button, class: "button address-input-lookup", disabled: field_disabled? %>
<div class="columns medium-5">
<%= form.button type: :button, class: "button button--icon address-input-lookup", disabled: field_disabled? do %>
<%= t(".address_lookup_button") %>
<%= icon "target", aria_hidden: true, role: "img" %>
<% end %>
</div>
</div>

<%= form_map(
id: "#{address_id}_map",
class: "plans-map google-map",
"data-connected-input" => user_signed_in? ? "##{address_id} .address-input-address" : nil
) %>
<div class="row medium-unstack">
<div class="columns medium-11">
<%= form_map(
id: "#{address_id}_map",
class: "plans-map google-map",
"data-connected-input" => user_signed_in? ? "##{address_id} .address-input-address" : nil
) %>
</div>
</div>
</div>
10 changes: 5 additions & 5 deletions app/cells/decidim/plans/section_type_edit/field_number/show.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<div class="field">
<div class="row medium-unstack field-label-with-info">
<div class="columns medium-7 large-8">
<%= content_tag :div, class: field_info_classes do %>
<%= content_tag :div, class: field_label_classes do %>
<%= plain_label form, :value %>
<%= render :tooltip %>
<% end %>
</div>
</div>

<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<% if currency_type? %>
<div class="input-group">
<% if currency_unit_after? %>
Expand All @@ -28,11 +28,11 @@
<% end %>
</div>
<% if show_info_link? %>
<div class="columns medium-5 large-4">
<div class="columns medium-5">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<%= plain_label form, :scope_id %>

<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<div class="field">
<%= scopes_picker_field form, :scope_id, options: { label: false, include_blank: true }, html_options: { disabled: field_disabled? } %>
</div>
</div>
<div class="columns medium-5 large-4">
<div class="columns medium-5">
<% if show_info_link? %>
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
<% end %>
Expand Down
8 changes: 4 additions & 4 deletions app/cells/decidim/plans/section_type_edit/field_tags/show.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<%= plain_label form, :taggings %>

<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="columns medium-7">
<div class="field">
<%= cell("decidim/tags/form", form, label: false) %>
</div>
</div>
<% if show_info_link? %>
<div class="columns medium-5 large-4">
<div class="columns medium-5">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
Expand Down
16 changes: 9 additions & 7 deletions app/cells/decidim/plans/section_type_edit/field_text/show.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="field with-character-counter">
<div class="row medium-unstack field-label-with-info">
<div class="columns medium-7 large-8">
<%= content_tag :div, class: field_info_classes do %>
<%= content_tag :div, class: field_label_classes do %>
<%= plain_label form, "body_#{current_locale}".to_sym %>
<%= render :tooltip %>
<% end %>
Expand Down Expand Up @@ -29,19 +29,21 @@
<div class="columns medium-5 large-4">
<div class="field-info field-info-with-icon">
<%= link_to info_path(section.id), class: "info-modal-link" do %>
<%= icon "information", aria_hidden: true %>
<%= information_label %>
<%= icon "info-line", aria_hidden: true %>
<span><%= information_label %></span>
<% end %>
</div>
</div>
<% end %>
</div>

<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="field-character-counter-info field-info help-text"></div>
<% if display_character_counter? %>
<div class="row medium-unstack">
<div class="columns medium-7 large-8">
<div class="field-character-counter-info help-text"></div>
</div>
</div>
</div>
<% end %>
</div>

<div id="plans-dummy-counter-<%= section.id %>" class="hide" aria-hidden="true"></div>
12 changes: 10 additions & 2 deletions app/cells/decidim/plans/section_type_edit/field_text_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ class FieldTextCell < Decidim::Plans::SectionEditCell

def field_options
base = super.merge(label: false)
return base if model.section.settings["answer_length"].to_i < 1
return base unless display_character_counter?

base.merge(
maxlength: model.section.settings["answer_length"],
maxlength: answer_length,
# Disable the core character counter with a hidden dummy element
"data-remaining-characters": "#plans-dummy-counter-#{section.id}"
)
end

def display_character_counter?
answer_length.positive?
end

def answer_length
model.section.settings["answer_length"].to_i
end
end
end
end
Expand Down
Loading

0 comments on commit 7c639ab

Please sign in to comment.