-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend
meeting#new
form to allow creating "global" meetings
The `meeting#new` form toggles as necessary between the project-scoped version and the global version. **TODO**: When a project is selected, I believe because @project is present, that the sidebar and top-menu project dropdown get populated with the project data as if it were now scoped. Some work needs to go in to perhaps modifying the instance variable name so that this doesn't get toggled but I'll ask if there's a pattern for this already in mind before going down that rabbit-hole.
- Loading branch information
1 parent
2bcc35a
commit 8d5382f
Showing
25 changed files
with
767 additions
and
217 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
10 changes: 10 additions & 0 deletions
10
modules/meeting/app/components/meetings/add_button_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,10 @@ | ||
<li class="<%= li_css_class %>"> | ||
<a href="<%= dynamic_path %>" | ||
id="<%= id %>" | ||
title="<%= title %>" | ||
arial-label="<%= aria_label %>" | ||
class="<%= link_css_class %>"> | ||
<%= icon %> | ||
<%= label %> | ||
</a> | ||
</li> |
78 changes: 78 additions & 0 deletions
78
modules/meeting/app/components/meetings/add_button_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,78 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2023 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 Meetings | ||
class AddButtonComponent < ::RailsComponent | ||
options :current_project | ||
|
||
def render? | ||
if current_project | ||
User.current.allowed_to?(:create_meetings, current_project) | ||
else | ||
User.current.allowed_to_globally?(:create_meetings) | ||
end | ||
end | ||
|
||
def li_css_class | ||
'toolbar-item' | ||
end | ||
|
||
def dynamic_path | ||
polymorphic_path([:new, current_project, :meeting]) | ||
end | ||
|
||
def id | ||
'add-meeting-button' | ||
end | ||
|
||
def title | ||
I18n.t(:label_meeting_new) | ||
end | ||
|
||
def aria_label | ||
I18n.t(:label_meeting_new) | ||
end | ||
|
||
def link_css_class | ||
'button -alt-highlight' | ||
end | ||
|
||
def label | ||
content_tag(:span, | ||
I18n.t(:label_meeting), | ||
class: 'button--text') | ||
end | ||
|
||
def icon | ||
helpers.op_icon('button--icon icon-add') | ||
end | ||
end | ||
end |
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,77 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- copyright | ||
# OpenProject is an open source project management software. | ||
# Copyright (C) 2023 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 BaseController < ApplicationController | ||
around_action :set_time_zone | ||
|
||
helper :watchers | ||
helper :meeting_contents | ||
include WatchersHelper | ||
include PaginationHelper | ||
include SortHelper | ||
|
||
private | ||
|
||
def set_time_zone(&) | ||
zone = User.current.time_zone | ||
if zone.nil? | ||
localzone = Time.current.utc_offset | ||
localzone -= 3600 if Time.current.dst? | ||
zone = ::ActiveSupport::TimeZone[localzone] | ||
end | ||
|
||
Time.use_zone(zone, &) | ||
end | ||
|
||
def convert_params | ||
if params.key?(:meeting) | ||
# We do some preprocessing of `meeting_params` that we will store in this | ||
# instance variable. | ||
@converted_params = meeting_params.to_h | ||
|
||
@converted_params[:duration] = @converted_params[:duration].to_hours | ||
# Force defaults on participants | ||
@converted_params[:participants_attributes] ||= {} | ||
@converted_params[:participants_attributes].each { |p| p.reverse_merge! attended: false, invited: false } | ||
end | ||
end | ||
|
||
def populate_meeting_with_converted_params | ||
@meeting.participants.clear # Start with a clean set of participants | ||
@meeting.participants_attributes = @converted_params.delete(:participants_attributes) | ||
@meeting.attributes = @converted_params | ||
end | ||
|
||
def meeting_params | ||
params.require(:meeting).permit(:title, :location, :start_time, :duration, :start_date, :start_time_hour, | ||
participants_attributes: %i[email name invited attended user user_id meeting id]) | ||
end | ||
end |
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
Oops, something went wrong.