Migration for adding summary and description to polls created. Both text_areas were added to polls form.
Imageable class included in polls model and the first aproach for adding images added to form.
This commit is contained in:
@@ -73,7 +73,9 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
|
||||
end
|
||||
|
||||
def poll_params
|
||||
params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, geozone_ids: [])
|
||||
params.require(:poll).permit(:name, :starts_at, :ends_at, :geozone_restricted, :summary, :description,
|
||||
geozone_ids: [],
|
||||
image_attributes: [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy])
|
||||
end
|
||||
|
||||
def search_params
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class Poll < ActiveRecord::Base
|
||||
include Imageable
|
||||
|
||||
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
|
||||
has_many :booths, through: :booth_assignments
|
||||
has_many :partial_results, through: :booth_assignments
|
||||
|
||||
@@ -19,6 +19,43 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%=f.text_area :summary, rows: 4%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-12 column">
|
||||
<%=f.text_area :description, rows: 8%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="images small-12 column">
|
||||
<div>
|
||||
<%= f.label :image, t("images.form.admin_title") %>
|
||||
|
||||
<div id="nested-image">
|
||||
<%= f.fields_for :image do |image_builder| %>
|
||||
<%= render 'images/image_fields', f: image_builder, imageable: @poll %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= link_to_add_association t('images.form.add_new_image'), f, :image,
|
||||
force_non_association_create: true,
|
||||
partial: "images/image_fields",
|
||||
id: "new_image_link",
|
||||
class: "button hollow #{"hide" if @poll.image.present?}",
|
||||
render_options: {
|
||||
locals: { imageable: @poll }
|
||||
},
|
||||
data: {
|
||||
association_insertion_node: "#nested-image",
|
||||
association_insertion_method: "append"
|
||||
} %>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="small-6 medium-6 column">
|
||||
<%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %>
|
||||
|
||||
@@ -9,6 +9,8 @@ en:
|
||||
delete_button: Remove image
|
||||
note: "You can upload one image of following content types: %{accepted_content_types}, up to %{max_file_size} MB."
|
||||
add_new_image: Add image
|
||||
title_placeholder: Add a descriptive title for the image
|
||||
admin_title: "Main image of the poll"
|
||||
|
||||
actions:
|
||||
destroy:
|
||||
|
||||
@@ -9,6 +9,7 @@ es:
|
||||
note: "Puedes subir una imagen en los formatos: %{accepted_content_types}, y de hasta %{max_file_size} MB por archivo."
|
||||
add_new_image: Añadir imagen
|
||||
title_placeholder: Añade un título descriptivo para la imagen
|
||||
admin_title: "Imagen principal de la votación"
|
||||
|
||||
actions:
|
||||
destroy:
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
class AddSummaryAndDescriptionToPolls < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :polls, :summary, :text
|
||||
add_column :polls, :description, :text
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user