Add main link to each phase of the budget
Co-authored-by: decabeza <alberto@decabeza.es>
This commit is contained in:
@@ -191,5 +191,10 @@
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.main-link {
|
||||
@include regular-button;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,18 @@
|
||||
class: "html-area",
|
||||
hint: t("admin.budget_phases.edit.description_help_text") %>
|
||||
</div>
|
||||
|
||||
<div class="small-12 column">
|
||||
<p class="form-label"><%= t("admin.budget_phases.edit.main_call_to_action") %></p>
|
||||
<p class="help-text"> <%= t("admin.budget_phases.edit.main_call_to_action_description") %></p>
|
||||
<%= translations_form.text_field :main_link_text %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 column">
|
||||
<%= f.text_field :main_link_url, placeholder: t("admin.shared.example_url") %>
|
||||
</div>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images small-12 column">
|
||||
<%= render "images/nested_image", imageable: @phase, f: f %>
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
<h3><%= phase.name %></h3>
|
||||
<p><%= start_date(phase) %> - <%= end_date(phase) %></p>
|
||||
<%= auto_link_already_sanitized_html(wysiwyg(phase.description)) %>
|
||||
|
||||
<% if phase.main_link_text.present? && phase.main_link_url.present? %>
|
||||
<%= link_to phase.main_link_text, phase.main_link_url, class: "main-link" %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<% if phase.image.present? %>
|
||||
|
||||
@@ -31,7 +31,8 @@ module Admin::BudgetPhasesActions
|
||||
end
|
||||
|
||||
def budget_phase_params
|
||||
valid_attributes = [:starts_at, :ends_at, :enabled, image_attributes: image_attributes]
|
||||
valid_attributes = [:starts_at, :ends_at, :enabled, :main_link_url,
|
||||
image_attributes: image_attributes]
|
||||
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,7 @@ class Budget
|
||||
translates :name, touch: true
|
||||
translates :summary, touch: true
|
||||
translates :description, touch: true
|
||||
translates :main_link_text, touch: true
|
||||
include Globalizable
|
||||
include Sanitizable
|
||||
include Imageable
|
||||
@@ -20,6 +21,7 @@ class Budget
|
||||
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
||||
validates :budget, presence: true
|
||||
validates :kind, presence: true, uniqueness: { scope: :budget }, inclusion: { in: ->(*) { PHASE_KINDS }}
|
||||
validates :main_link_url, presence: true, if: -> { main_link_text.present? }
|
||||
validate :invalid_dates_range?
|
||||
validate :prev_phase_dates_valid?
|
||||
validate :next_phase_dates_valid?
|
||||
|
||||
Reference in New Issue
Block a user