Table for links added (links to add images/documents).
Custom partial for admins upload image created, so that it can be reused in upload images and documents.
This commit is contained in:
@@ -313,7 +313,8 @@
|
|||||||
.proposal-form,
|
.proposal-form,
|
||||||
.proposal-edit,
|
.proposal-edit,
|
||||||
.new_poll_question,
|
.new_poll_question,
|
||||||
.edit_poll_question {
|
.edit_poll_question,
|
||||||
|
.edit_poll {
|
||||||
@include direct-uploads;
|
@include direct-uploads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ module Imageable
|
|||||||
|
|
||||||
included do
|
included do
|
||||||
has_one :image, as: :imageable, dependent: :destroy
|
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
|
accepts_nested_attributes_for :image, allow_destroy: true, update_only: true
|
||||||
|
|
||||||
def image_url(style)
|
def image_url(style)
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
class Poll < ActiveRecord::Base
|
class Poll < ActiveRecord::Base
|
||||||
include Imageable
|
include Imageable
|
||||||
|
include Documentable
|
||||||
|
|
||||||
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
|
has_many :booth_assignments, class_name: "Poll::BoothAssignment"
|
||||||
has_many :booths, through: :booth_assignments
|
has_many :booths, through: :booth_assignments
|
||||||
|
|||||||
@@ -31,29 +31,28 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="images small-12 column">
|
<div class="row">
|
||||||
<div>
|
<%= render 'images/admin_image', imageable: @poll, f: f %>
|
||||||
<%= f.label :image, t("images.form.admin_title") %>
|
</div>
|
||||||
|
|
||||||
<div id="nested-image">
|
<div class="row">
|
||||||
<%= f.fields_for :image do |image_builder| %>
|
<table>
|
||||||
<%= render 'images/image_fields', f: image_builder, imageable: @poll %>
|
<thead>
|
||||||
<% end %>
|
<tr>
|
||||||
</div>
|
<td colspan="2"><%= t("admin.polls.attachments.title") %></td>
|
||||||
</div>
|
</tr>
|
||||||
|
<tr>
|
||||||
<%= link_to_add_association t('images.form.add_new_image'), f, :image,
|
<td><%= t("admin.polls.attachments.images_title") %></td>
|
||||||
force_non_association_create: true,
|
<td><%= t("admin.polls.attachments.documents_title") %></td>
|
||||||
partial: "images/image_fields",
|
</tr>
|
||||||
id: "new_image_link",
|
</thead>
|
||||||
class: "button hollow #{"hide" if @poll.image.present?}",
|
<tbody>
|
||||||
render_options: {
|
<tr>
|
||||||
locals: { imageable: @poll }
|
<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>
|
||||||
data: {
|
</tr>
|
||||||
association_insertion_node: "#nested-image",
|
</tbody>
|
||||||
association_insertion_method: "append"
|
</table>
|
||||||
} %>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
60
app/views/images/_admin_image.html.erb
Normal file
60
app/views/images/_admin_image.html.erb
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<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: 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,
|
||||||
|
force_non_association_create: true,
|
||||||
|
partial: "images/image_fields",
|
||||||
|
id: "new_image_link",
|
||||||
|
class: "button hollow #{"hide" if imageable.image.present?}",
|
||||||
|
render_options: {
|
||||||
|
locals: { imageable: imageable }
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
association_insertion_node: "#nested-image",
|
||||||
|
association_insertion_method: "append"
|
||||||
|
} %>
|
||||||
|
</div>
|
||||||
@@ -152,6 +152,8 @@ en:
|
|||||||
starts_at: "Start Date"
|
starts_at: "Start Date"
|
||||||
ends_at: "Closing Date"
|
ends_at: "Closing Date"
|
||||||
geozone_restricted: "Restricted by geozone"
|
geozone_restricted: "Restricted by geozone"
|
||||||
|
summary: "Summary"
|
||||||
|
description: "Description"
|
||||||
poll/question:
|
poll/question:
|
||||||
title: "Question"
|
title: "Question"
|
||||||
valid_answers: "Posibles answers"
|
valid_answers: "Posibles answers"
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ es:
|
|||||||
starts_at: "Fecha de apertura"
|
starts_at: "Fecha de apertura"
|
||||||
ends_at: "Fecha de cierre"
|
ends_at: "Fecha de cierre"
|
||||||
geozone_restricted: "Restringida por zonas"
|
geozone_restricted: "Restringida por zonas"
|
||||||
|
summary: "Resumen"
|
||||||
|
description: "Descripción"
|
||||||
poll/question:
|
poll/question:
|
||||||
title: "Pregunta"
|
title: "Pregunta"
|
||||||
valid_answers: "Posibles respuestas"
|
valid_answers: "Posibles respuestas"
|
||||||
|
|||||||
@@ -580,6 +580,12 @@ es:
|
|||||||
error_on_question_added: "No se pudo asignar la pregunta"
|
error_on_question_added: "No se pudo asignar la pregunta"
|
||||||
question_removed: "Pregunta eliminada de esta votación"
|
question_removed: "Pregunta eliminada de esta votación"
|
||||||
error_on_question_removed: "No se pudo quitar la pregunta"
|
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:
|
questions:
|
||||||
index:
|
index:
|
||||||
title: "Preguntas ciudadanas"
|
title: "Preguntas ciudadanas"
|
||||||
|
|||||||
Reference in New Issue
Block a user