From 886328e457adf1bc5d10a142f4f7eb49b52e5c17 Mon Sep 17 00:00:00 2001 From: YuriBocharov Date: Thu, 29 Feb 2024 18:32:19 -0500 Subject: [PATCH] feat: frontend changes based on feedback --- app/components/kebab_menu_component.html.erb | 12 ++++ app/components/kebab_menu_component.rb | 9 +++ app/components/modal_component.html.erb | 43 ++++++++++++ app/components/modal_component.rb | 17 +++++ app/helpers/view_helper.rb | 4 ++ app/views/casa_org/_contact_topics.html.erb | 70 ++++++++++--------- .../form/_contact_topic_notes.html.erb | 6 +- spec/system/case_contacts/create_spec.rb | 28 +++++--- 8 files changed, 146 insertions(+), 43 deletions(-) create mode 100644 app/components/kebab_menu_component.html.erb create mode 100644 app/components/kebab_menu_component.rb create mode 100644 app/components/modal_component.html.erb create mode 100644 app/components/modal_component.rb create mode 100644 app/helpers/view_helper.rb diff --git a/app/components/kebab_menu_component.html.erb b/app/components/kebab_menu_component.html.erb new file mode 100644 index 0000000000..9904fd8358 --- /dev/null +++ b/app/components/kebab_menu_component.html.erb @@ -0,0 +1,12 @@ + diff --git a/app/components/kebab_menu_component.rb b/app/components/kebab_menu_component.rb new file mode 100644 index 0000000000..52ae5d2a7c --- /dev/null +++ b/app/components/kebab_menu_component.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +class KebabMenuComponent < ViewComponent::Base + renders_one :menu_content + + def initialize(menu_title: "Menu") + @menu_title = menu_title + end +end diff --git a/app/components/modal_component.html.erb b/app/components/modal_component.html.erb new file mode 100644 index 0000000000..27c59567f8 --- /dev/null +++ b/app/components/modal_component.html.erb @@ -0,0 +1,43 @@ +<% if @has_button %> + +<% end %> + +<% if @has_modal %> + +<% end %> diff --git a/app/components/modal_component.rb b/app/components/modal_component.rb new file mode 100644 index 0000000000..9e51bed1d5 --- /dev/null +++ b/app/components/modal_component.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +class ModalComponent < ViewComponent::Base + renders_one :open_button + renders_one :modal_header + renders_one :modal_content + renders_one :modal_footer + + def initialize(button: true, modal: true, button_value: nil, header_text: nil, body_text: nil, id: Digest::UUID.uuid_v4) + @has_button = button + @has_modal = modal + @button_value = button_value + @header_text = header_text + @body_text = body_text + @id = id + end +end diff --git a/app/helpers/view_helper.rb b/app/helpers/view_helper.rb new file mode 100644 index 0000000000..f0d887e54f --- /dev/null +++ b/app/helpers/view_helper.rb @@ -0,0 +1,4 @@ +module ViewHelper + def kebab_menu(&block) + end +end diff --git a/app/views/casa_org/_contact_topics.html.erb b/app/views/casa_org/_contact_topics.html.erb index 26ff81f7f4..81a7273b2f 100644 --- a/app/views/casa_org/_contact_topics.html.erb +++ b/app/views/casa_org/_contact_topics.html.erb @@ -19,42 +19,48 @@
- - - - - - + + + + + - <% @contact_topics.each do |contact_topic| %> - - - - - + + + + + + <%= render(ModalComponent.new( + id: "contact_topic-#{contact_topic.id}", + button: false, + header_text: "Delete Court Report Topic?" + )) do |component| %> + <% component.with_modal_footer do %> + <%= link_to soft_delete_contact_topic_path(contact_topic), method: :delete, + class: "btn-sm main-btn danger-btn btn-hover ms-auto" do %> + + Delete Court Report Topic + <% end %> <% end %> - <%= link_to soft_delete_contact_topic_path(contact_topic), - method: :delete, data: { confirm: "Are you sure that you want to delete this court topic item?" } do %> -
- -
+ <% component.with_modal_content do %> +

This topic and its related questions will be deleted and will no longer be presented while filling out case contacts.

+
+

This will not affect case contacts that have already been created.

<% end %> - - - <% end %> + <% end %> + <% end %>
QuestionDetailsActive?Actions
QuestionDetailsActive?
- <%= contact_topic.question %> - <%= contact_topic.details %> - <%= contact_topic.active ? "Yes" : "No" %> - - <%= link_to edit_contact_topic_path(contact_topic) do %> -
- -
+ <% @contact_topics.each do |contact_topic| %> +
+ <%= contact_topic.question %> + <%= contact_topic.details %> + <%= contact_topic.active ? "Yes" : "No" %> + + <%= render(KebabMenuComponent.new(menu_title: "Actions Menu")) do %> +
  • <%= link_to "Edit", edit_contact_topic_path(contact_topic), class: "dropdown-item" %>
  • +
  • <%= render(ModalComponent.new( id: "contact_topic-#{contact_topic.id}", modal: false, button_value: "Delete")) %>
  • + <% end %> +
    diff --git a/app/views/case_contacts/form/_contact_topic_notes.html.erb b/app/views/case_contacts/form/_contact_topic_notes.html.erb index 7935cbd290..5670f96c20 100644 --- a/app/views/case_contacts/form/_contact_topic_notes.html.erb +++ b/app/views/case_contacts/form/_contact_topic_notes.html.erb @@ -24,15 +24,15 @@
    " id="<%= answer_id %>"> Court report questions: - + ... [read more] -

    <%= topic.details %>

    - +

    <%= topic.details %>

    +