From a96f2c9cda78d88e840ab050fff853b8f09aca7b Mon Sep 17 00:00:00 2001 From: Eric Guo Date: Thu, 12 Dec 2024 17:19:15 +0800 Subject: [PATCH] Copy from https://bbbootstrap.com/snippets/user-business-timeline-32289439 --- app/controllers/home_controller.rb | 3 + app/javascript/packs/application.scss | 2 + app/javascript/stylesheets/timeline.css | 97 +++++++++++++++++++++++++ app/views/home/index.html.erb | 58 +++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 app/javascript/stylesheets/timeline.css diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 7e41513..feb1a4a 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -11,6 +11,9 @@ def index @third_level_user_job_roles = @second_level_user_job_roles.flat_map do |user_job_role| user_job_role.managed_user_job_roles.select(&:managed_user_job_roles) end.reject { |ujr| ujr.managed_user_job_roles.blank? } + + @good_events = GoodEvent.all + @bad_events = BadEvent.all end protected diff --git a/app/javascript/packs/application.scss b/app/javascript/packs/application.scss index ab89874..1ff6196 100644 --- a/app/javascript/packs/application.scss +++ b/app/javascript/packs/application.scss @@ -69,3 +69,5 @@ // If you want to add custom CSS you can put it here. @import "stylesheets/custom"; + +@import "stylesheets/timeline"; diff --git a/app/javascript/stylesheets/timeline.css b/app/javascript/stylesheets/timeline.css new file mode 100644 index 0000000..2cb4137 --- /dev/null +++ b/app/javascript/stylesheets/timeline.css @@ -0,0 +1,97 @@ +.mt-70{ + margin-top: 70px; +} + +.mb-70{ + margin-bottom: 70px; +} + +.vertical-timeline { + width: 100%; + position: relative; + padding: 1.5rem 0 1rem; +} + +.vertical-timeline::before { + content: ''; + position: absolute; + top: 0; + left: 67px; + height: 100%; + width: 4px; + background: #e9ecef; + border-radius: .25rem; +} + +.vertical-timeline-element { + position: relative; + margin: 0 0 1rem; +} + +.vertical-timeline--animate .vertical-timeline-element-icon.bounce-in { + visibility: visible; + animation: cd-bounce-1 .8s; +} +.vertical-timeline-element-icon { + position: absolute; + top: 0; + left: 60px; +} + +.vertical-timeline-element-icon .badge-dot-xl { + box-shadow: 0 0 0 5px #fff; +} + +.badge-dot-xl { + width: 18px; + height: 18px; + position: relative; +} +.badge:empty { + display: none; +} + + +.badge-dot-xl::before { + content: ''; + width: 10px; + height: 10px; + border-radius: .25rem; + position: absolute; + left: 50%; + top: 50%; + margin: -5px 0 0 -5px; + background: #fff; +} + +.vertical-timeline-element-content { + position: relative; + margin-left: 90px; + font-size: .8rem; +} + +.vertical-timeline-element-content .timeline-title { + font-size: .8rem; + text-transform: uppercase; + margin: 0 0 .5rem; + padding: 2px 0 0; + font-weight: bold; +} + +.vertical-timeline-element-content .vertical-timeline-element-date { + display: block; + position: absolute; + left: -90px; + top: 0; + padding-right: 10px; + text-align: right; + color: #adb5bd; + font-size: .7619rem; + white-space: nowrap; +} + +.vertical-timeline-element-content:after { + content: ""; + display: table; + clear: both; +} \ No newline at end of file diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index da51425..2de0fcf 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -33,3 +33,61 @@ <% end %> + +<%# Timeline Section %> +
+ <%# Good Events Column %> +
+
+
+
Good Events
+
+ <% @good_events&.each do |event| %> +
+
+ + + +
+

<%= event.good_title %>

+

<%= event.users.pluck(:chinese_name).to_sentence %>

+ + <%= event.created_at.strftime("%I:%M %p") %> + +
+
+
+ <% end %> +
+
+
+
+ + <%# Bad Events Column %> +
+
+
+
Bad Events
+
+ <% @bad_events&.each do |event| %> +
+
+ + + +
+

<%= event.bad_title %>

+

<%= event.users.pluck(:chinese_name).to_sentence %>

+ + <%= event.created_at.strftime("%I:%M %p") %> + +
+
+
+ <% end %> +
+
+
+
+
+