<% stimulus_controller = 'fields--date' form ||= current_fields_form options ||= {} user_tz = ActiveSupport::TimeZone.find_tzinfo(current_user.time_zone).name current_team_time_zone = if current_user&.respond_to?(:current_team) current_team.time_zone else "UTC" end team_tz = ActiveSupport::TimeZone.find_tzinfo(current_team_time_zone)&.name # data options data_options ||= {} data_options[:id] ||= form.field_id(method) data_options[:class] = "hidden" data_options[:value] = form.object.send(method)&.in_time_zone(current_time_zone)&.iso8601 data_options = data_options.merge({ data: {"#{stimulus_controller}-target": 'field' }}) # localized display options options[:id] ||= "#{form.field_id(method)}_display" options[:class] = "form-control single-daterange w-full border-slate-300 dark:bg-slate-800 dark:border-slate-900 #{options[:class]}".strip raw_value = form.object.send(method)&.in_time_zone(current_user.time_zone || current_team_time_zone || "UTC") options[:value] = raw_value && I18n.l(raw_value, format: :date_and_time_field) options = options.merge({ data: {"#{stimulus_controller}-target": 'displayField' }}) other_options ||= {} %> <%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %> <% content_for :field do %>
-include-time-value="true" data-<%= stimulus_controller %>-date-format-value="<%= I18n.t('date.formats.date_controller') %>" data-<%= stimulus_controller %>-time-format-value="<%= I18n.t('time.formats.date_controller') %>" data-<%= stimulus_controller %>-is-am-pm-value="<%= am_pm? %>" data-<%= stimulus_controller %>-picker-locale-value="<%= I18n.t("daterangepicker").deep_transform_keys { |k| k.to_s.camelize(:lower) }.to_json %>" data-<%= stimulus_controller %>-default-time-zones-value="<%= "[\"#{current_user.time_zone}\",\"#{current_team_time_zone}\"]" %>" data-<%= stimulus_controller %>-current-time-zone-value="<%= current_time_zone %>" > <%= form.text_field method, options %> <%= form.text_field method, data_options %> <% unless options[:disabled] %> <% end %> <% if current_user.time_zone != current_team_time_zone %>
-target="timeZoneField" value="<%= current_time_zone %>">
-target="currentTimeZoneWrapper"> <%= link_to (current_user.time_zone || current_team_time_zone || "UTC"), '#', class: 'button-secondary p-0', data: {action: "#{stimulus_controller}#showTimeZoneButtons"} %>
<% end %>
<% end %> <% end %>