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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Implement table component
Klaus Zandersf3fcc7300552
diff --git a/modules/costs/app/components/my/time_tracking/daily_entries_table.rb b/modules/costs/app/components/my/time_tracking/daily_entries_table.rbnew file mode 100644index 00000000000..f2b9ded2c4e--- /dev/null+++ b/modules/costs/app/components/my/time_tracking/daily_entries_table.rb@@ -0,0 +1,60 @@+# 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 My+ module TimeTracking+ class DailyEntriesTable < OpPrimer::BorderBoxTableComponent+ columns :time, :hours, :subject, :project, :activity, :comments++ options :date, :time_entries++ def row_class+ TimeEntryRow+ end++ def mobile_title+ TimeEntry.model_name.human(count: 2)+ end++ def has_actions? = true++ def headers+ [+ [:time, { caption: "Time" }],+ [:hours, { caption: "Hours" }],+ [:subject, { caption: "Subject" }],+ [:project, { caption: "Project" }],+ [:activity, { caption: "Activity" }],+ [:comments, { caption: "Comments" }]+ ]+ end+ end+ end+enddiff --git a/modules/costs/app/components/my/time_tracking/table_component.html.erb b/modules/costs/app/components/my/time_tracking/table_component.html.erbindex 620d41e1554..cd7bb90c3fe 100644--- a/modules/costs/app/components/my/time_tracking/table_component.html.erb+++ b/modules/costs/app/components/my/time_tracking/table_component.html.erb@@ -21,16 +21,8 @@) { "Log Time" }end %>- <ul><%- range.each do |date| %>- <li>- <h3><%= date %> (<%= time_entries_by_day[date].count %> entries, <%= total_hours_per_day(date) %>)</h3>- <ul>- <%- time_entries_by_day[date].each do |te| %>- <li><%= te.spent_on %> <%= te.hours %>h - <%= te.work_package.subject %></li>- <%- end %>- </ul>- </li>- <%- end %>- </ul>+ <h2><%= date %></h2>+ <%= render(My::TimeTracking::DailyEntriesTable.new(rows: time_entries_by_day[date])) %>+ <%- end %><%- end %>diff --git a/modules/costs/app/components/my/time_tracking/time_entry_row.rb b/modules/costs/app/components/my/time_tracking/time_entry_row.rbnew file mode 100644index 00000000000..9097653131b--- /dev/null+++ b/modules/costs/app/components/my/time_tracking/time_entry_row.rb@@ -0,0 +1,87 @@+# 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 My+ module TimeTracking+ class TimeEntryRow < OpPrimer::BorderBoxRowComponent+ 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": t("label_more"), scheme: :invisible)+ menu.with_item(+ content_arguments: {+ data: {+ "turbo-stream" => true+ }+ },+ tag: :a,+ label: t("label_edit"),+ href: dialog_time_entry_path(time_entry, onlyMe: true)+ ) do |item|+ item.with_leading_visual_icon(icon: :pencil)+ end+ end+ end++ def time+ time_entry.start_timestamp || ""+ end++ def hours+ DurationConverter.output(time_entry.hours, format: :hours_and_minutes)+ end++ def subject+ "##{time_entry.work_package.id} - #{time_entry.work_package.subject}"+ end++ def project+ time_entry.project.name+ end++ def activity+ time_entry.activity&.name+ end++ delegate :comments, to: :time_entry++ private++ def time_entry+ model+ end+ end+ end+end