-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<%= render(Primer::OpenProject::SubHeader.new(data: { | ||
controller: "filter--filters-form", | ||
"application-target": "dynamic", | ||
"filter--filters-form-output-format-value": "json", | ||
})) do |subheader| | ||
# subheader.with_filter_component do | ||
# render(Meetings::MeetingFilterButtonComponent.new(query: @query, project: @project)) | ||
# end | ||
|
||
if render_create_button? | ||
subheader.with_action_component do | ||
|
||
render Primer::Alpha::ActionMenu.new(anchor_align: :end) do |menu| | ||
menu.with_show_button(scheme: :primary, | ||
test_selector: "add-meeting-button", | ||
mobile_icon: :plus, | ||
mobile_label: label_text, | ||
id: id, | ||
title: accessibility_label_text, | ||
aria: { label: accessibility_label_text }) do |button| | ||
button.with_leading_visual_icon(icon: :plus) | ||
button.with_trailing_action_icon(icon: :"triangle-down") | ||
I18n.t(:label_meeting) | ||
end | ||
|
||
menu.with_item(label: I18n.t("meeting.types.structured"), | ||
tag: :a, | ||
href: new_dialog_meetings_path(project_id: @project&.id, type: :structured), | ||
content_arguments: { data: { controller: "async-dialog" }} | ||
) | ||
|
||
if OpenProject::FeatureDecisions.recurring_meetings_active? | ||
menu.with_item(label: I18n.t("meeting.types.recurring"), | ||
tag: :a, | ||
href: new_dialog_meetings_path(project_id: @project&.id, type: :recurring), | ||
content_arguments: { data: { controller: "async-dialog" }} | ||
) | ||
end | ||
|
||
menu.with_item(label: I18n.t("meeting.types.classic"), | ||
tag: :a, | ||
href: dynamic_path | ||
) | ||
end | ||
end | ||
end | ||
|
||
# subheader.with_bottom_pane_component(mt: 0) do | ||
# render(Meetings::MeetingFiltersComponent.new(query: @query, project: @project)) | ||
# end | ||
end %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# frozen_string_literal: true | ||
|
||
# -- 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 | ||
# rubocop:disable OpenProject/AddPreviewForViewComponent | ||
class IndexSubHeaderComponent < ApplicationComponent | ||
# rubocop:enable OpenProject/AddPreviewForViewComponent | ||
include ApplicationHelper | ||
|
||
def initialize(query: nil, project: nil) | ||
super | ||
@query = query | ||
@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, :meeting]) | ||
end | ||
|
||
def id | ||
"add-meeting-button" | ||
end | ||
|
||
def accessibility_label_text | ||
I18n.t(:label_meeting_new) | ||
end | ||
|
||
def label_text | ||
I18n.t(:label_meeting) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
# frozen_string_literal: true | ||
|
||
#-- 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 RowComponent < ::OpPrimer::BorderBoxRowComponent | ||
def column_args(column) | ||
if column == :title | ||
{ style: "grid-column: span 2" } | ||
else | ||
super | ||
end | ||
end | ||
|
||
def start_time | ||
if model["state"] == "open" || model["state"] == "closed" | ||
link_to safe_join([helpers.format_date(model["start_time"]), helpers.format_time(model["start_time"], include_date: false)], " "), project_meeting_path(Project.find(model["project_id"]), Meeting.find(model["id"])) | ||
Check notice on line 43 in modules/meeting/app/components/recurring_meetings/row_component.rb GitHub Actions / rubocop[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L43 <Layout/LineLength>
Raw output
|
||
else | ||
safe_join([helpers.format_date(model["start_time"]), helpers.format_time(model["start_time"], include_date: false)], " ") | ||
end | ||
end | ||
Check notice on line 47 in modules/meeting/app/components/recurring_meetings/row_component.rb GitHub Actions / rubocop[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L41-L47 <Metrics/AbcSize>
Raw output
|
||
|
||
def relative_time | ||
render(OpPrimer::RelativeTimeComponent.new(datetime: model["start_time"], prefix: I18n.t(:label_on))) | ||
end | ||
|
||
def last_edited | ||
safe_join([helpers.format_date(model["updated_at"]), helpers.format_time(model["updated_at"], include_date: false)], " ") | ||
end | ||
|
||
def status | ||
case model["state"] | ||
when "open" | ||
scheme = :success | ||
when "scheduled" | ||
scheme = :secondary | ||
when "cancelled" | ||
scheme = :severe | ||
when "closed" | ||
scheme = :secondary | ||
Check warning on line 66 in modules/meeting/app/components/recurring_meetings/row_component.rb GitHub Actions / rubocop[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L65-L66 <Lint/DuplicateBranch>
Raw output
|
||
end | ||
|
||
render(Primer::Beta::Label.new(scheme:)) do | ||
render(Primer::Beta::Text.new) { t("label_meeting_state_#{model['state']}") } | ||
end | ||
end | ||
|
||
def button | ||
if model["template"] == true | ||
render(Primer::Beta::Text.new) { "TEMPLATE" } | ||
elsif model["state"] != "open" | ||
link_to "INITIALIZE", init_meeting_path(Meeting.find(model["id"]), date: model["start_time"]) | ||
end | ||
end | ||
|
||
def button_links | ||
[ | ||
action_menu | ||
] | ||
end | ||
|
||
def action_menu | ||
render(Primer::Alpha::ActionMenu.new) do |menu| | ||
menu.with_show_button(icon: "kebab-horizontal", | ||
"aria-label": "More", | ||
scheme: :invisible, | ||
data: { | ||
"test-selector": "more-button" | ||
}) | ||
|
||
ical_action(menu) | ||
|
||
if delete_allowed? | ||
delete_action(menu) | ||
end | ||
end | ||
end | ||
|
||
def ical_action(menu) | ||
menu.with_item(label: I18n.t(:label_icalendar_download), | ||
href: download_ics_meeting_path(Meeting.find(model["id"])), | ||
content_arguments: { | ||
data: { turbo: false } | ||
}) do |item| | ||
item.with_leading_visual_icon(icon: :download) | ||
end | ||
end | ||
|
||
def delete_action(menu) | ||
menu.with_item(label: I18n.t(:label_recurring_meeting_cancel), | ||
scheme: :danger, | ||
href: meeting_path(Meeting.find(model["id"])), | ||
form_arguments: { | ||
method: :delete, data: { confirm: I18n.t("text_are_you_sure"), turbo: false } | ||
}) do |item| | ||
item.with_leading_visual_icon(icon: :trash) | ||
end | ||
end | ||
|
||
def delete_allowed? | ||
User.current.allowed_in_project?(:delete_meetings, Project.find(model["project_id"])) | ||
end | ||
|
||
def copy_allowed? | ||
User.current.allowed_in_project?(:create_meetings, Project.find(model["project_id"])) | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#-- 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 ShowComponent < ApplicationComponent | ||
include ApplicationHelper | ||
include OpPrimer::ComponentHelpers | ||
|
||
def initialize(meeting:, project:) | ||
super | ||
|
||
@meeting = meeting | ||
@project = project | ||
end | ||
end | ||
end |