Allow attaching an image to budget phases
Co-authored-by: decabeza <alberto@decabeza.es>
This commit is contained in:
@@ -22,4 +22,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.images {
|
||||||
|
@include direct-uploads;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button {
|
||||||
|
&.upload-image {
|
||||||
|
margin-bottom: $line-height / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,16 @@
|
|||||||
|
|
||||||
.budget-phase {
|
.budget-phase {
|
||||||
@include breakpoint(medium) {
|
@include breakpoint(medium) {
|
||||||
width: 50%;
|
@include grid-row-nest;
|
||||||
|
|
||||||
|
> * {
|
||||||
|
@include grid-column;
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.budget-phase-image {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,6 +43,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if feature?(:allow_images) %>
|
||||||
|
<div class="images small-12 column">
|
||||||
|
<%= render "images/nested_image", imageable: @phase, f: f %>
|
||||||
|
<p class="help-text"><%= t("admin.budget_phases.edit.image_description") %></p>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<div class="small-12 column">
|
<div class="small-12 column">
|
||||||
<%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success" %>
|
<%= f.submit t("admin.budget_phases.edit.save_changes"), class: "button success" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -43,9 +43,17 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="budget-phase">
|
<div class="budget-phase">
|
||||||
<h3><%= phase.name %></h3>
|
<div class="budget-phase-content">
|
||||||
<p><%= start_date(phase) %> - <%= end_date(phase) %></p>
|
<h3><%= phase.name %></h3>
|
||||||
<%= auto_link_already_sanitized_html(wysiwyg(phase.description)) %>
|
<p><%= start_date(phase) %> - <%= end_date(phase) %></p>
|
||||||
|
<%= auto_link_already_sanitized_html(wysiwyg(phase.description)) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if phase.image.present? %>
|
||||||
|
<div class="budget-phase-image">
|
||||||
|
<%= image_tag phase.image.attachment.url(:large) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ module Admin::BudgetPhasesActions
|
|||||||
|
|
||||||
included do
|
included do
|
||||||
include Translatable
|
include Translatable
|
||||||
|
include ImageAttributes
|
||||||
|
|
||||||
before_action :load_budget
|
before_action :load_budget
|
||||||
before_action :load_phase, only: [:edit, :update]
|
before_action :load_phase, only: [:edit, :update]
|
||||||
@@ -30,7 +31,7 @@ module Admin::BudgetPhasesActions
|
|||||||
end
|
end
|
||||||
|
|
||||||
def budget_phase_params
|
def budget_phase_params
|
||||||
valid_attributes = [:starts_at, :ends_at, :enabled]
|
valid_attributes = [:starts_at, :ends_at, :enabled, image_attributes: image_attributes]
|
||||||
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
params.require(:budget_phase).permit(*valid_attributes, translation_params(Budget::Phase))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class Budget
|
|||||||
translates :description, touch: true
|
translates :description, touch: true
|
||||||
include Globalizable
|
include Globalizable
|
||||||
include Sanitizable
|
include Sanitizable
|
||||||
|
include Imageable
|
||||||
|
|
||||||
belongs_to :budget, touch: true
|
belongs_to :budget, touch: true
|
||||||
belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase
|
belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ en:
|
|||||||
duration: "Phase's duration"
|
duration: "Phase's duration"
|
||||||
duration_description: "The period of time this phase will be active."
|
duration_description: "The period of time this phase will be active."
|
||||||
enabled_help_text: This phase will be public in the budget's phases timeline, as well as active for any other purpose
|
enabled_help_text: This phase will be public in the budget's phases timeline, as well as active for any other purpose
|
||||||
|
image_description: "If an image is uplodaded it will be displayed next to the description of this phase."
|
||||||
name_help_text: "This is the title of the phase users will read on the header whenever this phase is active."
|
name_help_text: "This is the title of the phase users will read on the header whenever this phase is active."
|
||||||
save_changes: Save changes
|
save_changes: Save changes
|
||||||
index:
|
index:
|
||||||
|
|||||||
@@ -199,6 +199,7 @@ es:
|
|||||||
duration: "Duración de la fase"
|
duration: "Duración de la fase"
|
||||||
duration_description: "El período de tiempo que esta fase estará activa."
|
duration_description: "El período de tiempo que esta fase estará activa."
|
||||||
enabled_help_text: Esta fase será pública en el calendario de fases del presupuesto y estará activa para otros propósitos
|
enabled_help_text: Esta fase será pública en el calendario de fases del presupuesto y estará activa para otros propósitos
|
||||||
|
image_description: "Si se proporciona una imagen se mostrará junto a la descripción de esta fase."
|
||||||
name_help_text: "Este es el título de la fase que los usuarios leerán en el encabezado cuando la fase esté activa."
|
name_help_text: "Este es el título de la fase que los usuarios leerán en el encabezado cuando la fase esté activa."
|
||||||
save_changes: Guardar cambios
|
save_changes: Guardar cambios
|
||||||
title: "Editar fase"
|
title: "Editar fase"
|
||||||
|
|||||||
@@ -42,5 +42,18 @@ describe "Admin budget phases" do
|
|||||||
expect(page).not_to have_content "Accepting projects"
|
expect(page).not_to have_content "Accepting projects"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scenario "shows successful notice when updating the phase with a valid image" do
|
||||||
|
visit edit_admin_budget_budget_phase_path(budget, budget.current_phase)
|
||||||
|
|
||||||
|
imageable_attach_new_file(
|
||||||
|
"budget_phase_image",
|
||||||
|
Rails.root.join("spec/fixtures/files/clippy.jpg")
|
||||||
|
)
|
||||||
|
|
||||||
|
click_on "Save changes"
|
||||||
|
|
||||||
|
expect(page).to have_content "Changes saved"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user