-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prepare basic recurring meeting setup
- Loading branch information
1 parent
b3afdf1
commit 4ed9b8b
Showing
22 changed files
with
526 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
modules/meeting/app/components/recurring_meetings/index_page_header_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= render(Primer::OpenProject::PageHeader.new) do |header| | ||
header.with_title { page_title } | ||
header.with_breadcrumbs(breadcrumb_items) | ||
if render_create_button? | ||
header.with_action_button(tag: :a, | ||
href: dynamic_path, | ||
scheme: :primary, | ||
mobile_icon: :plus, | ||
mobile_label: label_text, | ||
aria: { label: accessibility_label_text }, | ||
title: accessibility_label_text, | ||
id: id, | ||
test_selector: "add-recurring-meeting-button") do |button| | ||
button.with_leading_visual_icon(icon: :plus) | ||
label_text | ||
end | ||
end | ||
end %> |
82 changes: 82 additions & 0 deletions
82
modules/meeting/app/components/recurring_meetings/index_page_header_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2010-2024 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 IndexPageHeaderComponent < ApplicationComponent | ||
Check notice on line 32 in modules/meeting/app/components/recurring_meetings/index_page_header_component.rb GitHub Actions / rubocop[rubocop] modules/meeting/app/components/recurring_meetings/index_page_header_component.rb#L32 <OpenProject/AddPreviewForViewComponent>
Raw output
|
||
include OpPrimer::ComponentHelpers | ||
include ApplicationHelper | ||
|
||
def initialize(project: nil) | ||
super | ||
@project = project | ||
end | ||
|
||
def render_create_button? | ||
if @project | ||
User.current.allowed_in_project?(:create_meetings, @project) | ||
else | ||
User.current.allowed_in_any_project?(:create_meetings) | ||
end | ||
end | ||
|
||
def dynamic_path | ||
polymorphic_path([:new, @project, :recurring_meeting]) | ||
end | ||
|
||
def id | ||
"add-recurring-meeting-button" | ||
end | ||
|
||
def accessibility_label_text | ||
I18n.t(:label_recurring_meeting_new) | ||
end | ||
|
||
def label_text | ||
I18n.t(:label_recurring_meeting) | ||
end | ||
|
||
def page_title | ||
I18n.t(:label_recurring_meeting_plural) | ||
end | ||
|
||
def breadcrumb_items | ||
[parent_element, | ||
page_title] | ||
end | ||
|
||
def parent_element | ||
if @project.present? | ||
{ href: project_overview_path(@project.id), text: @project.name } | ||
else | ||
{ href: home_path, text: I18n.t(:label_home) } | ||
end | ||
end | ||
end | ||
end |
49 changes: 49 additions & 0 deletions
49
modules/meeting/app/controllers/recurring_meetings_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
class RecurringMeetingsController < ApplicationController | ||
include Layout | ||
|
||
before_action :find_meeting, only: %i[show] | ||
before_action :find_optional_project, only: %i[index new create] | ||
before_action :authorize_global, only: %i[index new create] | ||
|
||
menu_item :meetings | ||
|
||
def index | ||
@recurring_meetings = | ||
if @project | ||
RecurringMeeting.visible.where(project_id: @project.id) | ||
else | ||
RecurringMeeting.visible | ||
end | ||
end | ||
|
||
def new | ||
@recurring_meeting = RecurringMeeting.new(project: @project) | ||
end | ||
|
||
def show; end | ||
|
||
def create | ||
@recurring_meeting = RecurringMeeting.new(recurring_meeting_params.merge(project: @project)) | ||
|
||
if @recurring_meeting.save | ||
flash[:notice] = t(:notice_successful_create) | ||
redirect_to action: :index | ||
else | ||
render action: :new | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_meeting | ||
@recurring_meeting = RecurringMeeting.visible.find(params[:id]) | ||
rescue ActiveRecord::RecordNotFound | ||
render_404 | ||
end | ||
|
||
def recurring_meeting_params | ||
params | ||
.require(:recurring_meeting) | ||
.permit(:title) | ||
end | ||
end |
102 changes: 102 additions & 0 deletions
102
modules/meeting/app/forms/recurring_meeting/schedule_form.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#-- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2012-2024 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::ScheduleForm < ApplicationForm | ||
include OpenProject::StaticRouting::UrlHelpers | ||
|
||
form do |form| | ||
form.select_list( | ||
name: :recurrence, | ||
input_width: :medium, | ||
label: RecurringMeeting.human_attribute_name(:recurrence), | ||
required: true, | ||
autofocus: true | ||
) do |list| | ||
list.option(label: "Daily", value: "daily") | ||
list.option(label: "Daily on workdays", value: "workdays") | ||
list.option(label: "Weekly", value: "weekly") | ||
list.option(label: "Monthly", value: "monthly") | ||
end | ||
|
||
form.check_box_group(label: "Days", layout: :horizontal, visually_hide_label: true) do |check_group| | ||
check_group.check_box( | ||
name: "monday", | ||
label: "Monday" | ||
) | ||
check_group.check_box( | ||
name: "tuesday", | ||
label: "Tuesday" | ||
) | ||
check_group.check_box( | ||
name: "wednesday", | ||
label: "Wednesaday" | ||
) | ||
check_group.check_box( | ||
name: "thursday", | ||
label: "Thursday" | ||
) | ||
check_group.check_box( | ||
name: "friday", | ||
label: "Friday" | ||
) | ||
check_group.check_box( | ||
name: "saturday", | ||
label: "Saturday" | ||
) | ||
check_group.check_box( | ||
name: "sunday", | ||
label: "Sunday" | ||
) | ||
end | ||
|
||
form.text_field( | ||
name: :interval, | ||
input_width: :medium, | ||
label: RecurringMeeting.human_attribute_name(:interval), | ||
type: :number, | ||
step: 1 | ||
) | ||
|
||
form.select_list( | ||
name: :end, | ||
input_width: :medium, | ||
label: RecurringMeeting.human_attribute_name(:ends_on), | ||
required: true, | ||
autofocus: true | ||
) do |list| | ||
list.option(label: "Never", value: "Never") | ||
list.option(label: "After a number of events", value: "after") | ||
list.option(label: "On a pecific date", value: "date") | ||
end | ||
end | ||
|
||
def initialize(meeting:) | ||
super() | ||
@meeting = meeting | ||
end | ||
end |
Oops, something went wrong.