Ability to attach an image to budgets
Co-authored-by: decabeza <alberto@decabeza.es>
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
.admin .budgets-form {
|
||||
@include full-width-form;
|
||||
@include direct-uploads;
|
||||
|
||||
.button {
|
||||
&.upload-image {
|
||||
margin-bottom: $line-height / 2;
|
||||
}
|
||||
}
|
||||
|
||||
> fieldset {
|
||||
border-top: 4px solid $admin-border-color;
|
||||
|
||||
@@ -1136,6 +1136,12 @@
|
||||
padding-bottom: $line-height;
|
||||
padding-top: $line-height * 4;
|
||||
|
||||
&.with-background-image {
|
||||
background-position: center;
|
||||
background-repeat: no-repeat;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.budget-title {
|
||||
font-weight: bold;
|
||||
text-transform: uppercase;
|
||||
|
||||
@@ -36,6 +36,13 @@
|
||||
<%= f.select :currency_symbol, currency_symbol_select_options %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if feature?(:allow_images) %>
|
||||
<div class="images small-12 column">
|
||||
<%= render "/images/nested_image", imageable: budget, f: f %>
|
||||
<p class="help-text"><%= t("admin.budgets.edit.image_description") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
<div class="budget-header">
|
||||
<% if budget.image.present? %>
|
||||
<div class="budget-header with-background-image"
|
||||
style="background-image: url(<%= asset_url budget.image.attachment.url(:large) %>);">
|
||||
<% else %>
|
||||
<div class="budget-header">
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="small-12 column text-center">
|
||||
<span class="budget-title"><%= t("budgets.index.title") %></span>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Admin::BudgetsController < Admin::BaseController
|
||||
include Translatable
|
||||
include ReportAttributes
|
||||
include ImageAttributes
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
@@ -63,7 +64,8 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
:voting_style,
|
||||
:main_link_url,
|
||||
administrator_ids: [],
|
||||
valuator_ids: []
|
||||
valuator_ids: [],
|
||||
image_attributes: image_attributes
|
||||
] + descriptions
|
||||
params.require(:budget).permit(*valid_attributes, *report_attributes, translation_params(Budget))
|
||||
end
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Admin::BudgetsWizard::BudgetsController < Admin::BaseController
|
||||
include Translatable
|
||||
include ImageAttributes
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
@@ -36,7 +37,8 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
valid_attributes = [:currency_symbol, :voting_style, administrator_ids: [], valuator_ids: []]
|
||||
valid_attributes = [:currency_symbol, :voting_style, administrator_ids: [], valuator_ids: [],
|
||||
image_attributes: image_attributes]
|
||||
|
||||
valid_attributes + [translation_params(Budget)]
|
||||
end
|
||||
|
||||
@@ -3,6 +3,7 @@ class Budget < ApplicationRecord
|
||||
include Sluggable
|
||||
include StatsVersionable
|
||||
include Reportable
|
||||
include Imageable
|
||||
|
||||
translates :name, :main_link_text, touch: true
|
||||
include Globalizable
|
||||
|
||||
Reference in New Issue
Block a user