Skip to content

Commit

Permalink
fix: prep code for ruby 3.0 for index view (#290)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Brunetti <[email protected]>
  • Loading branch information
adrianthedev and francescob authored Mar 31, 2021
1 parent a40675f commit 7fbd1cd
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% end %>
<%= a_link "/avo/resources/#{@resource.model.model_name.route_key}/#{@resource.model.id
}/active_storage_attachments/#{@id}/#{@file.id}", color: :red, variant: :outlined, size: :xs, class: 'text-center', 'data-turbo-frame': 'destroy_attachment_form', data: { confirm: t('avo.are_you_sure')} do %>
<%= helpers.svg 'trash' %> <span class="hidden lg:block lg:flex-1"><%= t('avo.delete_file', { item: @file.filename }) %></span>
<%= helpers.svg 'trash' %> <span class="hidden lg:block lg:flex-1"><%= t 'avo.delete_file', item: @file.filename %></span>
<% end %>
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% end %>
<%= a_link "/avo/resources/#{@resource.model.model_name.route_key}/#{@resource.model.id
}/active_storage_attachments/#{@id}/#{@file.id}", color: :red, variant: :outlined, size: :md, class: '', 'data-turbo-frame': 'destroy_attachment_form', data: { confirm: t('avo.are_you_sure')} do %>
<%= helpers.svg 'trash' %> <%= t('avo.delete_file', { item: @file.filename }) %>
<%= helpers.svg 'trash' %> <%= t 'avo.delete_file', item: @file.filename %>
<% end %>
</div>
<% else %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
rounded: @field.rounded,
link_to_resource: @field.link_to_resource,
link: helpers.resource_path(@resource.model),
title: t('avo.view_item', { item: @resource.name}).humanize
title: t('avo.view_item', item: @resource.name).humanize
)
%>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
path = helpers.resource_path(@resource.model)
end
%>
<% link_to_if (@field.link_to_resource or Avo.configuration.id_links_to_resource), @field.value, path, title: t('avo.view_item', { item: @resource.name}).humanize %>
<% link_to_if (@field.link_to_resource or Avo.configuration.id_links_to_resource), @field.value, path, title: t('avo.view_item', item: @resource.name).humanize %>
<% end %>
12 changes: 6 additions & 6 deletions app/components/avo/index/resource_controls_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% if can_view? %>
<%= link_to helpers.svg('eye', class: 'text-gray-400 h-6 hover:text-gray-600'),
show_path,
title: t('avo.view_item', { item: @resource.model.model_name.name.downcase }).capitalize,
title: t('avo.view_item', item: @resource.model.model_name.name.downcase ).capitalize,
data: {
control: :show,
'tippy': 'tooltip',
Expand All @@ -13,7 +13,7 @@
<% if can_edit? %>
<%= link_to helpers.svg('edit', class: 'text-gray-400 h-6 hover:text-gray-600'),
edit_path,
title: t('avo.edit_item', { item: @resource.model.model_name.name.downcase }).capitalize,
title: t('avo.edit_item', item: @resource.model.model_name.name.downcase ).capitalize,
data: {
control: :edit,
'resource-id': @resource.model.id,
Expand All @@ -27,10 +27,10 @@
'data-turbo-frame': params[:turbo_frame]
} do |form| %>
<%= form.button helpers.svg('trash-sm', class: 'text-gray-400 h-6 hover:text-gray-600'),
title: t('avo.detach_item', { item: @resource.model.model_name.name.downcase }).capitalize,
title: t('avo.detach_item', item: @resource.model.model_name.name.downcase).capitalize,
type: :submit,
data: {
confirm: t('avo.are_you_sure_detach_item', { item: @resource.model.model_name.name.downcase }),
confirm: t('avo.are_you_sure_detach_item', item: @resource.model.model_name.name.downcase),
control: :detach,
'resource-id': @resource.model.id,
'tippy': 'tooltip',
Expand All @@ -47,10 +47,10 @@
'data-turbo-frame': params[:turbo_frame]
} do |form| %>
<%= form.button helpers.svg('trash', class: 'text-gray-400 h-6 hover:text-gray-600'),
title: t('avo.delete_item', { item: @resource.model.model_name.name.downcase }).capitalize,
title: t('avo.delete_item', item: @resource.model.model_name.name.downcase ).capitalize,
type: :submit,
data: {
confirm: t('avo.are_you_sure', { item: @resource.model.model_name.name.downcase }),
confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase ),
control: :destroy,
'resource-id': @resource.model.id,
'tippy': 'tooltip',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= panel(title: @field.id.capitalize) do |c| %>
<% c.with :tools do %>
<%= a_link helpers.resource_attach_path(@resource.model.model_name.route_key, @resource.model.id, @field.id), color: 'indigo', 'data-turbo-frame': 'attach_modal' do %>
<%= svg 'view-grid-add' %> <%= t('avo.attach_item', { item: @field.id }).capitalize %>
<%= svg 'view-grid-add' %> <%= t('avo.attach_item', item: @field.id).capitalize %>
<% end %>
<% end %>

Expand Down
6 changes: 3 additions & 3 deletions app/components/avo/views/resource_index_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@

<% if can_create? %>
<%= a_link create_path do %>
<%= svg 'plus' %> <%= t('avo.create_new_item', { item: @resource.model_class.model_name.human.downcase }) %>
<%= svg 'plus' %> <%= t('avo.create_new_item', item: @resource.model_class.model_name.human.downcase ) %>
<% end %>
<% end %>

<% if can_detach? %>
<%= a_link detach_path, color: 'indigo', method: :delete, data: { confirm: "Are you sure you want to detach this #{@resource.singular_name}." } do %>
<%= svg 'trash' %> <%= t('avo.detach_item', { item: @resource.singular_name }).capitalize %>
<%= svg 'trash' %> <%= t('avo.detach_item', item: @resource.singular_name).capitalize %>
<% end %>
<% end %>

<% if can_attach? %>
<%= a_link attach_path, color: 'indigo', 'data-turbo-frame': 'attach_modal' do %>
<%= svg 'view-grid-add' %> <%= t('avo.attach_item', { item: @resource.singular_name }).capitalize %>
<%= svg 'view-grid-add' %> <%= t('avo.attach_item', item: @resource.singular_name).capitalize %>
<% end %>
<% end %>
<% end %>
Expand Down
6 changes: 3 additions & 3 deletions app/components/avo/views/resource_show_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<% if @reflection.present? && @resource.model.present? %>
<%= a_link detach_path, color: 'indigo', method: :delete, data: { confirm: "Are you sure you want to detach this #{@resource.singular_name}." } do %>
<%= svg 'trash' %> <%= t('avo.detach_item', { item: @resource.singular_name }).capitalize %>
<%= svg 'trash' %> <%= t('avo.detach_item', item: @resource.singular_name).capitalize %>
<% end %>
<% else %>
<%= a_link back_path do %>
Expand All @@ -19,12 +19,12 @@

<% if @resource.authorization.authorize_action(:destroy, raise_exception: false) %>
<%= form_with url: helpers.resource_path(@resource.model), method: :delete, html: { 'data-turbo-frame': params[:turbo_frame] } do |form| %>
<%= a_button title: t('avo.delete_item', { item: @resource.model.model_name.name.downcase }).capitalize,
<%= a_button title: t('avo.delete_item', item: @resource.model.model_name.name.downcase).capitalize,
color: 'red',
variant: 'outlined',
type: :submit,
data: {
confirm: t('avo.are_you_sure', { item: @resource.model.model_name.name.downcase }),
confirm: t('avo.are_you_sure', item: @resource.model.model_name.name.downcase),
control: :destroy,
'resource-id': @resource.model.id,
'tippy': 'tooltip',
Expand Down
2 changes: 1 addition & 1 deletion app/views/avo/partials/_empty_state.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%
classes = 'absolute inset-auto left-1/2 top-1/2 transform -translate-x-1/2 -translate-y-1/2'
translation_tag = params[:related_name].present? ? 'avo.no_related_item_found' : 'avo.no_item_found'
label = t translation_tag, { item: resource_name }
label = t translation_tag, item: resource_name
%>
<div class="relative flex-1 py-12">
<div class="relative block text-gray-300 h-64 w-full">
Expand Down
4 changes: 2 additions & 2 deletions app/views/avo/partials/_view_toggle_button.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
translation_key = 'avo.table_view'
end
%>
<%= a_link params.permit!.merge(view_type: new_view_type), color: :blue, 'data-turbo-frame': turbo_frame, title: t('avo.switch_to_view', { view_type: new_view_type }), 'data-tippy': 'tooltip' do %>
<%= svg new_icon %> <%= t(translation_key, { item: @resource.model_class.model_name.human.downcase }) %>
<%= a_link params.permit!.merge(view_type: new_view_type), color: :blue, 'data-turbo-frame': turbo_frame, title: t('avo.switch_to_view', view_type: new_view_type), 'data-tippy': 'tooltip' do %>
<%= svg new_icon %> <%= t translation_key, item: @resource.model_class.model_name.human.downcase %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/avo/relations/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
} do |form| %>
<%= render Avo::ModalComponent.new do |c| %>
<% c.with :heading do %>
<%= t('avo.choose_item', { item: params[:related_name].downcase }) %>
<%= t 'avo.choose_item', item: params[:related_name].downcase %>
<% end %>

<div class="flex-1 flex items-center justify-center px-8 text-lg mt-8 mb-12">
Expand Down
2 changes: 1 addition & 1 deletion spec/system/avo/code_field_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,6 @@ def fill_in_editor_field(text)

def have_editor_display(options)
editor_display_locator = ".CodeMirror-code"
have_css(editor_display_locator, options)
have_css(editor_display_locator, **options)
end
end

0 comments on commit 7fbd1cd

Please sign in to comment.