Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Implement Table view for the meetings

Klaus Zanders3cf40d71a1e9
diff --git a/modules/meeting/app/cells/meetings/row_cell.rb b/modules/meeting/app/cells/meetings/row_cell.rb
new file mode 100644
index 00000000000..db2a1504e8b
--- /dev/null
+++ b/modules/meeting/app/cells/meetings/row_cell.rb
@@ -0,0 +1,26 @@
+module Meetings
+ class RowCell < ::RowCell
+ include ApplicationHelper
+
+ def project
+ link_to_project model.project, {}, {}, false
+ end
+
+ def title
+ link_to model.title, meeting_path(model)
+ end
+
+ def start_time
+ safe_join([format_date(model.start_time), format_time(model.start_time, false)], " ")
+ end
+
+ def duration
+ "#{number_with_delimiter model.duration} h"
+ end
+
+ def location
+ h(model.location)
+ end
+ end
+end
+
diff --git a/modules/meeting/app/cells/meetings/table_cell.rb b/modules/meeting/app/cells/meetings/table_cell.rb
new file mode 100644
index 00000000000..456d85d707a
--- /dev/null
+++ b/modules/meeting/app/cells/meetings/table_cell.rb
@@ -0,0 +1,32 @@
+module Meetings
+ class TableCell < ::TableCell
+ options :params # We read collapsed state from params
+ options :current_user # adds this option to those of the base class
+ options :current_project # used to determine if displaying the projects column
+
+ sortable_columns :title, :start_time, :duration, :location
+
+ def initial_sort
+ %i[start_time desc]
+ end
+
+ def paginated?
+ true
+ end
+
+ def headers
+ @headers ||= [
+ [:title, { caption: Meeting.human_attribute_name(:title) }],
+ current_project.blank? ? [:project, { caption: Meeting.human_attribute_name(:project) }] : nil,
+ [:start_time, { caption: Meeting.human_attribute_name(:start_time) }],
+ [:duration, { caption: Meeting.human_attribute_name(:duration) }],
+ [:location, { caption: Meeting.human_attribute_name(:location) }],
+ ].compact
+ end
+
+ def columns
+ @columns ||= headers.map(&:first)
+ end
+ end
+end
+
diff --git a/modules/meeting/app/controllers/meetings_controller.rb b/modules/meeting/app/controllers/meetings_controller.rb
index 970209efe12..3154fdbcef5 100644
--- a/modules/meeting/app/controllers/meetings_controller.rb
+++ b/modules/meeting/app/controllers/meetings_controller.rb
@@ -33,28 +33,19 @@ class MeetingsController < ApplicationController
before_action :find_meeting, except: %i[index new create]
before_action :convert_params, only: %i[create update]
before_action :authorize, except: [:index]
+ before_action :authorize_global, only: :index
+
helper :watchers
helper :meeting_contents
include WatchersHelper
include PaginationHelper
+ include SortHelper
menu_item :new_meeting, only: %i[new create]
def index
- scope = @project ? @project.meetings : visible_meetings
-
- # from params => today's page otherwise => first page as fallback
- tomorrows_meetings_count = scope.from_tomorrow.count
- @page_of_today = 1 + (tomorrows_meetings_count / per_page_param)
-
- page = params['page'] ? page_param : @page_of_today
-
- @meetings = scope.with_users_by_date
- .page(page)
- .per_page(per_page_param)
-
- @meetings_by_start_year_month_date = Meeting.group_by_time(@meetings)
+ @meetings = @project ? @project.meetings : visible_meetings
end
def show
diff --git a/modules/meeting/app/views/meetings/index.html.erb b/modules/meeting/app/views/meetings/index.html.erb
index 8ce1448960b..b5017d5f611 100644
--- a/modules/meeting/app/views/meetings/index.html.erb
+++ b/modules/meeting/app/views/meetings/index.html.erb
@@ -44,37 +44,12 @@ See COPYRIGHT and LICENSE files for more details.
<% end %>
<% end %>
-<% if @meetings_by_start_year_month_date.empty? -%>
+<% if @meetings.empty? -%>
<%= no_results_box %>
<% else -%>
-<div class="meetings meetings_by_month_year" id="activity">
-<% @meetings_by_start_year_month_date.each do |year,meetings_by_start_month_date| -%>
-<% meetings_by_start_month_date.each do |month,meetings_by_start_date| -%>
- <h3 class="month_year"><%= ::I18n.t('date.month_names')[month] + " #{year}" %></h3>
- <div class="meetings_by_date">
- <% meetings_by_start_date.each do |date,meetings| -%>
- <h4 id="<%= date.strftime("%m-%d-%Y") %>" class="date"><%= format_activity_day(date) %></h4>
- <dl class="meetings">
- <% meetings.each do |meeting| -%>
- <dt class="meeting" id="meeting-<%= meeting.id %>">
- <%= link_to h(meeting.title), :controller => '/meetings', :action => 'show', :id => meeting %>
- </dt>
- <dd class="meeting" id="meeting-<%= meeting.id %>">
- <p><strong><%= Meeting.human_attribute_name(:time) %></strong>: <%= format_time meeting.start_time, false %>-<%= format_time meeting.end_time, false %></p>
- <p><strong><%= Meeting.human_attribute_name(:location) %></strong>: <%=h meeting.location %></p>
- <p><strong><%= Meeting.human_attribute_name(:participants_invited) %></strong> (<%= meeting.participants.select(&:invited).count %>): <%= format_participant_list meeting.participants.select(&:invited) %></p>
- <p><strong><%= Meeting.human_attribute_name(:participants_attended) %></strong> (<%= meeting.participants.select(&:attended).count %>): <%= format_participant_list meeting.participants.select(&:attended) %></p>
- </dd>
- <% end -%>
- </dl>
- <% end -%>
- </div>
+<%= rails_cell Meetings::TableCell,
+ @meetings,
+ current_user: current_user,
+ current_project: @project,
+ params: params %>
<% end -%>
-<% end -%>
-</div>
-<% end -%>
-
-<p class="pagination">
- <%= link_to_content_update(t(:label_today), page: @page_of_today, anchor: Date.today.strftime("%m-%d-%Y")) %>
- <%= pagination_links_full @meetings, :container => false %>
-</p>