Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

add controller

Oliver Günther989deb6812a6
diff --git a/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts b/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts
new file mode 100644
index 00000000000..8cbcfd66d28
--- /dev/null
+++ b/frontend/src/stimulus/controllers/dynamic/recurring-meetings/form.controller.ts
@@ -0,0 +1,17 @@
+import { ApplicationController } from 'stimulus-use';
+
+export default class OpRecurringMeetingsFormController extends ApplicationController {
+ static targets = [
+ 'frequency',
+ 'interval',
+ ];
+
+ declare readonly frequencyTarget:HTMLSelectElement;
+ declare readonly intervalTarget:HTMLInputElement;
+
+ updateFrequencyText():void {
+ const frequency = this.frequencyTarget.value;
+ const interval = this.intervalTarget.value;
+ this.intervalTarget.placeholder = `Every ${frequency}`;
+ }
+}
diff --git a/frontend/src/stimulus/controllers/op-application.controller.ts b/frontend/src/stimulus/controllers/op-application.controller.ts
index e1234cc820e..fa3bb750ff9 100644
--- a/frontend/src/stimulus/controllers/op-application.controller.ts
+++ b/frontend/src/stimulus/controllers/op-application.controller.ts
@@ -8,11 +8,11 @@ export class OpApplicationController extends ApplicationController {
dynamicTargetConnected(target:HTMLElement) {
const controllers = (target.dataset.controller as string).split(' ');
+ const registered = this.application.controllers.map((controller) => controller.identifier);
controllers.forEach((controller) => {
const path = this.derivePath(controller);
-
- if (!this.loaded.has(controller)) {
+ if (!registered.includes(controller) && !this.loaded.has(controller)) {
this.loaded.add(controller);
void import(/* webpackChunkName: "[request]" */`./dynamic/${path}.controller`)
.then((imported:{ default:ControllerConstructor }) => this.application.register(controller, imported.default))
diff --git a/modules/meeting/app/components/meetings/index/form_component.html.erb b/modules/meeting/app/components/meetings/index/form_component.html.erb
index 82f8c581a1e..df5076b39ab 100644
--- a/modules/meeting/app/components/meetings/index/form_component.html.erb
+++ b/modules/meeting/app/components/meetings/index/form_component.html.erb
@@ -6,7 +6,8 @@
method: form_method,
data: {
turbo: true,
- controller: "show-when-value-selected"
+ controller: "show-when-value-selected recurring-meetings--form",
+ "application-target": "dynamic"
},
html: {
id: 'meeting-form'
@@ -67,6 +68,10 @@
end
end
+ modal_body.with_row(mt: 1) do
+ render(RecurringMeeting::EndAfter.new(f))
+ end
+
modal_body.with_row(mt: 3) do
render(RecurringMeeting::EndAfter.new(f))
end
diff --git a/modules/meeting/app/components/recurring_meetings/frequency_text_component.rb b/modules/meeting/app/components/recurring_meetings/frequency_text_component.rb
new file mode 100644
index 00000000000..1ba4d9707b0
--- /dev/null
+++ b/modules/meeting/app/components/recurring_meetings/frequency_text_component.rb
@@ -0,0 +1,56 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module RecurringMeetings
+ class FrequencyTextComponent < ApplicationComponent
+ include ApplicationHelper
+ include OpTurbo::Streamable
+ include OpPrimer::ComponentHelpers
+
+ def initialize(frequency:, interval:)
+ super
+
+ @frequency = frequency
+ @interval = interval
+ @current_count = count
+ @direction = direction
+ @max_count = max_count
+ end
+
+ def label
+ count = @max_count - @current_count
+ label_suffix = count == 1 ? "_singular" : ""
+
+ if @direction == "past"
+ I18n.t("label_recurring_meeting_more_past#{label_suffix}", count:)
+ else
+ I18n.t("label_recurring_meeting_more#{label_suffix}", count:, schedule: @meeting.schedule_in_words)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/forms/recurring_meeting/frequency.rb b/modules/meeting/app/forms/recurring_meeting/frequency.rb
index 06992662d22..66262baa1a7 100644
--- a/modules/meeting/app/forms/recurring_meeting/frequency.rb
+++ b/modules/meeting/app/forms/recurring_meeting/frequency.rb
@@ -33,7 +33,9 @@ class RecurringMeeting::Frequency < ApplicationForm
label: I18n.t("activerecord.attributes.recurring_meeting.frequency"),
data: {
target_name: "frequency",
- "show-when-value-selected-target": "cause"
+ "recurring-meetings--form-target": "frequency",
+ "show-when-value-selected-target": "cause",
+ action: "input->recurring-meetings--form#updateFrequencyText"
}
) do |list|
RecurringMeeting.frequencies.each_key do |value|
diff --git a/modules/meeting/app/forms/recurring_meeting/interval.rb b/modules/meeting/app/forms/recurring_meeting/interval.rb
index 9d598246dd6..c28f27f4505 100644
--- a/modules/meeting/app/forms/recurring_meeting/interval.rb
+++ b/modules/meeting/app/forms/recurring_meeting/interval.rb
@@ -32,7 +32,11 @@ class RecurringMeeting::Interval < ApplicationForm
name: :interval,
type: :number,
label: I18n.t("activerecord.attributes.recurring_meeting.interval"),
- caption: I18n.t("recurring_meeting.interval.instructions")
+ caption: I18n.t("recurring_meeting.interval.instructions"),
+ data: {
+ "recurring-meetings--form-target": "interval",
+ action: "input->recurring-meetings--form#updateFrequencyText"
+ }
)
end
end