diff --git a/bullet_train-themes/app/views/themes/base/attributes/_boolean.html.erb b/bullet_train-themes/app/views/themes/base/attributes/_boolean.html.erb index 61ffad672..c7a63fdba 100644 --- a/bullet_train-themes/app/views/themes/base/attributes/_boolean.html.erb +++ b/bullet_train-themes/app/views/themes/base/attributes/_boolean.html.erb @@ -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 %> diff --git a/bullet_train-themes/app/views/themes/base/attributes/_date.html.erb b/bullet_train-themes/app/views/themes/base/attributes/_date.html.erb index 1c431cbef..8380d9f6e 100644 --- a/bullet_train-themes/app/views/themes/base/attributes/_date.html.erb +++ b/bullet_train-themes/app/views/themes/base/attributes/_date.html.erb @@ -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 %> diff --git a/bullet_train-themes/app/views/themes/base/attributes/_date_and_time.html.erb b/bullet_train-themes/app/views/themes/base/attributes/_date_and_time.html.erb index 9fb0f7e43..5a399af2c 100644 --- a/bullet_train-themes/app/views/themes/base/attributes/_date_and_time.html.erb +++ b/bullet_train-themes/app/views/themes/base/attributes/_date_and_time.html.erb @@ -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 %> diff --git a/bullet_train-themes/app/views/themes/base/attributes/_days_ago.html.erb b/bullet_train-themes/app/views/themes/base/attributes/_days_ago.html.erb index 8ec6a54c7..20c8aa49b 100644 --- a/bullet_train-themes/app/views/themes/base/attributes/_days_ago.html.erb +++ b/bullet_train-themes/app/views/themes/base/attributes/_days_ago.html.erb @@ -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 %> diff --git a/bullet_train/config/locales/en/base.yml b/bullet_train/config/locales/en/base.yml index adccc93ce..1c0dafb7b 100644 --- a/bullet_train/config/locales/en/base.yml +++ b/bullet_train/config/locales/en/base.yml @@ -48,6 +48,7 @@ en: creator: Bullet Train, Inc. time_ago: "%{time} ago" never: Never + not_set: Not Set buttons: other: Other debug: Debug