Skip to content

Commit

Permalink
Add frequency/iterations form
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverguenther committed Nov 11, 2024
1 parent d02b49b commit b3985d1
Show file tree
Hide file tree
Showing 8 changed files with 129 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
scope: :meeting,
model: @meeting,
method: :post,
data: { turbo: true },
data: {
turbo: true,
controller: "show-when-value-selected"
},
html: { :id => 'meeting-form' },
url: {:controller => '/meetings', :action => 'create', :project_id => @project}
) do |f|
Expand Down Expand Up @@ -37,14 +40,30 @@
render(Meeting::Location.new(f))
end

modal_body.with_row do
render(Meeting::Type.new(f))
end

if @meeting.is_a?(RecurringMeeting)
modal_body.with_row(mt: 3) do
render(Meeting::RecurringFrequency.new(f))
render(RecurringMeeting::Frequency.new(f))
end

modal_body.with_row(mt: 3) do
render(RecurringMeeting::EndAfter.new(f))
end

modal_body.with_row(mt: 3,
data: { value: "specific_date", "show-when-value-selected-target": "effect" }
) do
render(RecurringMeeting::SpecificDate.new(f))
end

modal_body.with_row(mt: 3,
hidden: true,
data: { value: "iterations", "show-when-value-selected-target": "effect" }) do
render(RecurringMeeting::Iterations.new(f))
end
end

modal_body.with_row do
render(Meeting::Type.new(f))
end

if @copy_from
Expand Down
42 changes: 42 additions & 0 deletions modules/meeting/app/forms/recurring_meeting/end_after.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#-- 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.
#++

class RecurringMeeting::EndAfter < ApplicationForm
form do |meeting_form|
meeting_form.select_list(
name: "end_after",
label: I18n.t("activerecord.attributes.recurring_meeting.end_after"),
data: {
"show-when-value-selected-target": "cause"
}
) do |list|
list.option(value: "specific_date", label: I18n.t("recurring_meeting.end_after.specific_date"))
list.option(value: "iterations", label: I18n.t("recurring_meeting.end_after.iterations"))
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,11 @@
# See COPYRIGHT and LICENSE files for more details.
#++

class Meeting::RecurringFrequency < ApplicationForm
class RecurringMeeting::Frequency < ApplicationForm
form do |meeting_form|
meeting_form.text_field(
name: :title,
required: true,
label: Meeting.human_attribute_name(:title),
placeholder: Meeting.human_attribute_name(:title),
visually_hide_label: false
)
meeting_form.select_list(
name: :frequency,
name: "frequency",
label: I18n.t("activerecord.attributes.recurring_meeting.frequency"),

Check notice on line 33 in modules/meeting/app/forms/recurring_meeting/frequency.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/forms/recurring_meeting/frequency.rb#L33 <Style/TrailingCommaInArguments>

Avoid comma after the last parameter of a method call.
Raw output
modules/meeting/app/forms/recurring_meeting/frequency.rb:33:75: C: Style/TrailingCommaInArguments: Avoid comma after the last parameter of a method call.
input_width: :medium,
caption: I18n.t("saml.instructions.signature_method", default_option: "RSA SHA-1")
) do |list|
%i[daily weekly monthly yearly].each do |value|
label = I18n.t(:"recurring_meeting.frequency.#{value}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 2012-2024 the OpenProject GmbH
# 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.
Expand All @@ -26,14 +26,12 @@
# See COPYRIGHT and LICENSE files for more details.
#++

class RecurringMeeting::TitleForm < ApplicationForm
include OpenProject::StaticRouting::UrlHelpers

form do |form|
end

def initialize(meeting:)
super()
@meeting = meeting
class RecurringMeeting::Iterations < ApplicationForm
form do |meeting_form|
meeting_form.text_field(
name: :iterations,
type: :number,
label: I18n.t("activerecord.attributes.recurring_meeting.iterations")
)
end
end
120 changes: 0 additions & 120 deletions modules/meeting/app/forms/recurring_meeting/schedule_form.rb

This file was deleted.

46 changes: 46 additions & 0 deletions modules/meeting/app/forms/recurring_meeting/specific_date.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#-- 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.
#++

class RecurringMeeting::SpecificDate < ApplicationForm
form do |meeting_form|
meeting_form.text_field(
name: :end_date,
type: "date",
value: @initial_value,
placeholder: Meeting.human_attribute_name(:end_date),
label: Meeting.human_attribute_name(:end_date),
leading_visual: { icon: :calendar },
required: false,
autofocus: false
)
end

def initialize(initial_value: 1.year.from_now.strftime("%Y-%m-%d"))
@initial_value = initial_value
end

Check warning on line 45 in modules/meeting/app/forms/recurring_meeting/specific_date.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/forms/recurring_meeting/specific_date.rb#L43-L45 <Lint/MissingSuper>

Call `super` to initialize state of the parent class.
Raw output
modules/meeting/app/forms/recurring_meeting/specific_date.rb:43:3: W: Lint/MissingSuper: Call `super` to initialize state of the parent class.
end
5 changes: 4 additions & 1 deletion modules/meeting/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ en:
recurring_meeting:
frequency: "Frequency"
end_after: "End after"
iterations: "Iterations"
iterations: "Occurrences"
errors:
messages:
invalid_time_format: "is not a valid time. Required format: HH:MM"
Expand Down Expand Up @@ -191,6 +191,9 @@ en:
weekly: "Weekly"
monthly: "Monthly"
yearly: "Yearly"
end_after:
specific_date: "A specific date"
iterations: "A number of occurrences"

notice_successful_notification: "Notification sent successfully"
notice_timezone_missing: No time zone is set and %{zone} is assumed. To choose your time zone, please click here.
Expand Down
3 changes: 2 additions & 1 deletion script/anonymize-sql-dump
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ FOR table_name, column_name IN (
'role_permissions',
'enabled_modules',
'two_factor_authentication_devices',
'tokens'
'tokens',
'job_statuses'
)
AND information_schema.columns.column_name NOT LIKE '%type%'
AND NOT (information_schema.columns.table_name = 'grids' AND information_schema.columns.column_name = 'options')
Expand Down

0 comments on commit b3985d1

Please sign in to comment.