diff --git a/app/controllers/concerns/admin/widget/cards_actions.rb b/app/controllers/concerns/admin/widget/cards_actions.rb
index 9e1211cdb..bc9e4c886 100644
--- a/app/controllers/concerns/admin/widget/cards_actions.rb
+++ b/app/controllers/concerns/admin/widget/cards_actions.rb
@@ -45,7 +45,7 @@ module Admin::Widget::CardsActions
def allowed_params
[
- :link_url, :button_text, :button_url, :alignment, :header, :columns,
+ :link_url, :button_text, :button_url, :alignment, :header, :columns, :order,
translation_params(Widget::Card),
image_attributes: image_attributes
]
diff --git a/app/views/admin/widget/cards/_form.html.erb b/app/views/admin/widget/cards/_form.html.erb
index 3ea238768..7384e6475 100644
--- a/app/views/admin/widget/cards/_form.html.erb
+++ b/app/views/admin/widget/cards/_form.html.erb
@@ -31,12 +31,12 @@
<% unless card.header_or_sdg_header? %>
-
- <%= f.label :columns %>
-
<%= t("admin.site_customization.pages.cards.columns_help") %>
-
- <%= f.select :columns, (1..12), label: false %>
-
+
+ <%= f.select :columns, (1..12), hint: t("admin.site_customization.pages.cards.columns_help") %>
+
+
+
+ <%= f.number_field :order, min: 1, hint: t("admin.site_customization.pages.cards.order_help") %>
<% end %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml
index f2089ca9c..787eaabf7 100644
--- a/config/locales/en/activerecord.yml
+++ b/config/locales/en/activerecord.yml
@@ -488,6 +488,7 @@ en:
link_text: Link text
link_url: Link URL
columns: Number of columns
+ order: Position
widget/card/translation:
label: Label (optional)
title: Title
diff --git a/config/locales/en/admin.yml b/config/locales/en/admin.yml
index cd42d4782..3bba3b65d 100644
--- a/config/locales/en/admin.yml
+++ b/config/locales/en/admin.yml
@@ -1648,6 +1648,7 @@ en:
create_card: Create card
no_cards: There are no cards.
columns_help: "Width of the card in number of columns. On mobile screens it's always a width of 100%."
+ order_help: "You can enter the position where this card will be shown."
create:
notice: "Card created successfully!"
update:
diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml
index b3a321a76..a9fc0a0e8 100644
--- a/config/locales/es/activerecord.yml
+++ b/config/locales/es/activerecord.yml
@@ -488,6 +488,7 @@ es:
link_text: Texto del enlace
link_url: URL del enlace
columns: Número de columnas
+ order: Posición
widget/card/translation:
label: Etiqueta (opcional)
title: Título
diff --git a/config/locales/es/admin.yml b/config/locales/es/admin.yml
index 0b47ca4b4..9fdcdd41f 100644
--- a/config/locales/es/admin.yml
+++ b/config/locales/es/admin.yml
@@ -1648,6 +1648,7 @@ es:
create_card: Crear tarjeta
no_cards: No hay tarjetas.
columns_help: "Ancho de la tarjeta en número de columnas. En pantallas móviles siempre es un ancho del 100%."
+ order_help: "Puedes introducir la posición en la que se mostrará esta tarjeta."
create:
notice: "¡Tarjeta creada con éxito!"
update:
diff --git a/spec/system/admin/widgets/cards_spec.rb b/spec/system/admin/widgets/cards_spec.rb
index 0563dab84..ad0559237 100644
--- a/spec/system/admin/widgets/cards_spec.rb
+++ b/spec/system/admin/widgets/cards_spec.rb
@@ -11,7 +11,8 @@ describe "Cards", :admin do
fill_in "Title", with: "Card text"
fill_in "Description", with: "Card description"
fill_in "Link text", with: "Link text"
- fill_in "widget_card_link_url", with: "consul.dev"
+ fill_in "Link URL", with: "consul.dev"
+ fill_in "Position", with: "12"
attach_image_to_card
click_button "Create card"
@@ -25,6 +26,7 @@ describe "Cards", :admin do
expect(page).to have_content "Card description"
expect(page).to have_content "Link text"
expect(page).to have_content "consul.dev"
+ expect(page).to have_css "td", exact_text: "12"
expect(page).to have_link "Show image", title: "clippy.jpg"
end
end
@@ -87,7 +89,8 @@ describe "Cards", :admin do
fill_in "Link text", with: "Link text updated"
end
- fill_in "widget_card_link_url", with: "consul.dev updated"
+ fill_in "Link URL", with: "consul.dev updated"
+ fill_in "Position", with: "2"
click_button "Save card"
expect(page).to have_content "Card updated successfully"
@@ -101,6 +104,7 @@ describe "Cards", :admin do
expect(page).to have_content "Card description updated"
expect(page).to have_content "Link text updated"
expect(page).to have_content "consul.dev updated"
+ expect(page).to have_css "td", exact_text: "2"
end
end
end
@@ -125,6 +129,8 @@ describe "Cards", :admin do
visit admin_homepage_path
click_link "Create header"
+ expect(page).not_to have_field "Position"
+
fill_in "Label (optional)", with: "Header label"
fill_in "Title", with: "Header text"
fill_in "Description", with: "Header description"
@@ -174,10 +180,13 @@ describe "Cards", :admin do
fill_in "Title", with: "Card for a custom page"
fill_in "Link URL", with: "/any_path"
+ fill_in "Position", with: "12"
click_button "Create card"
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content "Card for a custom page"
+ expect(page).to have_content "12"
+ expect(page).to have_css "th", exact_text: "Position"
end
scenario "Show" do
@@ -239,12 +248,14 @@ describe "Cards", :admin do
within(".translatable-fields") do
fill_in "Title", with: "Updated title"
end
+ fill_in "Position", with: "2"
click_button "Save card"
expect(page).to have_current_path admin_site_customization_page_widget_cards_path(custom_page)
expect(page).to have_content "Updated title"
expect(page).not_to have_content "Original title"
+ expect(page).to have_css "td", exact_text: "2"
end
scenario "Destroy" do
diff --git a/spec/system/sdg_management/homepage_spec.rb b/spec/system/sdg_management/homepage_spec.rb
index 715ae9249..2245b3cd0 100644
--- a/spec/system/sdg_management/homepage_spec.rb
+++ b/spec/system/sdg_management/homepage_spec.rb
@@ -22,13 +22,17 @@ describe "SDG homepage configuration" do
click_link "Create planning card"
expect(page).to have_field "Number of columns"
+ expect(page).to have_field "Position"
within(".translatable-fields") { fill_in "Title", with: "My planning card" }
fill_in "Link URL", with: "/any_path"
+ fill_in "Position", with: "2"
click_button "Create card"
within(".planning-cards") do
expect(page).to have_content "My planning card"
+ expect(page).to have_css "th", exact_text: "Position"
+ expect(page).to have_css "td", exact_text: "2"
end
within(".sensitization-cards") do
@@ -57,6 +61,7 @@ describe "SDG homepage configuration" do
click_link "Create header"
expect(page).not_to have_field "Number of columns"
+ expect(page).not_to have_field "Position"
within(".translatable-fields") { fill_in "Title", with: "My header" }
fill_in "Link URL", with: "/any_path"