Skip to content

Commit

Permalink
Primerize table
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmir committed Oct 11, 2024
1 parent d502c23 commit d9ebd1d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 31 deletions.
6 changes: 0 additions & 6 deletions app/components/op_primer/border_box_table_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ module OpPrimer
class BorderBoxTableComponent < TableComponent
include ComponentHelpers

def before_render
raise ArgumentError, "BorderBoxTableComponent cannot be #sortable?" if sortable?

super
end

def header_args(_column)
{}
end
Expand Down
17 changes: 8 additions & 9 deletions modules/meeting/app/components/meetings/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@
#++

module Meetings
class RowComponent < ::RowComponent
class RowComponent < ::OpPrimer::BorderBoxRowComponent
def column_args(column)
if column == :title
{ style: "grid-column: span 2" }
else
super
end
end
def project_name
helpers.link_to_project model.project, {}, {}, false
end
Expand All @@ -38,14 +45,6 @@ def title
link_to model.title, project_meeting_path(model.project, model)
end

def type
if model.is_a?(StructuredMeeting)
I18n.t("meeting.types.structured")
else
I18n.t("meeting.types.classic")
end
end

def start_time
safe_join([helpers.format_date(model.start_time), helpers.format_time(model.start_time, include_date: false)], " ")
end
Expand Down
26 changes: 10 additions & 16 deletions modules/meeting/app/components/meetings/table_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,38 +29,32 @@
#++

module Meetings
class TableComponent < ::TableComponent
class TableComponent < ::OpPrimer::BorderBoxTableComponent
options :current_project # used to determine if displaying the projects column

sortable_columns :title, :project_name, :type, :start_time, :duration, :location
columns :title, :project_name, :start_time, :duration, :location

def initial_sort
%i[start_time asc]
end

def sortable_columns_correlation
super.merge(
project_name: "projects.name",
type: "meetings.type"
)
def header_args(column)
if column == :title
{ style: "grid-column: span 2" }
else
super
end
end

def initialize_sorted_model
helpers.sort_clear

super
end

def paginated?
def sortable?
true
end

def headers
@headers ||= [
[:title, { caption: Meeting.human_attribute_name(:title) }],
current_project.blank? ? [:project_name, { caption: Meeting.human_attribute_name(:project) }] : nil,
[:type, { caption: Meeting.human_attribute_name(:type) }],
[:start_time, { caption: Meeting.human_attribute_name(:start_time) }],
[:start_time, { caption: I18n.t(:label_meeting_date_and_time) }],
[:duration, { caption: Meeting.human_attribute_name(:duration) }],
[:location, { caption: Meeting.human_attribute_name(:location) }]
].compact
Expand Down
2 changes: 2 additions & 0 deletions modules/meeting/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ en:
label_meeting_open: "Open"
label_meeting_agenda_close: "Close the agenda to begin the Minutes"
label_meeting_date_time: "Date/Time"
label_meeting_date_and_time: "Date and time"
label_meeting_diff: "Diff"
label_upcoming_meetings: "Upcoming meetings"
label_past_meetings: "Past meetings"
Expand All @@ -128,6 +129,7 @@ en:
label_time_zone: "Time zone"
label_start_date: "Start date"


meeting:
attachments:
text: "Attached files are available to all meeting participants. You can also drag and drop these into agenda item notes."
Expand Down

0 comments on commit d9ebd1d

Please sign in to comment.