Deleted code in views and concerns that lets polls have more images and documentes attached, like it was at first.

Added missing text for english and new texts in english and spanish.

 Cambios para hacer commit:
	modificado:    app/assets/stylesheets/participation.scss
	modificado:    app/models/concerns/imageable.rb
	modificado:    app/models/poll.rb
	modificado:    app/views/admin/poll/polls/_form.html.erb
	modificado:    app/views/images/_admin_image.html.erb
	modificado:    config/locales/en/images.yml
	modificado:    config/locales/es/admin.yml
	modificado:    config/locales/es/images.yml
	modificado:    spec/features/admin/poll/polls_spec.rb
This commit is contained in:
iagirre
2017-10-02 12:59:26 +02:00
parent c67620fdef
commit 166caa3b4c
9 changed files with 36 additions and 74 deletions

View File

@@ -314,6 +314,7 @@
.proposal-edit,
.new_poll_question,
.edit_poll_question,
.new_poll,
.edit_poll {
@include direct-uploads;
}

View File

@@ -5,7 +5,6 @@ module Imageable
included do
has_one :image, as: :imageable, dependent: :destroy
has_many :images, as: :imageable, dependent: :destroy
accepts_nested_attributes_for :image, allow_destroy: true, update_only: true
def image_url(style)

View File

@@ -1,6 +1,5 @@
class Poll < ActiveRecord::Base
include Imageable
include Documentable
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
has_many :booths, through: :booth_assignments

View File

@@ -35,26 +35,6 @@
<%= render 'images/admin_image', imageable: @poll, f: f %>
</div>
<div class="row">
<table>
<thead>
<tr>
<td colspan="2"><%= t("admin.polls.attachments.title") %></td>
</tr>
<tr>
<td><%= t("admin.polls.attachments.images_title") %></td>
<td><%= t("admin.polls.attachments.documents_title") %></td>
</tr>
</thead>
<tbody>
<tr>
<td><%= link_to "#{t("admin.polls.attachments.images_link")} (#{@poll.images.count})", root_path %></td>
<td><%= link_to "#{t("admin.polls.attachments.documents_link")} (#{@poll.documents.count})", root_path %></td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="small-6 medium-6 column">
<%= f.check_box :geozone_restricted, data: { checkbox_toggle: "#geozones" } %>

View File

@@ -2,54 +2,12 @@
<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: imageable %>
<!-- -->
<div id="<%= dom_id(image_builder.object) %>" class="image direct-upload nested-fields">
<%= image_builder.hidden_field :id %>
<%= image_builder.hidden_field :user_id, value: current_user.id %>
<%= image_builder.hidden_field :cached_attachment %>
<%= image_builder.text_field :title, placeholder: t("images.form.title_placeholder") %>
<%= render_image(image_builder.object, :thumb, false) if image_builder.object.attachment.exists? %>
<div class="attachment-actions">
<div class="small-9 column action-add attachment-errors image-attachment">
<%= render_image_attachment(image_builder, imageable, image_builder.object) %>
</div>
<div class="small-3 column action-remove text-right">
<%= render_destroy_image_link(image_builder, image_builder.object) %>
</div>
</div>
<div class="small-6 column">
<p class="file-name">
<%= image_attachment_file_name(image_builder.object) %>
</p>
</div>
<div class="small-12 column">
<div class="progress-bar-placeholder"><div class="loading-bar"></div></div>
</div>
</div>
<!-- -->
<% end %>
</div>
</div>
<%= link_to_add_association t('images.form.add_new_image'), f, :image,
<%= 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 imageable.image.present?}",
class: "button hollow",
render_options: {
locals: { imageable: imageable }
},
@@ -57,4 +15,31 @@
association_insertion_node: "#nested-image",
association_insertion_method: "append"
} %>
<div id="nested-image">
<%= f.fields_for :image do |image_builder| %>
<div id="<%= dom_id(image_builder.object) %>" class="image direct-upload nested-fields">
<%= image_builder.hidden_field :id %>
<%= image_builder.hidden_field :user_id, value: current_user.id %>
<%= image_builder.hidden_field :cached_attachment %>
<%= image_builder.text_field :title, placeholder: t("images.form.title_placeholder"), label: "#{t("images.form.admin_alt_text")}" %>
<div class="attachment-actions">
<div class="small-12 column action-add attachment-errors image-attachment">
<%= render_image_attachment(image_builder, imageable, image_builder.object) %>
</div>
</div>
<div class="small-12 column">
<div class="progress-bar-placeholder"><div class="loading-bar"></div></div>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -11,6 +11,7 @@ en:
add_new_image: Add image
title_placeholder: Add a descriptive title for the image
admin_title: "Main image of the poll"
admin_alt_text: "Alternative text for the image"
actions:
destroy:

View File

@@ -580,12 +580,6 @@ es:
error_on_question_added: "No se pudo asignar la pregunta"
question_removed: "Pregunta eliminada de esta votación"
error_on_question_removed: "No se pudo quitar la pregunta"
attachments:
title: "Imágenes y documentos de la votación"
images_title: "Imágenes"
documents_title: "Documents"
images_link: "Lista de imágenes"
documents_link: "Lista de documentos"
questions:
index:
title: "Preguntas ciudadanas"

View File

@@ -10,6 +10,7 @@ es:
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"
admin_alt_text: "Texto alternativo para la imagen"
actions:
destroy:

View File

@@ -58,6 +58,8 @@ feature 'Admin polls' do
fill_in "poll_name", with: "Upcoming poll"
fill_in 'poll_starts_at', with: start_date.strftime("%d/%m/%Y")
fill_in 'poll_ends_at', with: end_date.strftime("%d/%m/%Y")
fill_in 'poll_summary', with: "Upcoming poll's summary. This poll..."
fill_in 'poll_description', with: "Upcomming poll's description. This poll..."
click_button "Create poll"
expect(page).to have_content "Poll created successfully"