Adds styles and missing i18n for admin homepage

This commit is contained in:
decabeza
2018-05-23 17:40:03 +02:00
parent 5fe0dd46b9
commit 50fd540797
19 changed files with 205 additions and 82 deletions

View File

@@ -319,7 +319,8 @@
.legislation-process-new,
.legislation-process-edit,
.milestone-new,
.milestone-edit {
.milestone-edit,
.image-form {
@include direct-uploads;
}

View File

@@ -37,7 +37,11 @@ module AdminHelper
end
def menu_customization?
["pages", "images", "content_blocks"].include?(controller_name)
["pages", "images", "content_blocks"].include?(controller_name) || menu_homepage?
end
def menu_homepage?
["homepage", "cards"].include?(controller_name)
end
def official_level_options

View File

@@ -167,8 +167,8 @@
</a>
<ul <%= "class=is-active" if menu_customization? &&
controller.class.parent != Admin::Poll::Questions::Answers %>>
<li <%= "class=active" if controller_name == "homepage" %>>
<%= link_to "Homepage", admin_homepage_path %>
<li <%= "class=active" if menu_homepage? %>>
<%= link_to t("admin.menu.site_customization.homepage"), admin_homepage_path %>
</li>
<li <%= "class=active" if controller_name == "pages" %>>

View File

@@ -1,22 +1,27 @@
<tr id="<%= dom_id(card) %>" class="card">
<td><%= card.title %></td>
<td><%= card.description %></td>
<td><%= card.link_text %></td>
<td><%= card.link_url %></td>
<td>
<%= card.link_text %><br>
<%= card.link_url %>
</td>
<!-- remove conditional once specs have image validations -->
<td><% if card.image.present? %>
<%= image_tag(card.image_url(:thumb),
class: "margin",
alt: card.image.title) %>
<% end %></td>
<td>
<div>
<%= link_to "Edit", edit_admin_widget_card_path(card) %>
<div>
<%= link_to "Remove", admin_widget_card_path(card),
<% if card.image.present? %>
<%= link_to t("admin.shared.show_image"), card.image_url(:large),
title: card.image.title, target: "_blank" %>
<% end %>
</td>
<td>
<%= link_to t("admin.actions.edit"),
edit_admin_widget_card_path(card),
class: "button hollow" %>
<%= link_to t("admin.actions.delete"),
admin_widget_card_path(card),
method: :delete,
data: { confirm: t('admin.actions.confirm') } %>
<div>
data: { confirm: t('admin.actions.confirm') },
class: "button hollow alert" %>
</td>
</tr>

View File

@@ -1,13 +1,16 @@
<table>
<thead>
<tr>
<th>title</th>
<th>text</th>
<th>link text</th>
<th>link</th>
<th>image</th>
<th>actions</th>
<th><%= t("admin.homepage.cards.title") %></th>
<th class="small-4"><%= t("admin.homepage.cards.description") %></th>
<th><%= t("admin.homepage.cards.link_text") %> / <%= t("admin.homepage.cards.link_url") %></th>
<th><%= t("admin.shared.image") %></th>
<th><%= t("admin.shared.actions") %></th>
</tr>
</thead>
<tbody>
<% cards.each do |card| %>
<%= render "card", card: card %>
<% end %>
</tbody>
</table>

View File

@@ -5,7 +5,7 @@
value: (setting.enabled? ? "" : "active") %>
<%= f.submit(t("admin.settings.index.features.#{setting.enabled? ? 'disable' : 'enable'}"),
class: "button expanded #{setting.enabled? ? 'hollow alert' : 'success'}",
class: "button #{setting.enabled? ? 'hollow alert' : 'success'}",
data: {confirm: t("admin.actions.confirm")}) %>
<% end %>
</div>

View File

@@ -1,35 +1,48 @@
<h1>Homepage</h1>
<h2><%= t("admin.homepage.title") %></h2>
<p>The active modules appear in the homepage in the same order as here.</p>
<p><%= t("admin.homepage.description") %></p>
<div id="header">
<h3 class="inline-block"><%= t("admin.homepage.header_title") %></h3>
<div class="float-right">
<%= link_to t("admin.homepage.create_header"), new_admin_widget_card_path(header_card: true), class: "button" %>
</div>
<% if @header.present? %>
<%= render "cards", cards: @header %>
<% else %>
<div class="callout primary clear">
<%= t("admin.homepage.no_header") %>
</div>
<% end %>
</div>
<h2>Cards</h2>
<div>
<%= link_to "Create header", new_admin_widget_card_path(header_card: true) %>
</div>
<div>
<%= link_to "Create card", new_admin_widget_card_path %>
</div>
<hr>
<div id="cards">
<h3 class="inline-block"><%= t("admin.homepage.cards_title") %></h3>
<div class="float-right">
<%= link_to t("admin.homepage.create_card"), new_admin_widget_card_path, class: "button" %>
</div>
<% if @cards.present? %>
<%= render "cards", cards: @cards %>
<% else %>
<div class="callout primary clear">
<%= t("admin.homepage.no_cards") %>
</div>
<% end %>
</div>
<hr>
<% @settings.each do |setting| %>
<div>
<strong><%= t("settings.#{setting.key}") %></strong>
</div>
<div class="callout">
<h3 class="inline-block"><%= t("settings.#{setting.key}") %></h3>
<div class="float-right">
<%= render "setting", setting: setting %>
</div>
</div>
<% end %>

View File

@@ -1,11 +1,23 @@
<%= form_for [:admin, @card] do |f| %>
<%= f.text_field :title %>
<%= f.text_area :description %>
<%= f.text_area :description, rows: 5 %>
<div class="small-12 medium-6">
<%= f.text_field :link_text %>
</div>
<div class="small-12 medium-6">
<%= f.text_field :link_url %>
</div>
<%= f.hidden_field :header, value: @card.header? %>
<div class="images small-12 column">
<div class="image-form">
<div class="image small-12 column">
<%= render 'images/nested_image', imageable: @card, f: f %>
</div>
<%= f.submit %>
</div>
<%= f.submit(t("admin.homepage.#{action_name}.#{@card.header? ? 'submit_header' : 'submit_card'}"), class: "button success") %>
<% end %>

View File

@@ -1,2 +1,9 @@
Edit
<h2>
<% if @card.header? %>
<%= t("admin.homepage.edit.header_title") %>
<% else %>
<%= t("admin.homepage.edit.card_title") %>
<% end %>
</h2>
<%= render "form" %>

View File

@@ -1,2 +1,9 @@
New
<h2>
<% if @card.header? %>
<%= t("admin.homepage.new.header_title") %>
<% else %>
<%= t("admin.homepage.new.card_title") %>
<% end %>
</h2>
<%= render "form" %>

View File

@@ -16,7 +16,7 @@
<div class="top-bar-title">
<h1>
<%= link_to namespaced_root_path do %>
<%= link_to admin_root_path do %>
<%= setting['org_name'] %>
<br><small><%= namespaced_header_title %></small>
<% end %>

View File

@@ -143,6 +143,7 @@ ignore_unused:
- 'admin.settings.index.features.*'
- 'admin.polls.*.submit_button'
- 'admin.booths.*.submit_button'
- 'admin.homepage.*'
- 'moderation.comments.index.filter*'
- 'moderation.comments.index.order*'
- 'moderation.debates.index.filter*'

View File

@@ -245,6 +245,11 @@ en:
subject: Subject
from: From
body: Email content
widget/card:
title: Title
description: Description
link_text: Link text
link_url: Link URL
errors:
models:
user:

View File

@@ -499,6 +499,7 @@ en:
stats: Statistics
signature_sheets: Signature Sheets
site_customization:
homepage: Homepage
pages: Custom Pages
images: Custom Images
content_blocks: Custom content blocks
@@ -958,6 +959,8 @@ en:
actions: Actions
title: Title
description: Description
image: Image
show_image: Show image
spending_proposals:
index:
geozone_filter_all: All zones
@@ -1212,3 +1215,27 @@ en:
status_draft: Draft
status_published: Published
locale: Language
homepage:
title: Homepage
description: The active modules appear in the homepage in the same order as here.
header_title: Header
no_header: There is no header.
create_header: Create header
cards_title: Cards
create_card: Create card
no_cards: There is no cards.
cards:
title: Title
description: Description
link_text: Link text
link_url: Link URL
new:
header_title: New header
submit_header: Create header
card_title: New card
submit_card: Create card
edit:
header_title: Edit header
submit_header: Save header
card_title: Edit card
submit_card: Save card

View File

@@ -845,3 +845,6 @@ en:
proposal: "Proposal"
debate: "Debate"
budget_investment: "Budget investment"
admin/widget:
header:
title: Administration

View File

@@ -241,6 +241,11 @@ es:
subject: Asunto
from: Enviado por
body: Contenido del email
widget/card:
title: Título
description: Descripción
link_text: Texto del enlace
link_url: URL del enlace
errors:
models:
user:

View File

@@ -499,6 +499,7 @@ es:
stats: Estadísticas
signature_sheets: Hojas de firmas
site_customization:
homepage: Homepage
pages: Personalizar páginas
images: Personalizar imágenes
content_blocks: Personalizar bloques
@@ -958,6 +959,8 @@ es:
actions: Acciones
title: Título
description: Descripción
image: Imagen
show_image: Mostrar imagen
spending_proposals:
index:
geozone_filter_all: Todos los ámbitos de actuación
@@ -1212,3 +1215,27 @@ es:
status_draft: Borrador
status_published: Publicada
locale: Idioma
homepage:
title: Homepage
description: Los módulos activos aparecerán en la homepage en el mismo orden que aquí.
header_title: Encabezado
create_header: Crear encabezado
no_header: No hay encabezado.
cards_title: Tarjetas
create_card: Crear tarjeta
no_cards: No hay tarjetas.
cards:
title: Título
description: Descripción
link_text: Texto del enlace
link_url: URL del enlace
new:
header_title: Nuevo encabezado
submit_header: Crear encabezado
card_title: Nueva tarjeta
submit_card: Crear tarjeta
edit:
header_title: Editar encabezado
submit_header: Guardar encabezado
card_title: Editar tarjeta
submit_card: Guardar tarjeta

View File

@@ -844,3 +844,6 @@ es:
proposal: "Propuesta"
debate: "Debate"
budget_investment: "Proyecto de gasto"
admin/widget:
header:
title: Administración