From 9c8b663de10fc2063284c239604ab69270580d48 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Tue, 5 Jun 2018 17:27:12 +0200 Subject: [PATCH] Basic checks table --- app/controllers/checks_controller.rb | 2 +- app/frontend/scss/components/checks.scss | 5 +++ app/frontend/scss/index.scss | 1 + app/helpers/checks_helper.rb | 12 ++++++ app/views/checks/_table.html.erb | 52 +++++++++++++++--------- test/system/checks_test.rb | 3 +- 6 files changed, 53 insertions(+), 22 deletions(-) create mode 100644 app/frontend/scss/components/checks.scss diff --git a/app/controllers/checks_controller.rb b/app/controllers/checks_controller.rb index 185d488..a54650a 100644 --- a/app/controllers/checks_controller.rb +++ b/app/controllers/checks_controller.rb @@ -5,7 +5,7 @@ class ChecksController < ApplicationController after_action :verify_policy_scoped, only: :index def index - @checks = policy_scope(Check) + @checks = policy_scope(Check).order(:domain_expires_at) end def new diff --git a/app/frontend/scss/components/checks.scss b/app/frontend/scss/components/checks.scss new file mode 100644 index 0000000..26f3f5d --- /dev/null +++ b/app/frontend/scss/components/checks.scss @@ -0,0 +1,5 @@ +.table-checks { + .action a { + color: black; + } +} diff --git a/app/frontend/scss/index.scss b/app/frontend/scss/index.scss index 24da8f7..2577ff8 100644 --- a/app/frontend/scss/index.scss +++ b/app/frontend/scss/index.scss @@ -2,3 +2,4 @@ @import 'layout'; @import 'icons'; @import 'components/users'; +@import 'components/checks'; diff --git a/app/helpers/checks_helper.rb b/app/helpers/checks_helper.rb index ec8edd7..ae82a4c 100644 --- a/app/helpers/checks_helper.rb +++ b/app/helpers/checks_helper.rb @@ -1,2 +1,14 @@ module ChecksHelper + def check_kind_label(check) + check.kind.upcase + end + + def check_row_class(check) + expiry_date = check.domain_expires_at + + return unless expiry_date.present? + + return "table-danger" if expiry_date <= 2.weeks.from_now + return "table-warning" if expiry_date <= 30.days.from_now + end end diff --git a/app/views/checks/_table.html.erb b/app/views/checks/_table.html.erb index cc3da53..d177256 100644 --- a/app/views/checks/_table.html.erb +++ b/app/views/checks/_table.html.erb @@ -1,20 +1,32 @@ -<% checks.each do |check| %> -
-
Domain: <%= check.domain %>
-
Kind: <%= check.kind %>
-
Created date: <%= l(check.domain_created_at.to_date) if check.domain_created_at.present? %>
-
Update date: <%= l(check.domain_updated_at.to_date) if check.domain_updated_at.present? %>
-
Expire date: <%= l(check.domain_expires_at.to_date) if check.domain_expires_at.present? %>
- - <% if check.comment? %> -
Comment: <%= check.comment %>
- <% end %> - - <% if check.vendor? %> -
Vendor: <%= check.vendor %>
- <% end %> - -
Active: <%= check.active %>
- <%= link_to "Edit", edit_check_path(check) %> -
-<% end %> +
+ + + + + + + + + + + <% checks.each do |check| %> + + + + + + + <% end %> + +
DomainExpiry dateEdit
+ <%= check_kind_label(check) %> + + <%= check.domain %> + + <%= format_utc(check.domain_expires_at) if check.domain_expires_at.present? %> + + <%= link_to edit_check_path(check) do %> + <%== Octicons::Octicon.new("pencil").to_svg %> + <% end %> +
+
diff --git a/test/system/checks_test.rb b/test/system/checks_test.rb index 83bdcc2..467d40f 100644 --- a/test/system/checks_test.rb +++ b/test/system/checks_test.rb @@ -58,7 +58,8 @@ class ChecksTest < ApplicationSystemTestCase assert_equal checks_path, page.current_path assert page.has_css?(".alert-success") - assert page.has_content?("My comment") + @check.reload + assert_equal "My comment", @check.comment end test "add a notification" do