-
-
Notifications
You must be signed in to change notification settings - Fork 483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Contact Topics (#5388) #5517
Add Contact Topics (#5388) #5517
Conversation
0c8965a
to
50c304a
Compare
50c304a
to
0e91ce3
Compare
@elasticspoon do you need this approved and merged to continue with the original ticket? Let me know and I can help get that done. |
0e91ce3
to
7331a5d
Compare
@elasticspoon I would highly suggest adding in the views for the Casa Org portion of this. That will give you more information about the UX, which should drive the backend as much as possible. |
7331a5d
to
1ff2627
Compare
fd234e6
to
d847305
Compare
@schoork I have redone the models and such and added the org views. They are not complete yet but I think they give a general sense of the UX. I could not for the life of me figure out how to properly test policies. So those tests are currently incorrect. This PR has gotten extremely large, so I would love some more input before I move in any direction. |
51409f0
to
6e216d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it's looking great, and I can tell you've put a lot of time in this.
@schoork I'll fix the stuff you mentioned. I didn't actually you realize you would go straight to UX tests. Most of the view stuff is pretty incomplete because I didn't want to build on models that I was unsure about. |
886328e
to
bdb0390
Compare
d27d176
to
8b11a6e
Compare
fix: chevron respect select status chore: removes a TODO refactor: modal view component into subcomponents adds tests refactor: kebab to generic dropdown menu fix: unsafe save fix: view changes
8b11a6e
to
daf7fea
Compare
After talking with PMs alphabetical scoping doesn't make sense. Topics should be set in the order they are on organization, maybe in the future they should even be swappable in order.
99151a8
to
897d5f7
Compare
After some clarification on how topics are represented in reports I went back on the idea of sorting topics in alphabetical order. Casa wants them in a particular order for the reports which is not alphabetical. Depending on how it goes there might be need to implement reordering of topics. That said, apparently topics rarely change so that should not be much of an issue. |
<div class="card-style-1 pl-25 mb-10"> | ||
<h4 class="mb-20 details__topics-label">Court report <%= "topic".pluralize(@case_contact.contact_topic_answers.count) %> <span class="content-1">(optional)</span></label></h4> | ||
<div class=""> | ||
<%= form.fields_for(:contact_topic_answers) do |f| %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These change order when you move through and back in the form. A little confusing. Can we do alphabetical?
def body_content | ||
return content if content.present? | ||
|
||
Array.wrap(@text).map do |text| | ||
content_tag :p, text | ||
end.join.html_safe | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems pretty restrictive to what can go in to the body. Why not just insert what the content is and do something like this when rendering...?
<% component.with_body do %>
<p>
This topic and its related questions...
</p>
<p>
This will not affect case contacts that...
</p>
<% end %>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can do that, currently if you provide a block it overrides and text is optional.
It's just if you provide text as a string or array of strings. It gets wrapped in ptags.
it "renders the body with content" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea was to provide two different options to open the model. As a button tag and a link tag, they format slightly differently.
In most situations you would want to use a button because it's semantically correct. But in some situations you're forced to use a link like in my case. So I wanted to have both.
@elasticspoon This looks really good! A few extra notes. Nothing blocking that I can see. Ready when you are to get this across the line. |
f4ee194
to
1874ee5
Compare
fix: order answers based on topics fix: set flaky test pending fix: remove TODOs fix: lint
1874ee5
to
a822a4c
Compare
@schoork Cleaned up the remaining comments. I think we are good to go with this part. I will work on the report generation in a new PR. |
Purpose
Fixes #5388
Models
Adds 2 Models, modifies 2 existing models:
Why?
I tried an approach where every topic would be a single record, however, that leads to a lot of duplicated information in the database. Saving a details with every record would result in a lot of extra data.
Technically, we could store details and question as single objects and have each ContactTopic reference then, however, that result in issues with cross org changes to those records. Given in production there are 10 Orgs and 44k Cases that optimization did not seem worth it.
Testing
Controllers
Added contact_topic controller. Call don't happen directly, happen as nested attributes from orgs
Added policy for changing contact topics: only same org admin can CRUD.
Generation of new topics happen after org creation in controller
Tests
policy:
Views
Admin Panel:
Delete Modal:
Form Details:
Form Notes:
Tests
Systems tests focused on checking the javascript: making sure the dropdowns, read more/less work
Components
The admin panel called for a kebab menu and a modal. I chose to make them generic and extract them to ViewComponents.
DropdownMenu Component: added a generic drop down menu component to wrap bootstrap behavior. It expects a body of items and have options to change how the button for the dropdown itself appears. The default if no icon is given and label is disabled is a kebab style icon. (I would have prefered to not add the svg but the icon pack did not include that icon)
Modal Component:
Other Notes