From 440750881b32a8d8594930149492a79cdce0c0cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Tollk=C3=BChn?= Date: Wed, 23 Jul 2025 14:19:06 +0200 Subject: [PATCH] render a table in projects view --- app/views/projects/_project.html.erb | 45 +++++++++++++++------------- app/views/projects/index.html.erb | 23 ++++++++++---- 2 files changed, 42 insertions(+), 26 deletions(-) diff --git a/app/views/projects/_project.html.erb b/app/views/projects/_project.html.erb index c68459d..532fd6d 100644 --- a/app/views/projects/_project.html.erb +++ b/app/views/projects/_project.html.erb @@ -1,22 +1,27 @@ -
- <% project_view_fields.each do |attrib| %> -

- <%= attrib.to_s.humanize %>: - <%= value = project.send(attrib) %> +<% project_view_fields.each do |attrib| %> + + <% value = project.send(attrib) %> + <% if attrib == :name %> + <%= link_to value, project_path(project) %> + <% elsif attrib == :email %> + <%= mail_to value %> + <% else %> <%= value.is_a?(Date) ? l(value) : value %> -

+ <% end %> + +<% end %> +<% if project.subprojects.any? %> + +
+ + +<% else %> + + No subprojects + +<% end %> diff --git a/app/views/projects/index.html.erb b/app/views/projects/index.html.erb index 79f6079..b377188 100644 --- a/app/views/projects/index.html.erb +++ b/app/views/projects/index.html.erb @@ -5,12 +5,23 @@

Projects

- <% @projects.each do |project| %> - <%= render project %> -

- <%= link_to "Show this project", project %> -

- <% end %> + + + + <% project_view_fields.each do |attrib| %> + + <% end %> + + + + + <% @projects.each do |project| %> + + <%= render project %> + + <% end %> + +
<%= attrib.to_s.humanize %>Subprojects
<%= link_to "New project", new_project_path %>