Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better handling for empty values in some attributes #960

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
<% object ||= current_attributes_object %>
<% strategy ||= current_attributes_strategy || :none %>
<% url ||= nil %>
<% default_message = local_assigns[:default_message] || t("global.not_set") %>
<% display_when_blank = local_assigns[:display_when_blank] || false %>

<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<% unless object[attribute].nil? %>
<%= t("#{object.class.name.underscore.pluralize}.fields.#{attribute}.options.#{object.public_send(attribute)}") %>
<% if !object[attribute].nil? || display_when_blank %>
<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<% unless object[attribute].nil? %>
<%= t("#{object.class.name.underscore.pluralize}.fields.#{attribute}.options.#{object.public_send(attribute)}") %>
<% else %>
<%= default_message %>
<% end %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<% strategy ||= current_attributes_strategy || :none %>
<% url ||= nil %>
<% default_message = local_assigns[:default_message] || t('global.formats.timestamp_unavailable') %>
<% display_when_blank = local_assigns[:display_when_blank] || false %>

<% if object.public_send(attribute).present? %>
<% if object.public_send(attribute).present? || display_when_blank %>
<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<%= display_date(object.public_send(attribute), **local_assigns.slice(:format), **local_assigns.slice(:date_format)) %>
<% if object.public_send(attribute).present? %>
<%= display_date(object.public_send(attribute), **local_assigns.slice(:format), **local_assigns.slice(:date_format)) %>
<% else %>
<%= default_message %>
<% end %>
<% end %>
<% else %>
<%= default_message %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<% strategy ||= current_attributes_strategy || :none %>
<% url ||= nil %>
<% default_message = local_assigns[:default_message] || t('global.formats.timestamp_unavailable') %>
<% display_when_blank = local_assigns[:display_when_blank] || false %>

<% if object.public_send(attribute).present? %>
<% if object.public_send(attribute).present? || display_when_blank %>
<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<%= display_date_and_time(object.public_send(attribute), **local_assigns.slice(:format), **local_assigns.slice(:date_format), **local_assigns.slice(:time_format)) %>
<% if object.public_send(attribute).present? %>
<%= display_date_and_time(object.public_send(attribute), **local_assigns.slice(:format), **local_assigns.slice(:date_format), **local_assigns.slice(:time_format)) %>
<% else %>
<%= default_message %>
<% end %>
<% end %>
<% else %>
<%= default_message %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
<% strategy ||= current_attributes_strategy || :none %>
<% url ||= nil %>
<% default_message = local_assigns[:default_message] || t("global.never") %>
<% display_when_blank = local_assigns[:display_when_blank] || false %>

<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<% if object.public_send(attribute) %>
<%= t("global.time_ago", time: time_ago_in_words(object.send(attribute))) %>
<% else %>
<%= default_message %>
<% if object.public_send(attribute) || display_when_blank %>
<%= render 'shared/attributes/attribute', object: object, attribute: attribute, strategy: strategy, url: url do %>
<% if object.public_send(attribute).present? %>
<%= t("global.time_ago", time: time_ago_in_words(object.send(attribute))) %>
<% else %>
<%= default_message %>
<% end %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions bullet_train/config/locales/en/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ en:
creator: Bullet Train, Inc.
time_ago: "%{time} ago"
never: Never
not_set: Not Set
buttons:
other: Other
debug: Debug
Expand Down
Loading