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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20647bab22cceca506089a2396bd2b3105a1cac2595d8fd17834e60db04fc862
4
- data.tar.gz: 1c0f8adca5ab3cf2196e7bef7e5b3819b8ac263e80e9f99104b483e574595585
3
+ metadata.gz: '069d35c9479d4f10916502bc7e13e13db0b26a758b3ff8b41619d632918f78c2'
4
+ data.tar.gz: f88fdf5a43cbbd18858f53ba8eb1592de132cc9ab5d711e38375322f4c3fdada
5
5
  SHA512:
6
- metadata.gz: 19b24fe598939465aab719d3080017e0f11fed41a8fc9cd3ab70a967656b1bc45629f7278daf5d27bc1655d53522da125cd912302c77a14def6f00b289714114
7
- data.tar.gz: d21393711d67f282b4431abcbed85b6eca87d2a55b1d91f7b3ab8415c9d54a1f8ddf0d7a9791cc6fdf4a960f64d052124f0a40134cdddfe14f5030642b53645d
6
+ metadata.gz: 72ac32f1763a7ef149adcc46356ed811e8dbd2c2b6dcd8e469631e902765f039ca170b2d7a183d8620a3df2d8dffb9f71f7eca1459794700e15c0d1469cd4c50
7
+ data.tar.gz: d80d3ddd4307f2a0a45d59e03c915b91a76d24c68956b2ecd91966faa6ec46eea106cac44d8d302e9ec7aa3cefc31d305ef3935b5ec5eb6a786b59b66d685664
data/README.md CHANGED
@@ -7,7 +7,7 @@ Built on top of [ice_cube](https://github.com/ice-cube-ruby/ice_cube), it provid
7
7
  [![Gem Version](https://img.shields.io/gem/v/recurrence_ui.svg)](https://rubygems.org/gems/recurrence_ui)
8
8
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
9
9
 
10
- ## ✨ Features
10
+ ## Features
11
11
 
12
12
  - **Form integration:** Ready-to-use components for adding recurrence rule editors to model creation and editing forms.
13
13
  - **Human-readable descriptions:** Converts `ice_cube` recurrence rules into readable descriptions.
@@ -18,16 +18,16 @@ Built on top of [ice_cube](https://github.com/ice-cube-ruby/ice_cube), it provid
18
18
  - **Light and dark themes:** Customize the appearance to match your application.
19
19
  - **Flexible model attribute mapping:** Use custom database column names for recurrence rules, time zones, durations, and event start and end times.
20
20
 
21
- ## 📦 Requirements
21
+ ## Requirements
22
22
 
23
23
  Recurrence UI depends on the following components:
24
24
 
25
- - **Ruby on Rails** >= 7.0
25
+ - **Ruby on Rails** >= 8.0
26
26
  - **[ice_cube](https://github.com/ice-cube-ruby/ice_cube)** ~> 0.16 — recurrence rule management.
27
27
  - **[ViewComponent](https://viewcomponent.org/)** >= 2.0 — reusable, encapsulated UI components.
28
- - **Tailwind CSS** — styling, integrated through `tailwindcss-rails` or your host application's Tailwind CSS setup.
28
+ - **Tailwind CSS ** >= 4.0 — styling, integrated through `tailwindcss-rails` or your host application's Tailwind CSS setup.
29
29
 
30
- ## 🚀 Installation
30
+ ## Installation and configuration
31
31
 
32
32
  Add the gem to your application's `Gemfile`:
33
33
 
@@ -40,41 +40,85 @@ Then install the dependencies:
40
40
  ```bash
41
41
  bundle install
42
42
  ```
43
+ ### Automatic Installation
43
44
 
44
- ### Importing styles
45
-
46
- For Tailwind CSS v4, add the following imports to your application's stylesheet, such as `app/assets/stylesheets/application.tailwind.css`:
47
-
48
- ```css
49
- @import "tailwindcss";
50
- @import "recurrence_ui/application.css";
45
+ Run the installation generator to automatically create the initializer configuration and wire up the JavaScript components:
46
+ ```bash
47
+ bin/rails g recurrence_ui:install
51
48
  ```
49
+ ### Manual Setup (Alternative)
52
50
 
53
- Make sure the stylesheet is included in your application's asset pipeline and that your Tailwind CSS setup is compatible with the gem's styles.
54
-
55
- ## ⚙️ Configuration
56
-
57
- Create an initializer at `config/initializers/recurrence_ui.rb` to configure the default settings:
58
-
51
+ If you prefer to configure the gem manually:
52
+ 1. Create an initializer at config/initializers/recurrence_ui.rb:
59
53
  ```ruby
54
+ require "recurrence_ui"
60
55
  RecurrenceUi.configure do |config|
56
+ # default locale, time_zone and week_start for all RecurrencePickerComponents in app
57
+ # Could be redefined in RecurrencePickerComponent
61
58
  config.locale = :en
62
59
  config.time_zone = "UTC"
63
60
  config.week_start = 1
61
+ config.start_time = "06:00" # Default start time for events (if no start_time is passed to the component or column does not configured in model)
62
+ config.end_time = "16:00" # Default end time for events (if no end_time is passed to the component or column does not configured in model)
63
+ config.duration = 3600 # Default duration in seconds for events (if no duration is passed to the component or column does not configured in model)
64
+
65
+ #---- This is default UI options for all RecurrencePickerComponents in app that could be redefined in RecurrencePickerComponent --- #
66
+ config.enabled_rule_types = %w[
67
+ never
68
+ daily
69
+ weekly
70
+ monthly_by_day_of_month
71
+ monthly_by_weekday
72
+ yearly_by_day_of_month
73
+ yearly_by_weekday
74
+ ]
75
+ config.allow_multiple_rules = true # Show only one rule(false) or multyple rules (true)
76
+ config.show_duration = true # Show/Hide duration fields in form
77
+ config.show_start_date_time = true # Show/Hide start date and time fields in form
78
+ config.show_time_zone = true # Show/Hide time zone in form
79
+ config.show_end_date_time = false # Show/Hide end date and time fields in form
80
+ config.show_exceptions = true # Show/Hide exceptions fields in form
81
+ config.show_rdates = true # Show/Hide additional dates fields in form
82
+ config.show_termination = true # Show/Hide termination fields in form
64
83
  end
65
84
  ```
66
-
67
85
  Available settings:
68
86
 
69
- - `locale` — the default interface locale, such as `:en`, `:ru`, `:uk`, `:be`, or `:ja`.
70
- - `time_zone` — the default time zone.
71
- - `week_start` — the first day of the week: `0` for Sunday or `1` for Monday.
87
+ - locale — the default interface locale, such as :en, :ru, :uk, :be, or :ja.
88
+ - week_start — the first day of the week: 0 for Sunday or 1 for Monday.
89
+ - time_zone — if record dosen't have this field uses: ActiveSupport::TimeZone[zone_name] || Time.zone || ActiveSupport::TimeZone[Rails.application.config.time_zone]
90
+ - start_time — if record dosen't have this field uses DEFAULT_START_TIME = '09:00'.freeze from gem configuration.
91
+ - duration — if record dosen't have this field uses DEFAULT_DURATION = 0 from gem configuration.
92
+ - end_time — if record dosen't have this field uses DEFAULT_END_TIME = '17:00'.freeze
93
+ - allow_multiple_rules — show only one rule (false) or multiple rules (true).
94
+ - show_duration — show/hide duration fields in the form.
95
+ - show_start_date_time — show/hide start date and time fields in the form.
96
+ - show_time_zone — show/hide time zone in the form.
97
+ - show_end_date_time — show/hide end date and time fields in the form.
98
+ - show_exceptions — show/hide exceptions fields in the form.
99
+ - show_rdates — show/hide additional dates fields in the form.
100
+ - show_termination — show/hide termination fields in the form.
101
+
102
+
103
+ 2. Import JavaScript: Add the following import to your application's main JavaScript file (app/javascript/application.js):
104
+ ```javascript
105
+ import "recurrence_ui"
106
+ ```
107
+ 3. Import styles: For Tailwind CSS v4, add the style imports to your stylesheet (e.g., app/assets/stylesheets/application.tailwind.css):
108
+
109
+ ```css
110
+ @import "tailwindcss";
111
+ @import "recurrence_ui/application.css";
112
+ ```
113
+
114
+ Make sure the stylesheet is included in your application's asset pipeline and that your Tailwind CSS setup is compatible with the gem's styles.
72
115
 
73
- The values above are examples. Adjust them to match your application's requirements.
74
116
 
75
- ## 🛠 Model Integration
117
+ ### Model Integration
76
118
 
77
119
  Include `RecurrenceUi::HasRecurrence` in your model and configure the mapping between the gem's attributes and your database columns.
120
+ If you dont configure some fields for your model, they will not connect to your base.
121
+ But some of them could uses default value if not configured. Could be redefined for all app in config/initializers/recurrence_ui.rb such as time_zone, start_time, duration and end_time.
78
122
 
79
123
  For example:
80
124
 
@@ -82,16 +126,14 @@ For example:
82
126
  class Event < ApplicationRecord
83
127
  include RecurrenceUi::HasRecurrence
84
128
 
85
- has_recurrence rules: :recurring_rules,
86
- start_time: :start_at,
87
- end_time: :end_at,
88
- time_zone: :time_zone
129
+ has_recurrence rules: :recurring_rules, # This column is needed for gem,
130
+ start_time: :start_at, # others - optional. Format:
131
+ end_time: :end_at, # name_in_gem: :name_in_your_db_schema
132
+ time_zone: :time_zone, # for default values see Configuration
89
133
  duration: :duration
90
134
  end
91
135
  ```
92
136
 
93
- ### Using custom attribute names
94
-
95
137
  You can configure different attribute names for different models:
96
138
 
97
139
  ```ruby
@@ -105,67 +147,47 @@ end
105
147
 
106
148
  Use the attribute names that match your application's database schema and the attributes supported by your model integration.
107
149
 
108
- ## 🎨 View Integration
109
-
110
- Render the recurrence editor inside a Rails form using `RecurrenceUi::RecurrencePickerComponent`:
111
-
112
- ```erb
113
- <%= form_with model: @event do |form| %>
114
- <%= render RecurrenceUi::RecurrencePickerComponent.new(
115
- form: form,
116
- record: @event,
117
- locale: params[:locale],
118
- time_zone: params[:time_zone],
119
- week_start: params[:week_start]
120
- ) %>
121
-
122
- <%= form.submit "Save" %>
123
- <% end %>
124
- ```
125
-
126
- The `locale`, `time_zone`, and `week_start` options can be supplied dynamically when needed. If omitted, the component can use the applicable defaults provided by your integration.
127
-
128
150
  Add required params to controller of your Model.
129
151
  ```erb
130
152
  def event_params
131
153
  params.require(:event).permit(
132
- #other params
154
+ #other params of your model
133
155
  *Event.recurrence_permitted_params # add this with name of your Model
134
156
  )
135
157
  end
136
158
  ```
137
- Configure gem:
159
+
160
+
161
+ ### View Integration
162
+
163
+ Render the recurrence editor inside a Rails form using `RecurrenceUi::RecurrencePickerComponent`:
164
+
138
165
  ```erb
139
- # config/initializers/recurrence_ui.rb
140
- require "recurrence_ui"
141
- RecurrenceUi.configure do |config|
142
- config.locale = :en # Default locale for all components of the gem (if no locale is passed to the component)
143
- config.time_zone = "Asia/Tokyo" # Default time zone for all components of the gem (if no time_zone is passed to the component)
144
- config.week_start = 1 # Week starts on Monday
166
+ <%= form_with model: @event do |form| %>
167
+ <%= render RecurrenceUi::RecurrencePickerComponent.new(
168
+ form: form,
169
+ record: @event,
170
+ allow_multiple_rules: true,
171
+ show_duration: true,
172
+ show_start_date_time: true,
173
+ show_time_zone: true,
174
+ show_end_date_time: true,
175
+ show_exceptions: true,
176
+ show_rdates: true,
177
+ show_termination: true,
178
+ locale: params[:locale],
179
+ time_zone: params[:time_zone],
180
+ week_start: params[:week_start]
181
+ )
182
+ %>
145
183
 
146
- # Configuration for the enabled rule types in the UI:
147
- config.enabled_rule_types = %w[
148
- never
149
- weekly
150
- daily
151
- monthly_by_day_of_month
152
- ]
153
- # All other options will be filtered out, and the order will be preserved as specified above.
154
- # config.enabled_rule_types = %w[
155
- # never
156
- # daily
157
- # weekly
158
- # monthly_by_day_of_month
159
- # monthly_by_weekday
160
- # yearly_by_day_of_month
161
- # yearly_by_weekday
162
- # ]
163
- end
184
+ <%= form.submit "Save" %>
185
+ <% end %>
164
186
  ```
165
187
 
188
+ The `locale`, `time_zone`, and `week_start` options can be supplied dynamically when needed. If omitted, the component can use the applicable defaults provided by your integration.
166
189
 
167
-
168
- ## 🌍 Internationalization
190
+ ## Internationalization
169
191
 
170
192
  Recurrence UI currently supports the following locales:
171
193
 
@@ -187,7 +209,7 @@ For example, to add German (`de`):
187
209
 
188
210
  Make sure the translation file follows the structure expected by the gem's existing locale files.
189
211
 
190
- ## 🌓 Themes and Customization
212
+ ## Themes and Customization
191
213
 
192
214
  Recurrence UI uses CSS custom properties (design tokens) to control its color palette.
193
215
 
@@ -210,14 +232,14 @@ For example:
210
232
 
211
233
  Use the CSS variables supported by the gem to customize the interface. The example above illustrates the approach; available tokens and theme selectors depend on the styles provided by your version of Recurrence UI.
212
234
 
213
- ## 🚀 Example Application
235
+ ## Example Application
214
236
 
215
237
  If you want to see `recurrence_ui` in action, check out the [rails-recurrence-ui-dummy](https://github.com/assoly/rails-recurrence-ui-dummy) repository. It demonstrates a fully configured Ruby on Rails application featuring:
216
238
  - Database models with `HasRecurrence` integration.
217
239
  - Form views using `ViewComponent` and Tailwind CSS.
218
240
  - Initializer and internationalization (i18n) setup.
219
241
 
220
- ## 🤝 Contributing
242
+ ## Contributing
221
243
 
222
244
  Contributions, bug reports, and feature requests are welcome!
223
245
 
@@ -240,7 +262,7 @@ To get started:
240
262
 
241
263
  Please make sure your changes are covered by tests where appropriate.
242
264
 
243
- ## 🧪 Testing
265
+ ## Testing
244
266
 
245
267
  *Note: The test suite is currently under active development. Contributions are very welcome!*
246
268
 
@@ -220,7 +220,7 @@
220
220
 
221
221
  /* Edit Icon wrapper */
222
222
  .rui-summary-icon {
223
- @apply opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-gray-400 dark:text-gray-500;
223
+ @apply opacity-0 group-hover:opacity-100 transition-opacity duration-200 text-[var(--app-text-muted)] dark:text-gray-500;
224
224
  }
225
225
  /* Rule Accordion Card Container */
226
226
  .rui-card-container {
@@ -7,132 +7,65 @@
7
7
  class="rui-container"
8
8
  data-rui-theme="<%= RecurrenceUi.configuration.theme_mode %>">
9
9
 
10
- <%# 1. Секция полей времени, окончания и часового пояса %>
11
- <div class="space-y-4 pb-4 border-b border-[var(--rui-border-color)]">
12
- <div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
13
-
14
- <!-- 1. Дата и время начала (всегда на одной строке, не тянутся) -->
15
- <div>
16
- <%= form.label :start_at, t('recurrence_ui.labels.start_at'), class: "rui-label block" %>
17
- <div class="flex items-center space-x-2 mt-1">
18
- <%= form.date_field :form_start_date,
19
- value: initial_start_at&.to_date || Date.current,
20
- class: "rui-input w-36 shrink-0",
21
- data: { "#{identifier}_target": "startDate", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
22
- <%= form.time_field :form_start_time,
23
- value: initial_start_at&.strftime('%H:%M') || '09:00',
24
- class: "rui-input w-24 shrink-0",
25
- data: { "#{identifier}_target": "startTime", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
26
- </div>
10
+ <%# 1. Секция полей времени начала и часового пояса %>
11
+ <div class="flex flex-wrap gap-4 my-4">
12
+ <% if show_start_date_time? %>
13
+ <div class="flex-1 min-w-[280px] p-2">
14
+ <%= render "recurrence_ui/start_at", form: form, identifier: identifier, rec_ui: self %>
27
15
  </div>
16
+ <% end %>
28
17
 
29
- <!-- Часовой пояс -->
30
- <div>
31
- <%= form.label :time_zone, t('recurrence_ui.labels.time_zone'), class: "rui-label block" %>
32
- <%= form.time_zone_select :time_zone,
33
- ActiveSupport::TimeZone.all,
34
- { default: record.public_send(time_zone_field).presence || Time.zone.name },
35
- { class: "rui-input rui-select cursor-pointer w-full mt-1" } %>
18
+ <% if show_time_zone? %>
19
+ <div class="flex-1 min-w-[280px] p-2" >
20
+ <%= render "recurrence_ui/time_zone", form: form, identifier: identifier, rec_ui: self %>
36
21
  </div>
37
-
38
- </div>
39
- </div>
40
-
41
- <!-- Блок выбора: Длительность или Окончание -->
42
- <div class="grid grid-cols-1 md:grid-cols-2 gap-4 my-4">
43
-
44
- <!-- Вариант 4.1: Длительность -->
45
- <label class="flex items-start space-x-3 p-2 rounded-lg transition-colors cursor-pointer hover:bg-[var(--rui-hover-bg-soft)]">
46
- <%= form.radio_button :form_duration_mode, :duration,
47
- checked: (initial_form_duration_mode == :duration),
48
- class: "mt-1 shrink-0",
49
- data: { "#{identifier}_target": "modeDuration", action: "change->#{identifier}#toggleDurationEndMode" } %>
50
-
51
- <div class="flex-1 min-w-0">
52
- <span class="rui-label font-medium select-none">
53
- <%= t('recurrence_ui.labels.duration') %>
54
- </span>
55
-
56
- <div class="flex flex-nowrap items-start gap-3 mt-2"
57
- data-<%= identifier %>-target="durationContainer">
58
-
59
- <%# Дни %>
60
- <div class="flex flex-col items-center gap-1 shrink-0"
61
- onclick="event.stopPropagation()">
62
- <span class="rui-duration-unit">
63
- <%= t('recurrence_ui.duration.form_days') %>
64
- </span>
65
-
66
- <%= form.number_field :form_duration_days,
67
- value: initial_form_duration_days,
68
- min: 0,
69
- class: "rui-input w-16 text-center",
70
- data: { "#{identifier}_target": "daysField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
71
- </div>
72
-
73
- <%# Часы %>
74
- <div class="flex flex-col items-center gap-1 shrink-0"
75
- onclick="event.stopPropagation()">
76
- <span class="rui-duration-unit">
77
- <%= t('recurrence_ui.duration.form_hours') %>
78
- </span>
79
-
80
- <%= form.number_field :form_duration_hours,
81
- value: initial_form_duration_hours,
82
- min: 0,
83
- max: 23,
84
- class: "rui-input w-16 text-center",
85
- data: { "#{identifier}_target": "hoursField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
86
- </div>
87
-
88
- <%# Минуты %>
89
- <div class="flex flex-col items-center gap-1 shrink-0"
90
- onclick="event.stopPropagation()">
91
- <span class="rui-duration-unit">
92
- <%= t('recurrence_ui.duration.form_minutes') %>
93
- </span>
94
-
95
- <%= form.number_field :form_duration_minutes,
96
- value: initial_form_duration_minutes,
97
- min: 0,
98
- max: 59,
99
- class: "rui-input w-16 text-center",
100
- data: { "#{identifier}_target": "minutesField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
101
- </div>
102
-
103
- </div>
104
- </div>
105
- </label>
106
-
107
- <!-- Вариант 4.2: Дата и время окончания -->
108
- <label class="flex items-start space-x-3 p-2 rounded-lg transition-colors cursor-pointer hover:bg-[var(--rui-hover-bg-soft)]">
109
- <%= form.radio_button :form_duration_mode, :end_at,
110
- checked: (initial_form_duration_mode == :end_at),
111
- class: "mt-1 shrink-0",
112
- data: { "#{identifier}_target": "modeEnd", action: "change->#{identifier}#toggleDurationEndMode" } %>
113
-
114
- <div class="flex-1 min-w-0">
115
- <span class="rui-label"><%= t('recurrence_ui.labels.end_at') %></span>
22
+ <% end %>
116
23
 
117
- <!-- Поля даты и времени окончания -->
118
- <div class="flex items-center space-x-2 mt-1" onclick="event.stopPropagation()">
119
- <%= form.date_field :form_end_date,
120
- value: initial_end_at&.to_date || Date.current,
121
- class: "rui-input w-36 shrink-0 disabled:opacity-50 disabled:--rui-input-disabled-bg disabled:cursor-not-allowed",
122
- disabled: (initial_form_duration_mode != :end_at),
123
- data: { "#{identifier}_target": "endDateField"} %>
124
- <%= form.time_field :form_end_time,
125
- value: initial_end_at&.strftime('%H:%M') || '09:00',
126
- class: ["rui-input w-24 shrink-0 disabled:opacity-50 disabled:--rui-input-disabled-bg disabled:cursor-not-allowed", ("rui-input-error" if record.errors[:form_end_time].any?)],
127
- disabled: (initial_form_duration_mode != :end_at),
128
- data: { "#{identifier}_target": "endTimeField" } %>
129
- </div>
130
- </div>
131
- </label>
132
-
133
- </div>
24
+ <%# 2. Блок выбора: Длительность и/или Окончание %>
25
+ <% if show_duration? && show_end_date_time? %>
26
+ <div class="flex flex-wrap gap-4 my-4">
27
+
28
+ <!-- Карточка Длительности -->
29
+ <label class="flex-1 min-w-[280px] flex items-start space-x-3 p-2 rounded-lg transition-colors cursor-pointer hover:bg-[var(--rui-hover-bg-soft)]">
30
+ <%= form.radio_button :form_duration_mode, :duration,
31
+ checked: (initial_form_duration_mode == :duration),
32
+ class: "mt-1 shrink-0",
33
+ data: { "#{identifier}_target": "modeDuration", action: "change->#{identifier}#toggleDurationEndMode" } %>
34
+ <div class="flex-1 min-w-0">
35
+ <span class="rui-label font-medium select-none"><%= t('recurrence_ui.labels.duration') %></span>
36
+ <div class="mt-1" onclick="event.stopPropagation()">
37
+ <%= render "recurrence_ui/duration", form: form, identifier: identifier, rec_ui: self %>
38
+ </div>
39
+ </div>
40
+ </label>
134
41
 
135
- <!-- 4. При показе саммари: только заголовок Повторение и саммари под ним -->
42
+ <!-- Карточка Окончания -->
43
+ <label class="flex-1 min-w-[280px] flex items-start space-x-3 p-2 rounded-lg transition-colors cursor-pointer hover:bg-[var(--rui-hover-bg-soft)]">
44
+ <%= form.radio_button :form_duration_mode, :end_at,
45
+ checked: (initial_form_duration_mode == :end_at),
46
+ class: "mt-1 shrink-0",
47
+ data: { "#{identifier}_target": "modeEnd", action: "change->#{identifier}#toggleDurationEndMode" } %>
48
+ <div class="flex-1 min-w-0">
49
+ <span class="rui-label font-medium select-none"><%= t('recurrence_ui.labels.end_at') %></span>
50
+ <div class="mt-1" onclick="event.stopPropagation()">
51
+ <%= render "recurrence_ui/end_at", form: form, identifier: identifier, rec_ui: self %>
52
+ </div>
53
+ </div>
54
+ </label>
55
+ </div>
56
+ <% elsif show_duration? %>
57
+ <div class="flex-1 min-w-[280px] p-2">
58
+ <span class="rui-label font-medium select-none block mb-1"><%= t('recurrence_ui.labels.duration') %></span>
59
+ <%= render "recurrence_ui/duration", form: form, identifier: identifier, rec_ui: self %>
60
+ </div>
61
+ <% elsif show_end_date_time? %>
62
+ <div class="flex-1 min-w-[280px] p-2">
63
+ <span class="rui-label font-medium select-none block mb-1"><%= t('recurrence_ui.labels.end_at') %></span>
64
+ <%= render "recurrence_ui/end_at", form: form, identifier: identifier, rec_ui: self %>
65
+ </div>
66
+ <% end %>
67
+ </div>
68
+ <!-- 3. Саммари -->
136
69
  <div data-<%= identifier %>-target="displayMode" class="space-y-1">
137
70
  <div class="rui-panel-header">
138
71
  <span class="rui-label">
@@ -144,10 +77,8 @@
144
77
  </div>
145
78
  </div>
146
79
 
147
- <!-- 5. Режим редактирования: заголовок Повторение + кнопка кода напротив, все поля под ними -->
80
+ <!-- Режим редактирования -->
148
81
  <div data-<%= identifier %>-target="editMode" class="hidden space-y-3 pt-2">
149
-
150
- <!-- Шапка с кнопкой кода справа напротив заголовка Повторение -->
151
82
  <div class="rui-panel-header flex items-center justify-between">
152
83
  <span class="rui-header-title">
153
84
  <%= t('recurrence_ui.labels.recurrence') %>
@@ -160,75 +91,71 @@
160
91
  </button>
161
92
  </div>
162
93
 
163
- <%# Visual Rule Editor Section %>
164
94
  <div data-<%= identifier %>-target="visualEditor" class="space-y-3">
165
- <div class="space-y-1">
166
- <%# Dynamic Rule Cards Container %>
167
- <div data-<%= identifier %>-target="rulesContainer" class="space-y-2"></div>
168
-
169
- <%# Add Rule Action Button %>
170
- <div class="pt-1">
171
- <button type="button"
172
- data-action="click-><%= identifier %>#addRule"
173
- class="rui-link-action">
174
- <span class="font-bold">+</span> <%= t('recurrence_ui.actions.add_rule', default: 'Add rule') %>
175
- </button>
95
+
96
+ <% if allow_multiple_rules %>
97
+ <div class="space-y-1">
98
+ <div data-<%= identifier %>-target="rulesContainer" class="space-y-2"></div>
99
+ <div class="pt-1">
100
+ <button type="button"
101
+ data-action="click-><%= identifier %>#addRule"
102
+ class="rui-link-action">
103
+ <span class="font-bold">+</span> <%= t('recurrence_ui.actions.add_rule', default: 'Add rule') %>
104
+ </button>
105
+ </div>
176
106
  </div>
177
- </div>
107
+ <% else %>
108
+
109
+ <div class="space-y-3">
110
+ <%= render "recurrence_ui/single_rule", form: form, identifier: identifier, days_for_ui: days_for_ui, rec_ui: self, rule_options: rule_options %>
111
+ </div>
112
+ <% end %>
178
113
 
179
- <%# Exceptions & Additional Dates Grid %>
180
114
  <div class="grid grid-cols-1 md:grid-cols-2 gap-3 pt-2 rui-divider">
181
- <div data-<%= identifier %>-target="rdatesBlock" class="hidden">
182
- <%= render "recurrence_ui/rdates", form: form, identifier: identifier, rec_ui: self, rdates: rules[:rdates] || [] %>
183
- </div>
184
- <div data-<%= identifier %>-target="exceptionsBlock" class="hidden">
185
- <%= render "recurrence_ui/exceptions", form: form, identifier: identifier, rec_ui: self, exdates: rules[:exdates] || [] %>
186
- </div>
115
+ <% if show_rdates %>
116
+ <div data-<%= identifier %>-target="rdatesBlock" class="hidden">
117
+ <%= render "recurrence_ui/rdates", form: form, identifier: identifier, rec_ui: self, rdates: rules[:rdates] || [] %>
118
+ </div>
119
+ <% end %>
120
+ <% if show_exceptions %>
121
+ <div data-<%= identifier %>-target="exceptionsBlock" class="hidden">
122
+ <%= render "recurrence_ui/exceptions", form: form, identifier: identifier, rec_ui: self, exdates: rules[:exdates] || [] %>
123
+ </div>
124
+ <% end %>
187
125
  </div>
188
126
 
189
- <%# Bottom Action Bar %>
190
127
  <div class="pt-2">
191
128
  <%= render "recurrence_ui/footer_actions", form: form, identifier: identifier, rec_ui: self %>
192
129
  </div>
193
130
  </div>
194
131
 
195
- <%# Raw JSON / Code Editor Panel %>
196
132
  <div data-<%= identifier %>-target="codeEditor" class="hidden space-y-3">
197
133
  <div>
198
- <label class="rui-label">
199
- <%= t('recurrence_ui.labels.raw_json', default: 'Raw JSON') %>
200
- </label>
201
- <textarea data-<%= identifier %>-target="iceCubeField"
202
- rows="6"
203
- class="rui-textarea font-mono text-xs w-full"></textarea>
134
+ <label class="rui-label"><%= t('recurrence_ui.labels.raw_json', default: 'Raw JSON') %></label>
135
+ <textarea data-<%= identifier %>-target="iceCubeField" rows="6" class="rui-textarea font-mono text-xs w-full"></textarea>
204
136
  </div>
205
137
  <div class="flex items-center justify-end space-x-2">
206
- <button type="button"
207
- data-action="click-><%= identifier %>#toggleCodeEditor"
208
- class="rui-btn-secondary">
138
+ <button type="button" data-action="click-><%= identifier %>#toggleCodeEditor" class="rui-btn-secondary">
209
139
  <%= t('recurrence_ui.actions.cancel') %>
210
140
  </button>
211
- <button type="button"
212
- data-action="click-><%= identifier %>#applyCodeChanges"
213
- class="rui-btn-primary">
141
+ <button type="button" data-action="click-><%= identifier %>#applyCodeChanges" class="rui-btn-primary">
214
142
  <%= t('recurrence_ui.actions.apply_code') %>
215
143
  </button>
216
144
  </div>
217
145
  </div>
218
-
219
146
  </div>
220
147
 
221
- <%# Rule Card Template %>
222
- <template data-<%= identifier %>-target="ruleCardTemplate">
223
- <%= render "recurrence_ui/rule_card",
224
- form: form,
225
- identifier: identifier,
226
- days_for_ui: days_for_ui,
227
- rec_ui: self,
228
- rule_options: rule_options %>
229
- </template>
148
+ <% if allow_multiple_rules %>
149
+ <template data-<%= identifier %>-target="ruleCardTemplate">
150
+ <%= render "recurrence_ui/rule_card",
151
+ form: form,
152
+ identifier: identifier,
153
+ days_for_ui: days_for_ui,
154
+ rec_ui: self,
155
+ rule_options: rule_options %>
156
+ </template>
157
+ <% end %>
230
158
 
231
- <%# Hidden Form Field %>
232
159
  <%= form.hidden_field field_name, value: rules_json, data: { "#{identifier}_target": "hiddenField" } %>
233
160
  </div>
234
161
  <% end %>