recurrence_ui 0.2.2 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +104 -82
- data/app/assets/stylesheets/recurrence_ui/components.css +1 -1
- data/app/components/recurrence_ui/recurrence_picker_component.html.erb +96 -169
- data/app/components/recurrence_ui/recurrence_picker_component.rb +76 -32
- data/app/javascript/recurrence_ui/index.js +1 -1
- data/app/javascript/recurrence_ui/recurrence_ui_controller.js +24 -7
- data/app/models/concerns/recurrence_ui/has_recurrence.rb +113 -155
- data/app/services/recurrence_ui/recurrence_formatter_service.rb +1 -2
- data/app/views/recurrence_ui/_duration.html.erb +40 -0
- data/app/views/recurrence_ui/_end_at.html.erb +14 -0
- data/app/views/recurrence_ui/_multiple_rules.html.erb +0 -0
- data/app/views/recurrence_ui/_single_rule.html.erb +36 -0
- data/app/views/recurrence_ui/_start_at.html.erb +21 -0
- data/app/views/recurrence_ui/_termination.html.erb +1 -1
- data/app/views/recurrence_ui/_time_zone.html.erb +9 -0
- data/config/importmap.rb +0 -3
- data/config/locales/recurrence_ui.be.yml +6 -6
- data/config/locales/recurrence_ui.en.yml +3 -3
- data/config/locales/recurrence_ui.ru.yml +4 -4
- data/config/locales/recurrence_ui.uk.yml +7 -7
- data/lib/generators/recurrence_ui/install/install_generator.rb +62 -11
- data/lib/recurrence_ui/configuration.rb +80 -11
- data/lib/recurrence_ui/engine.rb +6 -6
- data/lib/recurrence_ui/version.rb +1 -1
- metadata +8 -2
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<%# app/views/recurrence_ui/_duration.html.erb %>
|
|
2
|
+
<div class="flex flex-nowrap items-center gap-2" data-<%= identifier %>-target="durationContainer">
|
|
3
|
+
<%# Дни %>
|
|
4
|
+
<div class="flex items-center space-x-1 shrink-0">
|
|
5
|
+
<%= form.number_field :form_duration_days,
|
|
6
|
+
value: rec_ui.initial_form_duration_days,
|
|
7
|
+
min: 0,
|
|
8
|
+
disabled: (rec_ui.initial_form_duration_mode != :duration && rec_ui.show_end_date_time),
|
|
9
|
+
class: "rui-input w-16 text-center disabled:opacity-50 disabled:cursor-not-allowed",
|
|
10
|
+
data: { "#{identifier}_target": "daysField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
11
|
+
<span class="rui-duration-unit select-none"><%= t('recurrence_ui.duration.form_days') %></span>
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<%# Часы %>
|
|
16
|
+
<div class="flex items-center space-x-1 shrink-0">
|
|
17
|
+
<%= form.number_field :form_duration_hours,
|
|
18
|
+
value: rec_ui.initial_form_duration_hours,
|
|
19
|
+
min: 0,
|
|
20
|
+
max: 23,
|
|
21
|
+
disabled: (rec_ui.initial_form_duration_mode != :duration && rec_ui.show_end_date_time),
|
|
22
|
+
class: "rui-input w-16 text-center disabled:opacity-50 disabled:cursor-not-allowed",
|
|
23
|
+
data: { "#{identifier}_target": "hoursField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
24
|
+
<span class="rui-duration-unit select-none"><%= t('recurrence_ui.duration.form_hours') %></span>
|
|
25
|
+
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<%# Минуты %>
|
|
29
|
+
<div class="flex items-center space-x-1 shrink-0">
|
|
30
|
+
<%= form.number_field :form_duration_minutes,
|
|
31
|
+
value: rec_ui.initial_form_duration_minutes,
|
|
32
|
+
min: 0,
|
|
33
|
+
max: 59,
|
|
34
|
+
disabled: (rec_ui.initial_form_duration_mode != :duration && rec_ui.show_end_date_time),
|
|
35
|
+
class: "rui-input w-16 text-center disabled:opacity-50 disabled:cursor-not-allowed",
|
|
36
|
+
data: { "#{identifier}_target": "minutesField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
37
|
+
<span class="rui-duration-unit select-none"><%= t('recurrence_ui.duration.form_minutes') %></span>
|
|
38
|
+
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%# app/views/recurrence_ui/_end_at.html.erb %>
|
|
2
|
+
<div class="flex items-center space-x-2">
|
|
3
|
+
<%= form.date_field :form_end_date,
|
|
4
|
+
value: form.object.end_time_in_zone(:event)&.to_date || Date.current,
|
|
5
|
+
disabled: (rec_ui.initial_form_duration_mode != :end_at && rec_ui.show_duration),
|
|
6
|
+
class: "rui-input w-36 shrink-0 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
7
|
+
data: { "#{identifier}_target": "endDateField" } %>
|
|
8
|
+
|
|
9
|
+
<%= form.time_field :form_end_time,
|
|
10
|
+
value: form.object.end_time_in_zone(:event)&.strftime('%H:%M') || '09:00',
|
|
11
|
+
disabled: (rec_ui.initial_form_duration_mode != :end_at && rec_ui.show_duration),
|
|
12
|
+
class: ["rui-input w-24 shrink-0 disabled:opacity-50 disabled:cursor-not-allowed", ("rui-input-error" if form.object.errors[:form_end_time].any?)],
|
|
13
|
+
data: { "#{identifier}_target": "endTimeField" } %>
|
|
14
|
+
</div>
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<%# app/views/recurrence_ui/_single_rule.html.erb %>
|
|
2
|
+
<div class="space-y-4" data-<%= identifier %>-target="ruleCard">
|
|
3
|
+
|
|
4
|
+
<%# Frequency Selector Block %>
|
|
5
|
+
<div>
|
|
6
|
+
|
|
7
|
+
<%# Живое превью правила сверху селекта %>
|
|
8
|
+
<div class="mb-2">
|
|
9
|
+
<span data-item="cardSummary" class="rui-inline-label">
|
|
10
|
+
<%= t('recurrence_ui.labels.new_rule', default: 'New rule') %>
|
|
11
|
+
</span>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<select data-item="ruleType"
|
|
15
|
+
data-action="change-><%= identifier %>#toggleCardFields change-><%= identifier %>#onCardInputChanged"
|
|
16
|
+
class="rui-select w-full">
|
|
17
|
+
<% rec_ui.rule_options.each do |label, value| %>
|
|
18
|
+
<option value="<%= value %>" <%= "selected" if rec_ui.current_rule_type == value %>><%= label %></option>
|
|
19
|
+
<% end %>
|
|
20
|
+
</select>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<%# Dynamic Specific Rule Fields (используем data-item="specificFields", как в мультиправилах) %>
|
|
24
|
+
<% rec_ui.rule_options.map(&:last).each do |rule| %>
|
|
25
|
+
<div data-item="specificFields" data-rule="<%= rule %>" class="hidden space-y-3">
|
|
26
|
+
<%= render "recurrence_ui/#{rule}", form: form, identifier: identifier, days_for_ui: rec_ui.days_for_ui, rec_ui: rec_ui %>
|
|
27
|
+
</div>
|
|
28
|
+
<% end %>
|
|
29
|
+
|
|
30
|
+
<%# Termination Settings Section %>
|
|
31
|
+
<% if rec_ui.show_termination %>
|
|
32
|
+
<div class="pt-2 border-t border-[var(--rui-border-color)]">
|
|
33
|
+
<%= render "recurrence_ui/termination", form: form, identifier: identifier, rec_ui: rec_ui %>
|
|
34
|
+
</div>
|
|
35
|
+
<% end %>
|
|
36
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%# app/views/recurrence_ui/_start_at.html.erb %>
|
|
2
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
|
3
|
+
|
|
4
|
+
<!-- 1. Дата и время начала (всегда на одной строке, не тянутся) -->
|
|
5
|
+
<div>
|
|
6
|
+
<%= form.label :start_at, t('recurrence_ui.labels.start_at'), class: "rui-label block" %>
|
|
7
|
+
<div class="flex items-center space-x-2 mt-1">
|
|
8
|
+
<%= form.date_field :form_start_date,
|
|
9
|
+
value: form.object.start_time_in_zone(:event)&.to_date || Date.current,
|
|
10
|
+
class: "rui-input w-36 shrink-0",
|
|
11
|
+
data: { "#{identifier}_target": "startDate",
|
|
12
|
+
action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
13
|
+
<%= form.time_field :form_start_time,
|
|
14
|
+
value: form.object.start_time_in_zone(:event)&.strftime('%H:%M') || RecurrenceUi::RecurrencePickerComponent::DEFAULT_START_TIME.strftime('%H:%M'),
|
|
15
|
+
class: "rui-input w-24 shrink-0",
|
|
16
|
+
data: { "#{identifier}_target": "startTime",
|
|
17
|
+
action: "change->#{identifier}#calculateEndDateFromDuration" }
|
|
18
|
+
%>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</div>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_termination.html.erb %>
|
|
2
2
|
<%# Termination / End Condition Section for Recurrence Rules %>
|
|
3
|
-
<div
|
|
3
|
+
<div data-item="termination">
|
|
4
4
|
<label class="rui-label mb-2">
|
|
5
5
|
<%= t("recurrence_ui.labels.termination", default: "Ends") %>
|
|
6
6
|
</label>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%# Time zone #%>
|
|
2
|
+
<div>
|
|
3
|
+
<%= form.label :time_zone, t('recurrence_ui.labels.time_zone'), class: "rui-label block" %>
|
|
4
|
+
<%= form.time_zone_select :time_zone,
|
|
5
|
+
ActiveSupport::TimeZone.all,
|
|
6
|
+
{ default: rec_ui.record.public_send(rec_ui.time_zone_field).presence || Time.zone.name },
|
|
7
|
+
{ class: "rui-input rui-select cursor-pointer w-full mt-1" }
|
|
8
|
+
%>
|
|
9
|
+
</div>
|
data/config/importmap.rb
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
# config/importmap.rb in the recurrence_ui gem
|
|
2
2
|
pin "recurrence_ui", to: "recurrence_ui/index.js"
|
|
3
3
|
pin "recurrence_ui/recurrence_ui_controller", to: "recurrence_ui/recurrence_ui_controller.js"
|
|
4
|
-
|
|
5
|
-
# Явно указываем Importmap, где лежат файлы гема на диске
|
|
6
|
-
pin_all_from File.expand_path("../app/javascript/recurrence_ui", __dir__), under: "recurrence_ui"
|
|
@@ -64,9 +64,9 @@ be:
|
|
|
64
64
|
- снежань
|
|
65
65
|
days_of_month_fmt: "%{list} ліку"
|
|
66
66
|
duration:
|
|
67
|
-
form_days: "
|
|
68
|
-
form_hours: "
|
|
69
|
-
form_minutes: "
|
|
67
|
+
form_days: "д."
|
|
68
|
+
form_hours: "г."
|
|
69
|
+
form_minutes: "хв."
|
|
70
70
|
days:
|
|
71
71
|
few: "%{count} дні"
|
|
72
72
|
many: "%{count} дзен"
|
|
@@ -105,7 +105,7 @@ be:
|
|
|
105
105
|
choose_month: Выберыце месяц
|
|
106
106
|
day: дзень
|
|
107
107
|
duration: Працягласць
|
|
108
|
-
end_at: Час заканчэння
|
|
108
|
+
end_at: Час заканчэння
|
|
109
109
|
every: Кожны
|
|
110
110
|
exceptions: Выключэнні
|
|
111
111
|
frequency: Чакласць
|
|
@@ -115,8 +115,8 @@ be:
|
|
|
115
115
|
rdates: Дадатковыя даты
|
|
116
116
|
recurrence: Повторение
|
|
117
117
|
select_dates: Выбраць даты
|
|
118
|
-
start_at:
|
|
119
|
-
termination: Завяршэнне
|
|
118
|
+
start_at: Пачатак
|
|
119
|
+
termination: Завяршэнне паўтарэння
|
|
120
120
|
time_zone: Часовой пояс
|
|
121
121
|
times: раз
|
|
122
122
|
week: тыдзень
|
|
@@ -62,9 +62,9 @@ en:
|
|
|
62
62
|
- December
|
|
63
63
|
days_of_month_fmt: the %{list}
|
|
64
64
|
duration:
|
|
65
|
-
form_days: "
|
|
66
|
-
form_hours: "
|
|
67
|
-
form_minutes: "
|
|
65
|
+
form_days: "d."
|
|
66
|
+
form_hours: "h."
|
|
67
|
+
form_minutes: "m."
|
|
68
68
|
days:
|
|
69
69
|
one: "%{count} day"
|
|
70
70
|
other: "%{count} days"
|
|
@@ -64,9 +64,9 @@ ru:
|
|
|
64
64
|
- декабрь
|
|
65
65
|
days_of_month_fmt: "%{list} числа"
|
|
66
66
|
duration:
|
|
67
|
-
form_days: "
|
|
68
|
-
form_hours: "
|
|
69
|
-
form_minutes: "
|
|
67
|
+
form_days: "д."
|
|
68
|
+
form_hours: "ч."
|
|
69
|
+
form_minutes: "м."
|
|
70
70
|
days:
|
|
71
71
|
few: "%{count} дня"
|
|
72
72
|
many: "%{count} дней"
|
|
@@ -116,7 +116,7 @@ ru:
|
|
|
116
116
|
recurrence: Повторение
|
|
117
117
|
select_dates: Выбрать даты
|
|
118
118
|
start_at: Начало
|
|
119
|
-
termination: Завершение
|
|
119
|
+
termination: Завершение повторений
|
|
120
120
|
time_zone: Часовой пояс
|
|
121
121
|
times: раз
|
|
122
122
|
week: неделю
|
|
@@ -64,9 +64,9 @@ uk:
|
|
|
64
64
|
- грудень
|
|
65
65
|
days_of_month_fmt: "%{list} числа"
|
|
66
66
|
duration:
|
|
67
|
-
form_days: "
|
|
68
|
-
form_hours: "
|
|
69
|
-
form_minutes: "
|
|
67
|
+
form_days: "д."
|
|
68
|
+
form_hours: "г."
|
|
69
|
+
form_minutes: "хв."
|
|
70
70
|
days:
|
|
71
71
|
few: "%{count} дні"
|
|
72
72
|
many: "%{count} днів"
|
|
@@ -104,8 +104,8 @@ uk:
|
|
|
104
104
|
labels:
|
|
105
105
|
choose_month: Оберіть місяць
|
|
106
106
|
day: день
|
|
107
|
-
duration: Тривалість
|
|
108
|
-
end_at: Час завершення
|
|
107
|
+
duration: Тривалість
|
|
108
|
+
end_at: Час завершення
|
|
109
109
|
every: Кожен
|
|
110
110
|
exceptions: Винятки
|
|
111
111
|
frequency: Частота
|
|
@@ -115,8 +115,8 @@ uk:
|
|
|
115
115
|
rdates: Додаткові дати
|
|
116
116
|
recurrence: Повторение
|
|
117
117
|
select_dates: Обрати дати
|
|
118
|
-
start_at:
|
|
119
|
-
termination: Завершення
|
|
118
|
+
start_at: Початок
|
|
119
|
+
termination: Завершення повторення
|
|
120
120
|
time_zone: Часовий пояс
|
|
121
121
|
times: разів
|
|
122
122
|
week: тиждень
|
|
@@ -1,28 +1,79 @@
|
|
|
1
|
-
# recurrence_ui/lib/generators/recurrence_ui/install/install_generator.rb
|
|
2
1
|
module RecurrenceUi
|
|
3
2
|
module Generators
|
|
4
3
|
class InstallGenerator < Rails::Generators::Base
|
|
5
4
|
source_root File.expand_path("templates", __dir__)
|
|
6
5
|
|
|
7
|
-
desc "Installs RecurrenceUi
|
|
6
|
+
desc "Installs RecurrenceUi importmap, JS controller registration, and Tailwind CSS styles"
|
|
7
|
+
|
|
8
|
+
def add_importmap_pin
|
|
9
|
+
importmap_file = "config/importmap.rb"
|
|
10
|
+
if File.exist?(importmap_file)
|
|
11
|
+
pin_code = "\npin \"recurrence_ui\", to: \"recurrence_ui/index.js\"\n"
|
|
12
|
+
if File.read(importmap_file).include?("recurrence_ui")
|
|
13
|
+
say "RecurrenceUi pin already exists in #{importmap_file}", :blue
|
|
14
|
+
else
|
|
15
|
+
append_to_file importmap_file, pin_code
|
|
16
|
+
say "Added recurrence_ui pin to #{importmap_file}", :green
|
|
17
|
+
end
|
|
18
|
+
else
|
|
19
|
+
say "Could not find #{importmap_file}. Importmap configuration skipped.", :yellow
|
|
20
|
+
end
|
|
21
|
+
end
|
|
8
22
|
|
|
9
23
|
def register_controller
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
app_js_paths = [
|
|
25
|
+
Rails.root.join("app/javascript/application.js"),
|
|
26
|
+
Rails.root.join("app/javascript/packs/application.js")
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
target_js = app_js_paths.find { |path| File.exist?(path) }
|
|
30
|
+
|
|
31
|
+
if target_js
|
|
32
|
+
content = File.read(target_js)
|
|
33
|
+
|
|
34
|
+
if content.include?("recurrence_ui")
|
|
35
|
+
say "RecurrenceUi is already registered in #{target_js.relative_path_from(Rails.root)}", :blue
|
|
36
|
+
else
|
|
37
|
+
append_to_file target_js, <<~JS
|
|
15
38
|
|
|
16
39
|
// Register RecurrenceUi Stimulus controller
|
|
17
40
|
import { registerRecurrenceUiController } from "recurrence_ui"
|
|
18
|
-
|
|
41
|
+
if (typeof window.Stimulus !== "undefined") {
|
|
42
|
+
registerRecurrenceUiController(window.Stimulus)
|
|
43
|
+
}
|
|
19
44
|
JS
|
|
20
|
-
say "Added RecurrenceUi registration to
|
|
45
|
+
say "Added RecurrenceUi registration to #{target_js.relative_path_from(Rails.root)}", :green
|
|
46
|
+
end
|
|
47
|
+
else
|
|
48
|
+
say "Could not find application.js. Please register RecurrenceUi manually.", :red
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def register_styles
|
|
53
|
+
tailwind_css_paths = [
|
|
54
|
+
Rails.root.join("app/assets/tailwind/application.css"),
|
|
55
|
+
Rails.root.join("app/assets/stylesheets/application.tailwind.css"),
|
|
56
|
+
Rails.root.join("app/assets/stylesheets/application.css")
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
target_css = tailwind_css_paths.find { |path| File.exist?(path) }
|
|
60
|
+
|
|
61
|
+
if target_css
|
|
62
|
+
content = File.read(target_css)
|
|
63
|
+
import_line = '@import "recurrence_ui/application.css";'
|
|
64
|
+
|
|
65
|
+
if content.include?(import_line)
|
|
66
|
+
say "RecurrenceUi styles import already exists in #{target_css.relative_path_from(Rails.root)}", :blue
|
|
21
67
|
else
|
|
22
|
-
|
|
68
|
+
if content.include?('@import "tailwindcss";')
|
|
69
|
+
inject_into_file target_css, "\n#{import_line}", after: '@import "tailwindcss";'
|
|
70
|
+
else
|
|
71
|
+
prepend_to_file target_css, "#{import_line}\n"
|
|
72
|
+
end
|
|
73
|
+
say "Added RecurrenceUi styles import to #{target_css.relative_path_from(Rails.root)}", :green
|
|
23
74
|
end
|
|
24
75
|
else
|
|
25
|
-
say "
|
|
76
|
+
say "Tailwind CSS file not found. Please add `@import \"recurrence_ui/application.css\";` manually.", :yellow
|
|
26
77
|
end
|
|
27
78
|
end
|
|
28
79
|
end
|
|
@@ -5,8 +5,10 @@ module RecurrenceUi
|
|
|
5
5
|
SUPPORTED_LOCALES = %w[en ru ja uk be].freeze # Locales for which yml files are available in the gem
|
|
6
6
|
DEFAULT_LOCALE = 'en'.freeze
|
|
7
7
|
DEFAULT_TIME_ZONE = 'UTC'.freeze
|
|
8
|
+
DEFAULT_START_TIME = '09:00'.freeze # Default start time if not specified
|
|
8
9
|
DEFAULT_WEEK_START = 0
|
|
9
10
|
DEFAULT_DURATION = 0 # Default duration in seconds if not specified
|
|
11
|
+
DEFAULT_END_TIME = '17:00'.freeze # Default end time if not specified
|
|
10
12
|
ALL_RULE_TYPES = %w[
|
|
11
13
|
never
|
|
12
14
|
daily
|
|
@@ -17,31 +19,51 @@ module RecurrenceUi
|
|
|
17
19
|
yearly_by_weekday
|
|
18
20
|
].freeze
|
|
19
21
|
|
|
20
|
-
attr_accessor :enabled_rule_types,
|
|
22
|
+
attr_accessor :enabled_rule_types, #all rule types that showing in select box in the UI, if not specified - all types will be shown
|
|
21
23
|
:locale,
|
|
22
24
|
:time_zone,
|
|
23
|
-
:week_start,
|
|
25
|
+
:week_start, # 0 for Sunday, 1 for Monday
|
|
26
|
+
:start_time,
|
|
27
|
+
:end_time,
|
|
28
|
+
:duration, # default duration in seconds if not specified
|
|
24
29
|
:supported_locales,
|
|
25
|
-
:theme_mode,
|
|
30
|
+
:theme_mode,
|
|
31
|
+
# default values for the fields in the UI and in DB
|
|
26
32
|
:default_recurring_rules_field,
|
|
27
|
-
|
|
28
|
-
:
|
|
29
|
-
:
|
|
30
|
-
:
|
|
33
|
+
# UI display options
|
|
34
|
+
:allow_multiple_rules, #show multiple rules in the UI if false - you can only have one rule at a time
|
|
35
|
+
:show_duration, # show duration field in the UI
|
|
36
|
+
:show_start_date_time, # show start time field in the UI
|
|
37
|
+
:show_end_date_time, # show end time (for one occurrence) field in the UI
|
|
38
|
+
:show_exceptions, # show exception dates field in the UI
|
|
39
|
+
:show_rdates, # show additional date field in the UI
|
|
40
|
+
:show_termination, # show termination field in the UI (end date or count of occurrences)
|
|
41
|
+
:show_time_zone # show time zone field in the UI
|
|
42
|
+
|
|
31
43
|
|
|
32
44
|
def initialize
|
|
33
45
|
@locale = nil
|
|
34
46
|
@time_zone = nil
|
|
35
47
|
@week_start = nil
|
|
36
48
|
@duration = nil
|
|
49
|
+
@start_time = nil
|
|
50
|
+
@end_time = nil
|
|
37
51
|
@theme_mode = :auto # Example: :auto (default), :light (light only), :dark (dark only)
|
|
38
52
|
@supported_locales = SUPPORTED_LOCALES
|
|
39
53
|
@enabled_rule_types = ALL_RULE_TYPES.dup
|
|
40
54
|
@default_recurring_rules_field = :recurring_rules
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# UI display options
|
|
59
|
+
@allow_multiple_rules = true
|
|
60
|
+
@show_duration = true
|
|
61
|
+
@show_start_date_time = true
|
|
62
|
+
@show_end_date_time = true
|
|
63
|
+
@show_exceptions = true
|
|
64
|
+
@show_rdates = true
|
|
65
|
+
@show_termination = true
|
|
66
|
+
@show_time_zone = true
|
|
45
67
|
end
|
|
46
68
|
|
|
47
69
|
def resolved_locale(requested = nil)
|
|
@@ -96,7 +118,54 @@ module RecurrenceUi
|
|
|
96
118
|
valid_types = candidate.select { |t| ALL_RULE_TYPES.include?(t) }
|
|
97
119
|
valid_types.presence || ALL_RULE_TYPES
|
|
98
120
|
end
|
|
121
|
+
# Методы для резолва дефолтных значений длительности и времени старта
|
|
122
|
+
def resolved_duration(passed = nil)
|
|
123
|
+
passed.present? ? passed : (@duration.presence || DEFAULT_DURATION)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def resolved_start_time(passed = nil)
|
|
127
|
+
# Если передано явно — используем его, иначе берем из конфига @start_time, либо захардкоженный дефолт
|
|
128
|
+
passed.presence || @start_time.presence || DEFAULT_START_TIME
|
|
129
|
+
end
|
|
130
|
+
def resolved_end_time(passed = nil)
|
|
131
|
+
passed.presence || @end_time.presence || DEFAULT_END_TIME
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Methods for resolving boolean display options with default values
|
|
135
|
+
def resolved_allow_multiple_rules(passed = nil)
|
|
136
|
+
passed.nil? ? @allow_multiple_rules : !!passed
|
|
137
|
+
end
|
|
138
|
+
def resolved_show_duration(passed = nil)
|
|
139
|
+
passed.nil? ? @show_duration : !!passed
|
|
140
|
+
end
|
|
141
|
+
def resolved_show_start_date_time(passed = nil)
|
|
142
|
+
passed.nil? ? @show_start_date_time : !!passed
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def resolved_show_end_date_time(passed = nil)
|
|
146
|
+
passed.nil? ? @show_end_date_time : !!passed
|
|
147
|
+
end
|
|
148
|
+
def resolved_show_exceptions(passed = nil)
|
|
149
|
+
passed.nil? ? @show_exceptions : !!passed
|
|
150
|
+
end
|
|
151
|
+
def resolved_show_rdates(passed = nil)
|
|
152
|
+
passed.nil? ? @show_rdates : !!passed
|
|
153
|
+
end
|
|
154
|
+
def resolved_show_termination(passed = nil)
|
|
155
|
+
passed.nil? ? @show_termination : !!passed
|
|
156
|
+
end
|
|
157
|
+
def resolved_show_time_zone(passed = nil)
|
|
158
|
+
passed.nil? ? @show_time_zone : !!passed
|
|
159
|
+
end
|
|
160
|
+
class << self
|
|
161
|
+
def configuration
|
|
162
|
+
@configuration ||= Configuration.new
|
|
163
|
+
end
|
|
99
164
|
|
|
165
|
+
def configure
|
|
166
|
+
yield(configuration)
|
|
167
|
+
end
|
|
168
|
+
end
|
|
100
169
|
private
|
|
101
170
|
# Logs a warning in development mode if an unsupported locale is received
|
|
102
171
|
def log_unsupported_locale_warning(locale)
|
data/lib/recurrence_ui/engine.rb
CHANGED
|
@@ -6,11 +6,11 @@ module RecurrenceUi
|
|
|
6
6
|
isolate_namespace RecurrenceUi
|
|
7
7
|
|
|
8
8
|
# 1. Add importmap support for the gem
|
|
9
|
-
initializer "recurrence_ui.importmap", before: "importmap" do |app|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
9
|
+
#initializer "recurrence_ui.importmap", before: "importmap" do |app|
|
|
10
|
+
# if app.config.respond_to?(:importmap)
|
|
11
|
+
# app.config.importmap.paths << Engine.root.join("config/importmap.rb")
|
|
12
|
+
# end
|
|
13
|
+
#end
|
|
14
14
|
|
|
15
15
|
# 2. Assets (только стили и картинки, если нужны, т.к. JS обслуживает Importmap)
|
|
16
16
|
initializer "recurrence_ui.assets" do |app|
|
|
@@ -29,4 +29,4 @@ module RecurrenceUi
|
|
|
29
29
|
ApplicationController.helper(RecurrenceUi::Engine.helpers)
|
|
30
30
|
end
|
|
31
31
|
end
|
|
32
|
-
end
|
|
32
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: recurrence_ui
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Katerina German
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -148,14 +148,20 @@ files:
|
|
|
148
148
|
- app/services/recurrence_ui/recurrence_formatter_service.rb
|
|
149
149
|
- app/views/layouts/recurrence_ui/application.html.erb
|
|
150
150
|
- app/views/recurrence_ui/_daily.html.erb
|
|
151
|
+
- app/views/recurrence_ui/_duration.html.erb
|
|
152
|
+
- app/views/recurrence_ui/_end_at.html.erb
|
|
151
153
|
- app/views/recurrence_ui/_exceptions.html.erb
|
|
152
154
|
- app/views/recurrence_ui/_footer_actions.html.erb
|
|
153
155
|
- app/views/recurrence_ui/_monthly_by_day_of_month.html.erb
|
|
154
156
|
- app/views/recurrence_ui/_monthly_by_weekday.html.erb
|
|
157
|
+
- app/views/recurrence_ui/_multiple_rules.html.erb
|
|
155
158
|
- app/views/recurrence_ui/_rdates.html.erb
|
|
156
159
|
- app/views/recurrence_ui/_rule_card.html.erb
|
|
160
|
+
- app/views/recurrence_ui/_single_rule.html.erb
|
|
161
|
+
- app/views/recurrence_ui/_start_at.html.erb
|
|
157
162
|
- app/views/recurrence_ui/_summary_link.html.erb
|
|
158
163
|
- app/views/recurrence_ui/_termination.html.erb
|
|
164
|
+
- app/views/recurrence_ui/_time_zone.html.erb
|
|
159
165
|
- app/views/recurrence_ui/_weekly.html.erb
|
|
160
166
|
- app/views/recurrence_ui/_yearly_by_day_of_month.html.erb
|
|
161
167
|
- app/views/recurrence_ui/_yearly_by_weekday.html.erb
|