bullet_train-themes-tailwind_css 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51f353d2908bc1a86c2dc5e354da335736b6919a726e79bad6a73036376885d6
4
- data.tar.gz: cbc3c0bf3366ec39b0a4c2a6eb7818d71e2bd601234b3548b4264943bc3752d6
3
+ metadata.gz: bcddcd3ebc08ff9776d4b1d9553dc1cb5f62904bf355ec4b1663f650977e0292
4
+ data.tar.gz: f5ba1d827b9e78b0688af5edd746b5a4c250fd38ac997a38a0f951bd51da6366
5
5
  SHA512:
6
- metadata.gz: 74a076120a33a30f705749c0850e055cdb7ee175395168121e1b2790c6e686a1a1ab6733289e73a94787c9b4412a150329fda3cf0722f659b3618dc6e6bcaf5d
7
- data.tar.gz: c6f4d1f875d35bdfee3e9d33ddbcaff44e43748f4c1179f37afd81c3bd71146d3fed821d79c2e70296fba848ff4ca71497da761c4870aadb84d905f253b2a1c9
6
+ metadata.gz: 116a5da2d2c67b31f99ff1efe045b7731784cd6a7a21d175d840f12b94ad1f8f548e920dcda23184b2dcfbe01a3657f05e4f5660b260f1542edb7c0c926eddc7
7
+ data.tar.gz: 7adf7638c5788afef2d18f54f1630379d42d843497fb0013e27dfbb7883ef387922d475327b29908c26f7b55b55c47b1e9947125f3c904f42ef536de0d354d43
@@ -1,43 +1,73 @@
1
1
  <%
2
+ stimulus_controller = 'fields--date'
3
+
2
4
  form ||= current_fields_form
3
5
  options ||= {}
4
- options[:id] ||= form.field_id(method)
6
+ user_tz = ActiveSupport::TimeZone.find_tzinfo(current_user.time_zone).name
7
+ team_tz = ActiveSupport::TimeZone.find_tzinfo(current_user.current_team.time_zone).name
8
+
9
+ # data options
10
+ data_options ||= {}
11
+ data_options[:id] ||= form.field_id(method)
12
+ data_options[:class] = "hidden"
13
+ data_options[:value] = form.object.send(method)&.in_time_zone(current_time_zone)&.iso8601
14
+ data_options = data_options.merge({ data: {"#{stimulus_controller}-target": 'field' }})
15
+
16
+ # localized display options
17
+ options[:id] ||= "#{form.field_id(method)}_display"
5
18
  options[:class] = "form-control single-daterange w-full border-slate-300 dark:bg-slate-800 dark:border-slate-900 #{options[:class]}".strip
6
- options[:value] = form.object.send(method)&.in_time_zone(current_team.time_zone)&.strftime(t('global.formats.date_and_time'))
7
- options = options.merge({ data: {'fields--date-target': 'field' }})
19
+ raw_value = form.object.send(method)&.in_time_zone(current_user.time_zone || current_team.time_zone || "UTC")
20
+ options[:value] = raw_value && I18n.l(raw_value, format: :date_and_time_field)
21
+ options = options.merge({ data: {"#{stimulus_controller}-target": 'displayField' }})
22
+
8
23
  other_options ||= {}
9
24
  %>
10
25
 
11
26
  <%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
12
27
  <% content_for :field do %>
13
- <div class="date-input relative" data-controller="fields--date" data-fields--date-include-time-value="true" data-fields--date-default-time-zones-value="<%= "[\"#{current_user.current_team.time_zone}\",\"#{current_user.time_zone}\"]" %>">
28
+ <div
29
+ class="date-input relative"
30
+ data-controller="<%=stimulus_controller%>"
31
+ data-<%= stimulus_controller %>-include-time-value="true"
32
+ data-<%= stimulus_controller %>-date-format-value="<%= I18n.t('date.formats.date_controller') %>"
33
+ data-<%= stimulus_controller %>-time-format-value="<%= I18n.t('time.formats.date_controller') %>"
34
+ data-<%= stimulus_controller %>-is-am-pm-value="<%= am_pm? %>"
35
+ data-<%= stimulus_controller %>-picker-locale-value="<%= I18n.t("daterangepicker").deep_transform_keys { |k| k.to_s.camelize(:lower) }.to_json %>"
36
+ data-<%= stimulus_controller %>-default-time-zones-value="<%= "[\"#{current_user.time_zone}\",\"#{current_user.current_team.time_zone}\"]" %>"
37
+ data-<%= stimulus_controller %>-current-time-zone-value="<%= current_time_zone %>"
38
+ >
14
39
  <%= form.text_field method, options %>
40
+ <%= form.text_field method, data_options %>
15
41
  <% unless options[:disabled] %>
16
42
  <button type="button" class="clear py-2 px-3 border border-transparent inline-flex items-center whitespace-nowrap absolute rounded-md top-1 md:top-0.5 right-0.5"
17
- data-fields--date-target="clearButton"
18
- data-action="fields--date#clearDate"
43
+ data-<%= stimulus_controller %>-target="clearButton"
44
+ data-action="<%=stimulus_controller%>#clearDate"
19
45
  >
20
46
  <i class="leading-4 text-lg ti ti-trash dark:text-blue-500"></i>
21
47
  </button>
22
48
  <% end %>
23
49
  <% if current_user.time_zone != current_user.current_team.time_zone %>
24
50
  <div class="mt-1.5 text-xs text-slate-500">
25
- <%= form.hidden_field "#{method}_time_zone".to_sym, value: current_user.current_team.time_zone, data: {'fields--date-target': 'timeZoneField'} %>
26
- <div data-fields--date-target="currentTimeZoneWrapper">
27
- <%= link_to current_user.current_team.time_zone, '#', class: 'button-secondary p-0', data: {action: 'fields--date#showTimeZoneButtons'} %>
51
+ <input class="hidden" data-<%=stimulus_controller%>-target="timeZoneField" value="<%= current_time_zone %>"></span>
52
+ <div data-<%= stimulus_controller %>-target="currentTimeZoneWrapper">
53
+ <%= link_to (current_user.time_zone || current_user.current_team.time_zone || "UTC"), '#', class: 'button-secondary p-0', data: {action: "#{stimulus_controller}#showTimeZoneButtons"} %>
28
54
  </div>
29
- <div class="space-x-1 hidden" data-fields--date-target="timeZoneButtons">
30
- <%= link_to '', '#', hidden: true, class: 'time-zone-button button-alternative button-smaller selected-option-time-zone-button hidden', data: {action: 'fields--date#setTimeZone', value: ''} %>
31
- <%= link_to current_user.current_team.time_zone, '#', class: 'time-zone-button button button-smaller', data: {action: 'fields--date#setTimeZone', value: current_user.current_team.time_zone} %>
32
- <%= link_to current_user.time_zone, '#', class: 'time-zone-button button-alternative button-smaller', data: {action: 'fields--date#setTimeZone', value: current_user.time_zone} %>
33
- <%= link_to t('global.buttons.other'), '#', class: 'button-alternative button-smaller', data: {action: 'fields--date#showTimeZoneSelectWrapper'} %>
34
- <%= link_to t('global.buttons.cancel'), '#', class: 'button-secondary button-smaller', data: {action: 'fields--date#resetTimeZoneUI'} %>
55
+ <div class="space-x-1 hidden" data-<%= stimulus_controller %>-target="timeZoneButtons">
56
+ <%= link_to '', '#', hidden: true, class: 'time-zone-button button-alternative button-smaller selected-option-time-zone-button hidden', data: {action: "#{stimulus_controller}#setTimeZone", value: ''} %>
57
+ <%= link_to current_user.current_team.time_zone, '#', class: 'time-zone-button button-alternative button-smaller', data: {action: "#{stimulus_controller}#setTimeZone", value: team_tz, label: current_user.current_team.time_zone } %>
58
+ <%= link_to current_user.time_zone, '#', class: 'time-zone-button button button-smaller', data: {action: "#{stimulus_controller}#setTimeZone", value: user_tz, label: current_user.time_zone } %>
59
+ <%= link_to t('global.buttons.other'), '#', class: 'button-alternative button-smaller', data: {action: "#{stimulus_controller}#showTimeZoneSelectWrapper"} %>
60
+ <%= link_to t('global.buttons.cancel'), '#', class: 'button-secondary button-smaller', data: {action: "#{stimulus_controller}#resetTimeZoneUI"} %>
35
61
  </div>
36
- <div class="hidden flex flex-row items-center mt-3 text-sm" data-fields--date-target="timeZoneSelectWrapper">
62
+ <div class="hidden flex flex-row items-center mt-3 text-sm" data-<%= stimulus_controller %>-target="timeZoneSelectWrapper">
37
63
  <div class="flex-grow">
38
- <%= select_tag :time_zone, options_from_collection_for_select(ActiveSupport::TimeZone.all, "name", "to_s", current_user.current_team.time_zone), {class: 'form-control select2'} %>
64
+ <%= select_tag :time_zone,
65
+ options_for_select(ActiveSupport::TimeZone.all.map{|tz| [tz.name.to_s, tz.tzinfo.name.to_s]}, [ user_tz || team_tz ]),
66
+ class: 'form-control select2',
67
+ data: { "#{stimulus_controller}-target": "timeZoneSelect", action: "#{stimulus_controller}#selectTimeZoneChange"}
68
+ %>
39
69
  </div>
40
- <%= link_to t('global.buttons.cancel'), '#', class: 'button-secondary ml-1.5', data: {action: 'fields--date#resetTimeZoneUI'} %>
70
+ <%= link_to t('global.buttons.cancel'), '#', class: 'button-secondary ml-1.5', data: {action: "#{stimulus_controller}#cancelSelect"} %>
41
71
  </div>
42
72
  </div>
43
73
  <% end %>
@@ -3,18 +3,36 @@ stimulus_controller = 'fields--date'
3
3
 
4
4
  form ||= current_fields_form
5
5
  options ||= {}
6
- options[:id] ||= form.field_id(method)
6
+
7
+ # data options
8
+ data_options ||= {}
9
+ data_options[:id] ||= form.field_id(method)
10
+ data_options[:class] = "hidden"
11
+ data_options[:value] = form.object.send(method)&.strftime("%Y-%m-%d")
12
+ data_options = data_options.merge({ data: {"#{stimulus_controller}-target": 'field' }})
13
+
14
+ # localized display options
15
+ options[:id] ||= "#{form.field_id(method)}_display"
7
16
  options[:class] = "form-control single-daterange w-full border-slate-300 dark:bg-slate-800 dark:border-slate-900 #{options[:class]}".strip
8
- options[:value] = form.object.send(method)&.strftime(t('global.formats.date'))
9
- options = options.merge({ data: {"#{stimulus_controller}-target": 'field' }})
17
+ options[:value] = form.object.send(method) && I18n.l(form.object.send(method), format: :date_field)
18
+ options = options.merge({ data: {"#{stimulus_controller}-target": 'displayField' }})
19
+
10
20
  other_options ||= {}
11
21
 
12
22
  %>
13
-
14
23
  <%= render 'shared/fields/field', form: form, method: method, options: options, other_options: other_options do %>
15
24
  <% content_for :field do %>
16
- <div class="date-input relative" data-controller="<%= stimulus_controller %>">
25
+ <div
26
+ class="date-input relative"
27
+ data-controller="<%= stimulus_controller %>"
28
+ data-<%= stimulus_controller %>-date-format-value="<%= I18n.t('date.formats.date_controller') %>"
29
+ data-<%= stimulus_controller %>-time-format-value="<%= I18n.t('time.formats.date_controller') %>"
30
+ data-<%= stimulus_controller %>-is-am-pm-value="<%= am_pm? %>"
31
+ data-<%= stimulus_controller %>-picker-locale-value="<%= I18n.t("daterangepicker").deep_transform_keys { |k| k.to_s.camelize(:lower) }.to_json %>"
32
+ data-<%= stimulus_controller %>-current-time-zone-value="<%= current_time_zone %>"
33
+ >
17
34
  <%= form.text_field method, options %>
35
+ <%= form.text_field method, data_options %>
18
36
  <% unless options[:disabled] %>
19
37
  <button type="button" class="clear py-2 px-3 border border-transparent inline-flex items-center whitespace-nowrap absolute rounded-md top-1 md:top-0.5 right-0.5"
20
38
  data-<%= stimulus_controller %>-target="clearButton"
@@ -1,7 +1,7 @@
1
1
  module BulletTrain
2
2
  module Themes
3
3
  module TailwindCss
4
- VERSION = "1.3.1"
4
+ VERSION = "1.3.2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-themes-tailwind_css
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver