Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion app/assets/tailwind/application.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,14 @@
box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.input-field:hover:not(:focus) {
.input-field:hover:not(:focus):not(:disabled) {
@apply border-gray-400;
}

.input-field:disabled {
@apply bg-gray-100 text-gray-500;
}

.select-field {
@apply w-full border border-gray-300 rounded-lg text-sm bg-white transition-all duration-200 cursor-pointer;
padding: 0.625rem 2.5rem 0.625rem 0.875rem;
Expand Down
46 changes: 45 additions & 1 deletion app/views/providers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@
<div class="space-y-6">
<%= render "shared/errors", errors: provider.errors.full_messages, resource_name: provider.class.name %>

<!-- File name prefix uneditable notice -->
<% if @provider&.topics.any? %>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can reduce dots number here if you extract a method for provider model, then you can call it here and there

<div id="file-name-prefix-uneditable-notice" class="bg-blue-50 border border-blue-200 rounded-lg p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
</div>
<div class="ml-3">
<p class="text-sm text-blue-700 m-0">
There are topics associated with this provider, so the file names are established and the file name prefix can't be edited.
</p>
</div>
</div>
</div>
<% end %>


<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">

<!-- Provider Name -->
Expand All @@ -11,7 +30,7 @@
<span class="text-red-500">*</span>
<% end %>
<%= form.text_field :name,
placeholder: "Enter provider name (e.g., Johns Hopkins, Mayo Clinic)",
placeholder: "e.g., Johns Hopkins, Mayo Clinic",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the placeholder here to be consistent with the rest of them. I think it is sufficient to have the placeholder give examples, as our help text says what the input should be

autofocus: true,
class: "input-field bg-gray-50" %>
<p class="help-text">The official name of the healthcare provider or organization.</p>
Expand All @@ -29,6 +48,31 @@
<p class="help-text">The type or category of healthcare provider.</p>
</div>

<!-- File name prefix -->
<% if @provider&.topics.any? %>
<div>
<%= form.label :file_name_prefix, class: "input-label" do %>
File name prefix
<% end %>
<%= form.text_field :file_name_prefix,
disabled: true,
value: @provider.file_name_prefix,
class: "input-field bg-gray-50"
%>
<p class="help-text">The prefix to use for this provider's uploads.</p>
</div>
<% else %>
<div>
<%= form.label :file_name_prefix, class: "input-label" do %>
File name prefix
<% end %>
<%= form.text_field :file_name_prefix,
placeholder: "e.g., 123_who_guidelines",
class: "input-field bg-gray-50" %>
<p class="help-text">The prefix to use for this provider's uploads.</p>
</div>
<% end %>

<!-- Regions -->
<div>
<%= form.label :region, class: "input-label" do %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/providers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
</div>

<div class="card-body">
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<div class="grid grid-cols-1 md:grid-cols-2 gap-8">

<div>
<label class="input-label">Provider Name</label>
Expand All @@ -97,7 +97,7 @@
</div>
</div>

<div>
<div class="col-span-full">
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before, an overly long file_name_prefix value would overflow its display label on large displays...

Image

The file_name_prefix value overflowing the display label on the previous grid layout

Now, this has been updated so the file_name_prefix display takes up the entire column...

Image

The file_name_prefix value spans its entire column on the new grid layout

<label class="input-label">File Name Prefix</label>
<div class="bg-gray-50 p-4 rounded-lg border border-gray-200">
<% if @provider.file_name_prefix.present? %>
Expand Down
24 changes: 24 additions & 0 deletions spec/views/providers/edit.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,28 @@
assert_select "input[type='submit'][value='Update Provider']"
end
end

context "when the provider has associated topics" do
before { create(:topic, provider: provider) }

it "tells the user that the File name prefix can't be changed" do
render

assert_select "form[action=?][method=?]", provider_path(provider), "post" do
assert_select "input[name=?][disabled]", "provider[file_name_prefix]"
end

assert_select "div#file-name-prefix-uneditable-notice"
end
end

context "when the provider that has no associated topics" do
it "has the File name prefix field" do
render

assert_select "form[action=?][method=?]", provider_path(provider), "post" do
assert_select "input[name=?]", "provider[file_name_prefix]"
end
end
end
end
1 change: 1 addition & 0 deletions spec/views/providers/new.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
assert_select "form[action=?][method=?]", providers_path, "post" do
assert_select "input[name=?]", "provider[name]"
assert_select "input[name=?]", "provider[provider_type]"
assert_select "input[name=?]", "provider[file_name_prefix]"
assert_select "input[type='submit'][value='Create Provider']"
end
end
Expand Down