recurrence_ui 0.3.3 → 0.4.0
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 +6 -12
- data/app/assets/stylesheets/recurrence_ui/application.css +962 -12
- data/app/components/recurrence_ui/recurrence_picker_component.html.erb +85 -83
- data/app/javascript/recurrence_ui/recurrence_ui_controller.js +53 -42
- data/app/views/recurrence_ui/_daily.html.erb +3 -3
- data/app/views/recurrence_ui/_duration.html.erb +33 -36
- data/app/views/recurrence_ui/_end_at.html.erb +5 -4
- data/app/views/recurrence_ui/_exceptions.html.erb +22 -22
- data/app/views/recurrence_ui/_footer_actions.html.erb +1 -1
- data/app/views/recurrence_ui/_monthly_by_day_of_month.html.erb +5 -5
- data/app/views/recurrence_ui/_monthly_by_weekday.html.erb +12 -12
- data/app/views/recurrence_ui/_rdates.html.erb +22 -22
- data/app/views/recurrence_ui/_rule_card.html.erb +9 -9
- data/app/views/recurrence_ui/_single_rule.html.erb +13 -11
- data/app/views/recurrence_ui/_start_at.html.erb +17 -21
- data/app/views/recurrence_ui/_summary_link.html.erb +4 -4
- data/app/views/recurrence_ui/_termination.html.erb +13 -12
- data/app/views/recurrence_ui/_time_zone.html.erb +11 -9
- data/app/views/recurrence_ui/_weekly.html.erb +19 -24
- data/app/views/recurrence_ui/_yearly_by_day_of_month.html.erb +9 -10
- data/app/views/recurrence_ui/_yearly_by_weekday.html.erb +11 -12
- data/config/locales/recurrence_ui.ru.yml +2 -2
- data/config/routes.rb +0 -3
- data/lib/generators/recurrence_ui/install/install_generator.rb +29 -23
- data/lib/generators/recurrence_ui/install/templates/recurrence_ui.rb +40 -0
- data/lib/recurrence_ui/engine.rb +1 -0
- data/lib/recurrence_ui/version.rb +1 -1
- metadata +3 -4
- data/app/assets/stylesheets/recurrence_ui/components.css +0 -295
- data/app/assets/stylesheets/recurrence_ui/tokens.css +0 -102
|
@@ -7,134 +7,136 @@
|
|
|
7
7
|
class="rui-container"
|
|
8
8
|
data-rui-theme="<%= RecurrenceUi.configuration.theme_mode %>">
|
|
9
9
|
|
|
10
|
-
<%# 1.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<div class="
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
<%# 1. Единая секция верхних полей (Начало, Часовой пояс, Длительность, Окончание) %>
|
|
11
|
+
<% if show_start_date_time || show_time_zone || show_duration || show_end_date_time %>
|
|
12
|
+
<div class="rui-top-fields-section">
|
|
13
|
+
<div class="rui-grid-2">
|
|
14
|
+
|
|
15
|
+
<%# Время начала %>
|
|
16
|
+
<% if show_start_date_time %>
|
|
17
|
+
<%= render "recurrence_ui/start_at", form: form, identifier: identifier, rec_ui: self %>
|
|
18
|
+
<% end %>
|
|
19
|
+
<% if show_time_zone %>
|
|
20
|
+
<%= render "recurrence_ui/time_zone", form: form, identifier: identifier, rec_ui: self %>
|
|
21
|
+
<% end %>
|
|
22
|
+
<%# Длительность и Окончание (если оба включены, они могут рендериться как две карточки с радиокнопками) %>
|
|
23
|
+
<% if show_duration && show_end_date_time %>
|
|
24
|
+
<!-- Карточка Длительности -->
|
|
25
|
+
<label class="rui-card-option rui-duration-card">
|
|
26
|
+
<%= form.radio_button :form_duration_mode, :duration,
|
|
27
|
+
checked: (initial_form_duration_mode == :duration),
|
|
28
|
+
class: "rui-radio rui-radio-spacing",
|
|
29
|
+
data: { "#{identifier}_target": "modeDuration", action: "change->#{identifier}#toggleDurationEndMode" } %>
|
|
30
|
+
<div class="rui-card-content">
|
|
31
|
+
<span class="rui-label"><%= t('recurrence_ui.labels.duration') %></span>
|
|
32
|
+
<div class="rui-subcontent-spacing" onclick="event.stopPropagation()">
|
|
33
|
+
<%= render "recurrence_ui/duration", form: form, identifier: identifier, rec_ui: self %>
|
|
34
|
+
</div>
|
|
35
|
+
</div>
|
|
36
|
+
</label>
|
|
17
37
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
38
|
+
<!-- Карточка Окончания -->
|
|
39
|
+
<label class="rui-card-option rui-duration-card">
|
|
40
|
+
<%= form.radio_button :form_duration_mode, :end_at,
|
|
41
|
+
checked: (initial_form_duration_mode == :end_at),
|
|
42
|
+
class: "rui-radio rui-radio-spacing",
|
|
43
|
+
data: { "#{identifier}_target": "modeEnd", action: "change->#{identifier}#toggleDurationEndMode" } %>
|
|
44
|
+
<div class="rui-card-content">
|
|
45
|
+
<span class="rui-label"><%= t('recurrence_ui.labels.end_at') %></span>
|
|
46
|
+
<div class="rui-subcontent-spacing" onclick="event.stopPropagation()">
|
|
47
|
+
<%= render "recurrence_ui/end_at", form: form, identifier: identifier, rec_ui: self %>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
</label>
|
|
51
|
+
|
|
52
|
+
<% else %>
|
|
53
|
+
<%# Если включена только длительность %>
|
|
54
|
+
<% if show_duration %>
|
|
55
|
+
<div class="rui-single-option-block">
|
|
56
|
+
<span class="rui-label"><%= t('recurrence_ui.labels.duration') %></span>
|
|
37
57
|
<%= render "recurrence_ui/duration", form: form, identifier: identifier, rec_ui: self %>
|
|
38
58
|
</div>
|
|
39
|
-
|
|
40
|
-
</label>
|
|
59
|
+
<% end %>
|
|
41
60
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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()">
|
|
61
|
+
<%# Если включено только окончание %>
|
|
62
|
+
<% if show_end_date_time %>
|
|
63
|
+
<div class="rui-single-option-block">
|
|
64
|
+
<span class="rui-label"><%= t('recurrence_ui.labels.end_at') %></span>
|
|
51
65
|
<%= render "recurrence_ui/end_at", form: form, identifier: identifier, rec_ui: self %>
|
|
52
66
|
</div>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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 %>
|
|
67
|
+
<% end %>
|
|
68
|
+
<% end %>
|
|
69
|
+
|
|
65
70
|
</div>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
71
|
+
</div>
|
|
72
|
+
<% end %>
|
|
73
|
+
|
|
74
|
+
<!-- 2. Саммари -->
|
|
75
|
+
<div data-<%= identifier %>-target="displayMode" class="rui-display-mode-section">
|
|
70
76
|
<div class="rui-panel-header">
|
|
71
77
|
<span class="rui-label">
|
|
72
78
|
<%= t('recurrence_ui.labels.recurrence') %>
|
|
73
79
|
</span>
|
|
74
80
|
</div>
|
|
75
|
-
<div>
|
|
76
81
|
<%= render "recurrence_ui/summary_link", form: form, identifier: identifier, rec_ui: self %>
|
|
77
|
-
</div>
|
|
78
82
|
</div>
|
|
79
83
|
|
|
80
84
|
<!-- Режим редактирования -->
|
|
81
|
-
<div data-<%= identifier %>-target="editMode" class="hidden
|
|
82
|
-
<div class="rui-panel-header flex
|
|
83
|
-
<span class="rui-
|
|
85
|
+
<div data-<%= identifier %>-target="editMode" class="rui-hidden rui-edit-mode-container">
|
|
86
|
+
<div class="rui-panel-header rui-flex-between">
|
|
87
|
+
<span class="rui-label">
|
|
84
88
|
<%= t('recurrence_ui.labels.recurrence') %>
|
|
85
89
|
</span>
|
|
86
90
|
<button type="button"
|
|
87
91
|
data-action="click-><%= identifier %>#toggleCodeEditor"
|
|
88
92
|
title="<%= t('recurrence_ui.actions.code_mode') %>"
|
|
89
|
-
class="rui-btn-secondary
|
|
93
|
+
class="rui-btn-secondary rui-code-btn">
|
|
90
94
|
</>
|
|
91
95
|
</button>
|
|
92
96
|
</div>
|
|
93
97
|
|
|
94
|
-
<div data-<%= identifier %>-target="visualEditor" class="
|
|
98
|
+
<div data-<%= identifier %>-target="visualEditor" class="rui-visual-editor-stack">
|
|
95
99
|
|
|
96
100
|
<% if allow_multiple_rules %>
|
|
97
|
-
<div class="
|
|
98
|
-
<div data-<%= identifier %>-target="rulesContainer" class="
|
|
99
|
-
<div class="
|
|
101
|
+
<div class="rui-multiple-rules-wrapper">
|
|
102
|
+
<div data-<%= identifier %>-target="rulesContainer" class="rui-rules-container"></div>
|
|
103
|
+
<div class="rui-add-rule-wrapper">
|
|
100
104
|
<button type="button"
|
|
101
105
|
data-action="click-><%= identifier %>#addRule"
|
|
102
106
|
class="rui-link-action">
|
|
103
|
-
<span class="font-bold">+</span> <%= t('recurrence_ui.actions.add_rule', default: 'Add rule') %>
|
|
107
|
+
<span class="rui-font-bold">+</span> <%= t('recurrence_ui.actions.add_rule', default: 'Add rule') %>
|
|
104
108
|
</button>
|
|
105
109
|
</div>
|
|
106
110
|
</div>
|
|
107
111
|
<% else %>
|
|
108
|
-
|
|
109
|
-
<div class="space-y-3">
|
|
112
|
+
<div class="rui-visual-editor-stack">
|
|
110
113
|
<%= render "recurrence_ui/single_rule", form: form, identifier: identifier, days_for_ui: days_for_ui, rec_ui: self, rule_options: rule_options %>
|
|
111
114
|
</div>
|
|
112
115
|
<% end %>
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
<% if show_rdates || show_exceptions %>
|
|
117
|
+
<div class="rui-grid-2">
|
|
118
|
+
<% if show_rdates %>
|
|
119
|
+
<div data-<%= identifier %>-target="rdatesBlock" >
|
|
120
|
+
<%= render "recurrence_ui/rdates", form: form, identifier: identifier, rec_ui: self, rdates: rules[:rdates] || [] %>
|
|
121
|
+
</div>
|
|
122
|
+
<% end %>
|
|
123
|
+
<% if show_exceptions %>
|
|
124
|
+
<div data-<%= identifier %>-target="exceptionsBlock" >
|
|
125
|
+
<%= render "recurrence_ui/exceptions", form: form, identifier: identifier, rec_ui: self, exdates: rules[:exdates] || [] %>
|
|
126
|
+
</div>
|
|
127
|
+
<% end %>
|
|
118
128
|
</div>
|
|
119
|
-
|
|
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 %>
|
|
125
|
-
</div>
|
|
129
|
+
<% end %>
|
|
126
130
|
|
|
127
|
-
<div class="pt-2">
|
|
128
131
|
<%= render "recurrence_ui/footer_actions", form: form, identifier: identifier, rec_ui: self %>
|
|
129
|
-
</div>
|
|
130
132
|
</div>
|
|
131
133
|
|
|
132
|
-
<div data-<%= identifier %>-target="codeEditor" class="hidden
|
|
134
|
+
<div data-<%= identifier %>-target="codeEditor" class="rui-hidden rui-visual-editor-stack">
|
|
133
135
|
<div>
|
|
134
136
|
<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
|
|
137
|
+
<textarea data-<%= identifier %>-target="iceCubeField" rows="6" class="rui-textarea rui-code-textarea"></textarea>
|
|
136
138
|
</div>
|
|
137
|
-
<div class="flex
|
|
139
|
+
<div class="rui-flex-end-gap">
|
|
138
140
|
<button type="button" data-action="click-><%= identifier %>#toggleCodeEditor" class="rui-btn-secondary">
|
|
139
141
|
<%= t('recurrence_ui.actions.cancel') %>
|
|
140
142
|
</button>
|
|
@@ -40,13 +40,13 @@ export default class extends Controller {
|
|
|
40
40
|
this.initializeDurationMode()
|
|
41
41
|
// Принудительно инициализируем видимость полей для режима «Одно правило»
|
|
42
42
|
|
|
43
|
-
this.element.querySelectorAll('select[data-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
this.element.querySelectorAll('select[data-item="ruleType"]').forEach(select => {
|
|
44
|
+
this.toggleCardFields({ currentTarget: select })
|
|
45
|
+
})
|
|
46
46
|
this.isInitializing = false
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
// ==========================================
|
|
49
|
+
// ==========================================
|
|
50
50
|
// INITIALIZATION & STATE MANAGEMENT
|
|
51
51
|
// ==========================================
|
|
52
52
|
|
|
@@ -65,8 +65,15 @@ export default class extends Controller {
|
|
|
65
65
|
const rules = schedule.rrules || (schedule.rule_type ? [schedule] : [])
|
|
66
66
|
|
|
67
67
|
if (rules.length > 0) {
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
if (this.hasRulesContainerTarget && this.hasRuleCardTemplateTarget) {
|
|
69
|
+
rules.forEach(ruleHash => this._createRuleCardFromHash(ruleHash))
|
|
70
|
+
} else {
|
|
71
|
+
const singleCard = this.element.querySelector(`[data-${this.identifier}-target="ruleCard"]`)
|
|
72
|
+
if (singleCard) {
|
|
73
|
+
this._applyRuleHashToCard(singleCard, rules[0])
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} else if (this.hasRulesContainerTarget && this.hasRuleCardTemplateTarget) {
|
|
70
77
|
this.addRule()
|
|
71
78
|
}
|
|
72
79
|
|
|
@@ -79,9 +86,9 @@ export default class extends Controller {
|
|
|
79
86
|
}
|
|
80
87
|
} catch (e) {
|
|
81
88
|
console.error("[RecurrenceUi] JSON Parsing error:", e)
|
|
82
|
-
if (this.hasRuleCardTemplateTarget) this.addRule()
|
|
89
|
+
if (this.hasRulesContainerTarget && this.hasRuleCardTemplateTarget) this.addRule()
|
|
83
90
|
}
|
|
84
|
-
} else if (this.hasRuleCardTemplateTarget) {
|
|
91
|
+
} else if (this.hasRulesContainerTarget && this.hasRuleCardTemplateTarget) {
|
|
85
92
|
this.addRule()
|
|
86
93
|
}
|
|
87
94
|
|
|
@@ -169,12 +176,12 @@ export default class extends Controller {
|
|
|
169
176
|
// Toggle Main Panel Accordion Mode
|
|
170
177
|
toggleMainAccordion() {
|
|
171
178
|
if (!this.hasEditModeTarget) return
|
|
172
|
-
const isHidden = this.editModeTarget.classList.contains('hidden')
|
|
179
|
+
const isHidden = this.editModeTarget.classList.contains('rui-hidden')
|
|
173
180
|
|
|
174
181
|
if (isHidden) {
|
|
175
|
-
this.editModeTarget.classList.remove('hidden')
|
|
182
|
+
this.editModeTarget.classList.remove('rui-hidden')
|
|
176
183
|
} else {
|
|
177
|
-
this.editModeTarget.classList.add('hidden')
|
|
184
|
+
this.editModeTarget.classList.add('rui-hidden')
|
|
178
185
|
this.updateSummary() // Recalculate summary text on close
|
|
179
186
|
}
|
|
180
187
|
}
|
|
@@ -191,13 +198,13 @@ export default class extends Controller {
|
|
|
191
198
|
|
|
192
199
|
const body = card.querySelector(`[data-${this.identifier}-target="cardBody"]`)
|
|
193
200
|
if (body) {
|
|
194
|
-
const isHidden = body.classList.contains('hidden')
|
|
201
|
+
const isHidden = body.classList.contains('rui-hidden')
|
|
195
202
|
|
|
196
203
|
if (isHidden) {
|
|
197
|
-
body.classList.remove('hidden')
|
|
204
|
+
body.classList.remove('rui-hidden')
|
|
198
205
|
card.classList.add('is-open') // Add active state class
|
|
199
206
|
} else {
|
|
200
|
-
body.classList.add('hidden')
|
|
207
|
+
body.classList.add('rui-hidden')
|
|
201
208
|
card.classList.remove('is-open') // Remove active state class
|
|
202
209
|
this.updateCardSummary(card) // Update rule text on collapse
|
|
203
210
|
}
|
|
@@ -207,7 +214,7 @@ export default class extends Controller {
|
|
|
207
214
|
toggleCodeEditor(event) {
|
|
208
215
|
if (event) event.preventDefault()
|
|
209
216
|
|
|
210
|
-
const isCodeHidden = this.codeEditorTarget.classList.contains('hidden')
|
|
217
|
+
const isCodeHidden = this.codeEditorTarget.classList.contains('rui-hidden')
|
|
211
218
|
|
|
212
219
|
if (isCodeHidden) {
|
|
213
220
|
// Считываем текущий JSON из скрытого поля формы
|
|
@@ -223,12 +230,12 @@ export default class extends Controller {
|
|
|
223
230
|
}
|
|
224
231
|
|
|
225
232
|
// Переключаем видимость блоков
|
|
226
|
-
this.visualEditorTarget.classList.add('hidden')
|
|
227
|
-
this.codeEditorTarget.classList.remove('hidden')
|
|
233
|
+
this.visualEditorTarget.classList.add('rui-hidden')
|
|
234
|
+
this.codeEditorTarget.classList.remove('rui-hidden')
|
|
228
235
|
} else {
|
|
229
236
|
// Возврат назад без сохранения
|
|
230
|
-
this.codeEditorTarget.classList.add('hidden')
|
|
231
|
-
this.visualEditorTarget.classList.remove('hidden')
|
|
237
|
+
this.codeEditorTarget.classList.add('rui-hidden')
|
|
238
|
+
this.visualEditorTarget.classList.remove('rui-hidden')
|
|
232
239
|
}
|
|
233
240
|
}
|
|
234
241
|
|
|
@@ -251,8 +258,8 @@ export default class extends Controller {
|
|
|
251
258
|
this.initializeState()
|
|
252
259
|
|
|
253
260
|
// Переключаем обратно в визуальный режим
|
|
254
|
-
this.codeEditorTarget.classList.add('hidden')
|
|
255
|
-
this.visualEditorTarget.classList.remove('hidden')
|
|
261
|
+
this.codeEditorTarget.classList.add('rui-hidden')
|
|
262
|
+
this.visualEditorTarget.classList.remove('rui-hidden')
|
|
256
263
|
|
|
257
264
|
} catch (e) {
|
|
258
265
|
alert(this.t('errors.invalid_json', { default: 'Ошибка в синтаксисе JSON' }))
|
|
@@ -276,7 +283,7 @@ export default class extends Controller {
|
|
|
276
283
|
const body = newCard.querySelector(`[data-${this.identifier}-target="cardBody"]`)
|
|
277
284
|
|
|
278
285
|
// Раскрываем тело новой карточки
|
|
279
|
-
if (body) body.classList.remove('hidden')
|
|
286
|
+
if (body) body.classList.remove('rui-hidden')
|
|
280
287
|
|
|
281
288
|
// Запускаем первичную синхронизацию полей новой карточки
|
|
282
289
|
const select = newCard.querySelector('[data-item="ruleType"]')
|
|
@@ -315,7 +322,7 @@ export default class extends Controller {
|
|
|
315
322
|
|
|
316
323
|
specificFields.forEach(el => {
|
|
317
324
|
const isCurrent = el.dataset.rule === selectedValue
|
|
318
|
-
el.classList.toggle('hidden', !isCurrent)
|
|
325
|
+
el.classList.toggle('rui-hidden', !isCurrent)
|
|
319
326
|
|
|
320
327
|
// Если выбрали тип с полем (например, daily) и интервал не задан, выставляем 1 по умолчанию
|
|
321
328
|
if (isCurrent) {
|
|
@@ -325,7 +332,7 @@ export default class extends Controller {
|
|
|
325
332
|
}
|
|
326
333
|
}
|
|
327
334
|
})
|
|
328
|
-
|
|
335
|
+
if (this.isInitializing) return
|
|
329
336
|
this.updateHiddenHash()
|
|
330
337
|
this.updateCardSummary(card)
|
|
331
338
|
}
|
|
@@ -351,9 +358,9 @@ export default class extends Controller {
|
|
|
351
358
|
const endDate = card.querySelector('[data-item="endDateInput"]')
|
|
352
359
|
const endCount = card.querySelector('[data-item="endCount"]')
|
|
353
360
|
|
|
354
|
-
if (endDate) endDate.classList.toggle('hidden', mode !== 'until')
|
|
361
|
+
if (endDate) endDate.classList.toggle('rui-hidden', mode !== 'until')
|
|
355
362
|
if (endCount) {
|
|
356
|
-
endCount.classList.toggle('hidden', mode !== 'count')
|
|
363
|
+
endCount.classList.toggle('rui-hidden', mode !== 'count')
|
|
357
364
|
if (mode === 'count') endCount.classList.add('flex')
|
|
358
365
|
}
|
|
359
366
|
|
|
@@ -361,6 +368,7 @@ export default class extends Controller {
|
|
|
361
368
|
this.updateCardSummary(card)
|
|
362
369
|
}
|
|
363
370
|
onCardInputChanged(event) {
|
|
371
|
+
if (this.isInitializing) return
|
|
364
372
|
const card = event.currentTarget.closest(`[data-${this.identifier}-target="ruleCard"]`)
|
|
365
373
|
this.updateHiddenHash()
|
|
366
374
|
if (card) this.updateCardSummary(card)
|
|
@@ -389,14 +397,14 @@ export default class extends Controller {
|
|
|
389
397
|
}
|
|
390
398
|
|
|
391
399
|
showDisplayMode() {
|
|
392
|
-
if (this.hasDisplayModeTarget) this.displayModeTarget.classList.remove('hidden')
|
|
393
|
-
if (this.hasEditModeTarget) this.editModeTarget.classList.add('hidden')
|
|
400
|
+
if (this.hasDisplayModeTarget) this.displayModeTarget.classList.remove('rui-hidden')
|
|
401
|
+
if (this.hasEditModeTarget) this.editModeTarget.classList.add('rui-hidden')
|
|
394
402
|
this.updateSummary()
|
|
395
403
|
}
|
|
396
404
|
|
|
397
405
|
showEditMode() {
|
|
398
|
-
if (this.hasDisplayModeTarget) this.displayModeTarget.classList.add('hidden')
|
|
399
|
-
if (this.hasEditModeTarget) this.editModeTarget.classList.remove('hidden')
|
|
406
|
+
if (this.hasDisplayModeTarget) this.displayModeTarget.classList.add('rui-hidden')
|
|
407
|
+
if (this.hasEditModeTarget) this.editModeTarget.classList.remove('rui-hidden')
|
|
400
408
|
}
|
|
401
409
|
|
|
402
410
|
// ==========================================
|
|
@@ -697,16 +705,11 @@ export default class extends Controller {
|
|
|
697
705
|
if (Object.keys(ruleHash.validations).length === 0) delete ruleHash.validations
|
|
698
706
|
return ruleHash
|
|
699
707
|
}
|
|
708
|
+
|
|
709
|
+
_applyRuleHashToCard(card, ruleHash) {
|
|
710
|
+
if (!card || !ruleHash) return
|
|
700
711
|
|
|
701
|
-
_createRuleCardFromHash(ruleHash) {
|
|
702
|
-
|
|
703
|
-
if (!this.hasRuleCardTemplateTarget) return
|
|
704
|
-
const content = this.ruleCardTemplateTarget.innerHTML
|
|
705
|
-
this.rulesContainerTarget.insertAdjacentHTML('beforeend', content)
|
|
706
|
-
|
|
707
|
-
const card = this.rulesContainerTarget.lastElementChild
|
|
708
712
|
const ruleType = this._determineRuleType(ruleHash)
|
|
709
|
-
|
|
710
713
|
const typeSelect = card.querySelector('[data-item="ruleType"]')
|
|
711
714
|
if (typeSelect) typeSelect.value = ruleType
|
|
712
715
|
|
|
@@ -728,16 +731,24 @@ export default class extends Controller {
|
|
|
728
731
|
}
|
|
729
732
|
|
|
730
733
|
this._fillTerminationFieldsForCard(card, ruleHash)
|
|
734
|
+
this.updateCardSummary(card)
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
_createRuleCardFromHash(ruleHash) {
|
|
738
|
+
if (!this.hasRuleCardTemplateTarget) return
|
|
739
|
+
const content = this.ruleCardTemplateTarget.innerHTML
|
|
740
|
+
this.rulesContainerTarget.insertAdjacentHTML('beforeend', content)
|
|
741
|
+
|
|
742
|
+
const card = this.rulesContainerTarget.lastElementChild
|
|
743
|
+
this._applyRuleHashToCard(card, ruleHash)
|
|
744
|
+
|
|
731
745
|
// Card should be collapsed by default, so we don't show the body unless the user expands it
|
|
732
746
|
const body = card.querySelector(`[data-${this.identifier}-target="cardBody"]`)
|
|
733
747
|
if (body) {
|
|
734
748
|
body.classList.add('hidden')
|
|
735
749
|
}
|
|
736
|
-
// Update header summary text for the card based on JSON data
|
|
737
|
-
this.updateCardSummary(card)
|
|
738
750
|
}
|
|
739
|
-
|
|
740
|
-
|
|
751
|
+
|
|
741
752
|
_buildRuleSummaryText(hash) {
|
|
742
753
|
const type = this._determineRuleType(hash)
|
|
743
754
|
const interval = hash.interval || 1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_daily.html.erb %>
|
|
2
2
|
<%# Daily Recurrence Rule Options %>
|
|
3
|
-
<div class="
|
|
4
|
-
<div class="
|
|
3
|
+
<div class="rui-daily-container" data-item="specificFields" data-rule="daily">
|
|
4
|
+
<div class="rui-daily-row">
|
|
5
5
|
<span class="rui-inline-label">
|
|
6
6
|
<%= t("recurrence_ui.labels.every", default: "Every") %>
|
|
7
7
|
</span>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<%= number_field_tag nil, rec_ui.initial_interval,
|
|
10
10
|
value: 1,
|
|
11
11
|
min: 1,
|
|
12
|
-
class: "rui-input
|
|
12
|
+
class: "rui-input rui-daily-input text-center",
|
|
13
13
|
data: {
|
|
14
14
|
item: "interval",
|
|
15
15
|
action: "input->#{identifier}#onCardInputChanged"
|
|
@@ -1,40 +1,37 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_duration.html.erb %>
|
|
2
|
-
<div class="
|
|
3
|
-
<%#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
<div class="rui-duration-container" data-<%= identifier %>-target="durationContainer">
|
|
3
|
+
<%# Days %>
|
|
4
|
+
<div class="rui-duration-field-group rui-duration-days-group">
|
|
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",
|
|
10
|
+
data: { "#{identifier}_target": "daysField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
11
|
+
<span class="rui-duration-unit rui-select-none"><%= t('recurrence_ui.duration.form_days') %></span>
|
|
12
|
+
</div>
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
<%# Hours %>
|
|
15
|
+
<div class="rui-duration-field-group rui-duration-hours-group">
|
|
16
|
+
<%= form.number_field :form_duration_hours,
|
|
17
|
+
value: rec_ui.initial_form_duration_hours,
|
|
18
|
+
min: 0,
|
|
19
|
+
max: 23,
|
|
20
|
+
disabled: (rec_ui.initial_form_duration_mode != :duration && rec_ui.show_end_date_time),
|
|
21
|
+
class: "rui-input",
|
|
22
|
+
data: { "#{identifier}_target": "hoursField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
23
|
+
<span class="rui-duration-unit rui-select-none"><%= t('recurrence_ui.duration.form_hours') %></span>
|
|
24
|
+
</div>
|
|
14
25
|
|
|
15
|
-
<%#
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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>
|
|
26
|
+
<%# Minutes %>
|
|
27
|
+
<div class="rui-duration-field-group rui-duration-minutes-group">
|
|
28
|
+
<%= form.number_field :form_duration_minutes,
|
|
29
|
+
value: rec_ui.initial_form_duration_minutes,
|
|
30
|
+
min: 0,
|
|
31
|
+
max: 59,
|
|
32
|
+
disabled: (rec_ui.initial_form_duration_mode != :duration && rec_ui.show_end_date_time),
|
|
33
|
+
class: "rui-input",
|
|
34
|
+
data: { "#{identifier}_target": "minutesField", action: "change->#{identifier}#calculateEndDateFromDuration" } %>
|
|
35
|
+
<span class="rui-duration-unit rui-select-none"><%= t('recurrence_ui.duration.form_minutes') %></span>
|
|
36
|
+
</div>
|
|
40
37
|
</div>
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_end_at.html.erb %>
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
<div class="rui-end-at-row" onclick="event.stopPropagation()">
|
|
3
4
|
<%= form.date_field :form_end_date,
|
|
4
5
|
value: form.object.end_time_in_zone(:event)&.to_date || Date.current,
|
|
5
6
|
disabled: (rec_ui.initial_form_duration_mode != :end_at && rec_ui.show_duration),
|
|
6
|
-
class: "rui-input
|
|
7
|
+
class: "rui-input rui-input-date #{'rui-input-error' if form.object.errors[:form_end_date].any?}",
|
|
7
8
|
data: { "#{identifier}_target": "endDateField" } %>
|
|
8
9
|
|
|
9
10
|
<%= form.time_field :form_end_time,
|
|
10
|
-
value: form.object.end_time_in_zone(:event)
|
|
11
|
+
value: form.object.end_time_in_zone(:event),
|
|
11
12
|
disabled: (rec_ui.initial_form_duration_mode != :end_at && rec_ui.show_duration),
|
|
12
|
-
class:
|
|
13
|
+
class: "rui-input rui-input-time #{'rui-input-error' if form.object.errors[:form_end_time].any?}",
|
|
13
14
|
data: { "#{identifier}_target": "endTimeField" } %>
|
|
14
15
|
</div>
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_exceptions.html.erb %>
|
|
2
2
|
<%# Excluded Dates (EXDATES) Section %>
|
|
3
|
-
<div class="
|
|
3
|
+
<div class="rui-exceptions-container rui-divider ">
|
|
4
4
|
<%# 1. Section Label %>
|
|
5
|
-
<label class="rui-label
|
|
6
|
-
|
|
5
|
+
<label class="rui-label rui-exceptions-label">
|
|
6
|
+
<%= t("recurrence_ui.labels.exceptions", locale: locale, default: "Exceptions") %>
|
|
7
7
|
</label>
|
|
8
8
|
|
|
9
|
-
<%# 2.
|
|
10
|
-
<div
|
|
11
|
-
<% exdates.each do |exdate| %>
|
|
12
|
-
<% date_str = exdate.is_a?(Date) || exdate.is_a?(Time) ? exdate.strftime("%Y-%m-%d") : exdate.to_s %>
|
|
13
|
-
<span class="rui-chip rui-chip--exdate" data-exdate-value="<%= date_str %>">
|
|
14
|
-
<button type="button"
|
|
15
|
-
data-action="click-><%= identifier %>#removeExdate"
|
|
16
|
-
class="rui-chip__remove-btn"
|
|
17
|
-
title="<%= t('recurrence_ui.actions.remove', default: 'Delete') %>">✕</button>
|
|
18
|
-
<span><%= rec_ui._formatDate(date_str) rescue date_str %></span>
|
|
19
|
-
</span>
|
|
20
|
-
<% end %>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<%# 3. Date Input and Add Button %>
|
|
24
|
-
<div class="flex items-center gap-1.5 pt-1">
|
|
9
|
+
<%# 2. Date Input and Add Button (теперь первыми) %>
|
|
10
|
+
<div class="rui-exceptions-input-group ">
|
|
25
11
|
<input type="date"
|
|
26
12
|
data-<%= identifier %>-target="exdateInput"
|
|
27
|
-
data-action="input-><%= identifier %>#onDateInputChange"
|
|
28
|
-
class="rui-input
|
|
13
|
+
data-action="input-><%= identifier %>#onDateInputChange change-><%= identifier %>#onDateInputChange"
|
|
14
|
+
class="rui-input rui-input-date rui-exceptions-date-input">
|
|
29
15
|
|
|
30
16
|
<button type="button"
|
|
31
17
|
data-<%= identifier %>-target="addExdateBtn"
|
|
32
18
|
data-action="click-><%= identifier %>#addExdate"
|
|
33
19
|
disabled
|
|
34
20
|
title="<%= t('recurrence_ui.actions.add_exdate', default: 'Add exception') %>"
|
|
35
|
-
class="rui-btn rui-btn-primary
|
|
21
|
+
class="rui-btn rui-btn-primary rui-exceptions-add-btn">
|
|
36
22
|
+
|
|
37
23
|
</button>
|
|
38
24
|
</div>
|
|
25
|
+
|
|
26
|
+
<%# 3. Container for EXDATE Chips (теперь под инпутом) %>
|
|
27
|
+
<div data-<%= identifier %>-target="exdatesContainer" class="rui-chip-container">
|
|
28
|
+
<% exdates.each do |exdate| %>
|
|
29
|
+
<% date_str = exdate.is_a?(Date) || exdate.is_a?(Time) ? exdate.strftime("%Y-%m-%d") : exdate.to_s %>
|
|
30
|
+
<span class="rui-chip rui-chip--exdate" data-exdate-value="<%= date_str %>">
|
|
31
|
+
<button type="button"
|
|
32
|
+
data-action="click-><%= identifier %>#removeExdate"
|
|
33
|
+
class="rui-chip__remove-btn"
|
|
34
|
+
title="<%= t('recurrence_ui.actions.remove', default: 'Delete') %>">✕</button>
|
|
35
|
+
<span><%= rec_ui._formatDate(date_str) rescue date_str %></span>
|
|
36
|
+
</span>
|
|
37
|
+
<% end %>
|
|
38
|
+
</div>
|
|
39
39
|
</div>
|
|
40
40
|
|
|
41
41
|
<%# 4. Template for Dynamically Generated EXDATE Chips via JS %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%# app/views/recurrence_ui/_footer_actions.html.erb %>
|
|
2
2
|
<%# Footer Action Buttons (Cancel / Save) %>
|
|
3
|
-
<div class="rui-divider
|
|
3
|
+
<div class="rui-divider rui-footer-actions">
|
|
4
4
|
<%# Cancel Editing Button %>
|
|
5
5
|
<button type="button"
|
|
6
6
|
data-action="click-><%= identifier %>#cancelEdit"
|