Skip to content

Commit

Permalink
Add show table and initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmir committed Nov 13, 2024
1 parent 03f1193 commit 6f8dd8e
Show file tree
Hide file tree
Showing 17 changed files with 487 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%= render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { page_title }
header.with_description { page_description }
header.with_breadcrumbs(breadcrumb_items)
if render_create_button?
header.with_action_button(tag: :a,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ class IndexPageHeaderComponent < ApplicationComponent
include OpPrimer::ComponentHelpers
include ApplicationHelper

def initialize(project: nil)
def initialize(project: nil, meeting: nil)
super

@project = project
@meeting = meeting
end

def render_create_button?
Expand Down Expand Up @@ -63,11 +65,17 @@ def label_text
end

def page_title
I18n.t(:label_recurring_meeting_plural)
@meeting.present? ? @meeting.title + " (Meeting series)" : I18n.t(:label_recurring_meeting_plural)

Check notice on line 68 in modules/meeting/app/components/recurring_meetings/index_page_header_component.rb

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/components/recurring_meetings/index_page_header_component.rb#L68 <Style/StringConcatenation>

Prefer string interpolation to string concatenation.
Raw output
modules/meeting/app/components/recurring_meetings/index_page_header_component.rb:68:27: C: Style/StringConcatenation: Prefer string interpolation to string concatenation.
end

def page_description
"Meeting schedule goes here"
end

def breadcrumb_items
[parent_element,
{ href: @project.present? ? project_meetings_path(@project.id) : meetings_path,
text: I18n.t(:label_meeting_plural) },
page_title]
end

Expand Down
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
134 changes: 134 additions & 0 deletions modules/meeting/app/components/recurring_meetings/row_component.rb
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

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L43 <Layout/LineLength>

Line is too long. [221/130]
Raw output
modules/meeting/app/components/recurring_meetings/row_component.rb:43:131: C: Layout/LineLength: Line is too long. [221/130]
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

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L41-L47 <Metrics/AbcSize>

Assignment Branch Condition size for start_time is too high. [<0, 30, 5> 30.41/17]
Raw output
modules/meeting/app/components/recurring_meetings/row_component.rb:41:5: C: Metrics/AbcSize: Assignment Branch Condition size for start_time is too high. [<0, 30, 5> 30.41/17]

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

View workflow job for this annotation

GitHub Actions / rubocop

[rubocop] modules/meeting/app/components/recurring_meetings/row_component.rb#L65-L66 <Lint/DuplicateBranch>

Duplicate branch body detected.
Raw output
modules/meeting/app/components/recurring_meetings/row_component.rb:65:7: W: Lint/DuplicateBranch: Duplicate branch body detected.
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
Empty file.
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
Loading

0 comments on commit 6f8dd8e

Please sign in to comment.