recurrence_ui 0.2.2 → 0.3.1
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/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/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/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 +48 -11
- data/lib/recurrence_ui/configuration.rb +80 -11
- data/lib/recurrence_ui/engine.rb +1 -1
- data/lib/recurrence_ui/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 30bda1d3e659e5be4acd1c5addc226c2bddcbb9d862bbee836a15542b896722c
|
|
4
|
+
data.tar.gz: e68a05739a7cc1e34a6d01b9b0cbc16f8a569a28ab0d2cd1c998f028d4eeb360
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3cc4b0b312432613d8c5780648d373a48286527c8864458c149d73244a449fb9c2b445dde608fe246b6980aef8a74ec62b4cbabc14f06ad8bf4e654d53f50133
|
|
7
|
+
data.tar.gz: 2fb010565904f3f9635c277c1834607200b6f35e30058568da1722b5b9bd60d77d82ce7242d419b6d711e09c5773e7387df0b472508932face14a8b474d91576
|
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
|
[](https://rubygems.org/gems/recurrence_ui)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
9
|
|
|
10
|
-
##
|
|
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
|
-
##
|
|
21
|
+
## Requirements
|
|
22
22
|
|
|
23
23
|
Recurrence UI depends on the following components:
|
|
24
24
|
|
|
25
|
-
- **Ruby on Rails** >=
|
|
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
|
-
##
|
|
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
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
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
|
-
-
|
|
70
|
-
-
|
|
71
|
-
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
### View Integration
|
|
162
|
+
|
|
163
|
+
Render the recurrence editor inside a Rails form using `RecurrenceUi::RecurrencePickerComponent`:
|
|
164
|
+
|
|
138
165
|
```erb
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
-
|
|
147
|
-
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
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
|
-
##
|
|
265
|
+
## Testing
|
|
244
266
|
|
|
245
267
|
*Note: The test suite is currently under active development. Contributions are very welcome!*
|
|
246
268
|
|
|
@@ -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="
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
<%=
|
|
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
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
</
|
|
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
|
-
|
|
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
|
-
<!--
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
<div
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
</
|
|
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
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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
|
-
|
|
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
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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 %>
|