Skip to content

Commit

Permalink
enhancement: display a label with the next action for the ordering bu…
Browse files Browse the repository at this point in the history
…tton (#3454)

* Show title of sorted column name

* apply sorting label

* test

---------

Co-authored-by: Paul Bob <[email protected]>
Co-authored-by: Paul Bob <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent b0ff724 commit fe108af
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 3 deletions.
9 changes: 7 additions & 2 deletions app/views/avo/partials/_sortable_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,10 @@
end
end
%>

<%= svg icon, class: 'inline-block fill-current text-gray-500 relative leading-none min-w-[1rem] min-h-full ml-1 h-4' %>
<%= svg icon,
class: 'inline-block fill-current text-gray-500 relative leading-none min-w-[1rem] min-h-full ml-1 h-4',
data: {
tippy: :tooltip,
tippy_content: sort_tippy_content
}
%>
5 changes: 4 additions & 1 deletion app/views/avo/partials/_table_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@
class: class_names("flex-1 flex justify-between", text_classes),
'data-turbo-frame': params[:turbo_frame] do %>
<%= field.table_header_label %>
<%= render partial: 'avo/partials/sortable_component', locals: {field: field} %>
<%= render partial: 'avo/partials/sortable_component', locals: {
field: field,
sort_tippy_content: I18n.t("avo.sort_#{sort_direction || "reset"}")
} %>
<% end %>
<% else %>
<%= content_tag :div, class: text_classes, data: {sortable: false} do %>
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ ar:
select_item: تحديد العنصر
show_content: عرض المحتوى
sign_out: تسجيل الخروج
sort_asc: ترتيب تصاعدي
sort_desc: ترتيب تنازلي
sort_reset: إعادة تهيئة الترتيب
switch_to_view: التبديل إلى عرض %{view_type}
table_view: عرض الجدول
this_field_has_attachments_disabled: هذا الحقل لديه المرفقات معطلة.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ de:
select_item: Eintrag auswählen
show_content: Inhalt anzeigen
sign_out: Abmelden
sort_asc: Aufsteigend sortieren
sort_desc: Absteigend sortieren
sort_reset: Sortierung zurücksetzen
switch_to_view: Wechseln zur %{view_type}-Ansicht
table_view: Tabellenansicht
this_field_has_attachments_disabled: Für dieses Feld sind Anhänge deaktiviert.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ en:
select_item: Select item
show_content: Show content
sign_out: Sign out
sort_asc: Sort ascending
sort_desc: Sort descending
sort_reset: Reset sorting
switch_to_view: Switch to %{view_type} view
table_view: Table view
this_field_has_attachments_disabled: This field has attachments disabled.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ es:
select_item: Selecionar elemento
show_content: Mostrar contenido
sign_out: Salir
sort_asc: Ordenar de forma ascendente
sort_desc: Ordenar de forma descendente
sort_reset: Restablecer ordenación
switch_to_view: Cambiar a la vista %{view_type}
table_view: Vista en tabla
this_field_has_attachments_disabled: Este campo tiene los adjuntos deshabilitados.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ fr:
select_item: Sélectionnez un élément
show_content: Afficher le contenu
sign_out: Se déconnecter
sort_asc: Trier par ordre croissant
sort_desc: Trier par ordre décroissant
sort_reset: Réinitialiser le tri
switch_to_view: Passez à la vue %{view_type}
table_view: Vue table
this_field_has_attachments_disabled: Ce champ a les pièces jointes désactivées.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ it:
select_item: Seleziona elemento
show_content: Mostra contenuto
sign_out: Esci
sort_asc: Ordina in ordine crescente
sort_desc: Ordina in ordine decrescente
sort_reset: Reimposta ordinamento
switch_to_view: Passa a vista %{view_type}
table_view: Vista tabella
this_field_has_attachments_disabled: Gli allegati sono disabilitati per questo campo.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ ja:
select_item: アイテムを選択
show_content: 内容を表示
sign_out: サインアウト
sort_asc: 昇順で並べ替え
sort_desc: 降順で並べ替え
sort_reset: ソートをリセット
switch_to_view: "%{view_type}ビューに切り替える"
table_view: テーブルビュー
this_field_has_attachments_disabled: このフィールドには添付ファイルが無効になっています。
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.nb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ nb:
select_item: Velg
show_content: Vis innhold
sign_out: Logg ut
sort_asc: Sorter stigende
sort_desc: Sorter synkende
sort_reset: Tilbakestill sortering
switch_to_view: Bytt til %{view_type} vis
table_view: Tabell visning
this_field_has_attachments_disabled: Dette feltet har vedlegg deaktivert.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ nl:
select_item: Item selecteren
show_content: Inhoud tonen
sign_out: Afmelden
sort_asc: Oplopend sorteren
sort_desc: Aflopend sorteren
sort_reset: Sortering resetten
switch_to_view: Schakelen naar %{view_type}-weergave
table_view: Tabelweergave
this_field_has_attachments_disabled: Bijlagen zijn uitgeschakeld voor dit veld.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.nn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ nn:
select_item: Vel
show_content: Vis innhald
sign_out: Logg ut
sort_asc: Sorter stigande
sort_desc: Sorter synkende
sort_reset: Nullstill sortering
switch_to_view: Bytt til %{view_type} vis
table_view: Tabellvisning
this_field_has_attachments_disabled: Dette feltet har vedlegg deaktivert.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pl:
select_item: Wybierz element
show_content: Pokaż zawartość
sign_out: Wyloguj się
sort_asc: Sortuj rosnąco
sort_desc: Sortuj malejąco
sort_reset: Resetuj sortowanie
switch_to_view: Przełącz na widok %{view_type}
table_view: Widok tabelaryczny
this_field_has_attachments_disabled: Załączniki są wyłączone dla tego pola.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pt-BR:
select_item: Selecionar item
show_content: Mostrar conteúdo
sign_out: sair
sort_asc: Ordenar em ordem crescente
sort_desc: Ordenar em ordem decrescente
sort_reset: Redefinir ordenação
switch_to_view: Alterar para visão %{view_type}
table_view: Visualização em tabela
this_field_has_attachments_disabled: Este campo tem anexos desativados.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.pt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ pt:
select_item: Selecionar item
show_content: Mostrar conteúdo
sign_out: Terminar sessão
sort_asc: Ordenar em ordem crescente
sort_desc: Ordenar em ordem decrescente
sort_reset: Redefinir ordenação
switch_to_view: Alterar para visão %{view_type}
table_view: Visualização em tabela
this_field_has_attachments_disabled: Este campo tem anexos desativados.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.ro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ ro:
select_item: Selectează record
show_content: Arată conținutul
sign_out: Delogare
sort_asc: Sortare crescătoare
sort_desc: Sortare descrescătoare
sort_reset: Resetare sortare
switch_to_view: Comutați la vizualizarea %{view_type}
table_view: Vezi sub formă de tabel
this_field_has_attachments_disabled: Acest câmp are atașamente dezactivate.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ ru:
select_item: Выбрать элемент
show_content: Показать содержимое
sign_out: Выйти
sort_asc: Сортировать по возрастанию
sort_desc: Сортировать по убыванию
sort_reset: Сбросить сортировку
switch_to_view: Переключиться на вид %{view_type}
table_view: Таблица
this_field_has_attachments_disabled: Для этого поля прикрепления отключены.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ tr:
select_item: Öğe seç
show_content: İçeriği göster
sign_out: Çıkış yap
sort_asc: Artan sırala
sort_desc: Azalan sırala
sort_reset: Sıralamayı sıfırla
switch_to_view: "%{view_type} görünümüne kay"
table_view: Tablo görünümü
this_field_has_attachments_disabled: Bu alanın ekleri devre dışı bırakıldı.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.uk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ uk:
select_item: Вибрати елемент
show_content: Показати вміст
sign_out: Вийти
sort_asc: Rūšiuoti didėjančia tvarka
sort_desc: Rūšiuoti mažėjančia tvarka
sort_reset: Atstatyti rūšiavimą
switch_to_view: Перейти до виду %{view_type}
table_view: Таблиця
this_field_has_attachments_disabled: Прикріплення для цього поля вимкнено.
Expand Down
3 changes: 3 additions & 0 deletions lib/generators/avo/templates/locales/avo.zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ zh:
select_item: 选择项目
show_content: 显示内容
sign_out: 登出
sort_asc: 升序排序
sort_desc: 降序排序
sort_reset: 重置排序
switch_to_view: 切换到 %{view_type} 视图
table_view: 表格视图
this_field_has_attachments_disabled: 此字段已禁用附件。
Expand Down
22 changes: 22 additions & 0 deletions spec/system/avo/field_sorting_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require "rails_helper"

RSpec.feature "Field Sorting", type: :system do
let!(:project) { create :project }

describe "sortable field option" do
it "shows the next action as a title" do
visit avo.resources_projects_path

expect(page).not_to have_current_path(/sort_direction=/)

first('svg[data-tippy-content="Sort descending"]').click
expect(page).to have_current_path(/sort_direction=desc/)

first('svg[data-tippy-content="Sort ascending"]').click
expect(page).to have_current_path(/sort_direction=asc/)

first('svg[data-tippy-content="Reset sorting"]').click
expect(page).not_to have_current_path(/sort_direction=/)
end
end
end

0 comments on commit fe108af

Please sign in to comment.