Skip to content

Commit

Permalink
fix: modify forms (follow up)
Browse files Browse the repository at this point in the history
  • Loading branch information
puglet5 committed Nov 10, 2023
1 parent a19f7ae commit 9b8c8a5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/views/samples/_spectrum_panel.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@
<path d="M8 4h-3v16h3"></path>
<path d="M16 4h3v16h-3"></path>
</svg>
<div class="flex space-x-1 text-gray-700">
<span class="my-auto">
<%= ApplicationHelper.humanize_range spectrum.range %>
<div class="flex text-gray-700">
<span class="my-auto mr-2 text-sm font-medium text-gray-500">
<%= ApplicationHelper.humanize_category spectrum.category %>
</span>
<div class="my-auto">
<div class="my-auto mr-2 text-sm text-gray-500">
&middot;
</div>
<span class="my-auto">
<%= ApplicationHelper.humanize_category spectrum.category %>
<span class="my-auto mr-2 text-xs font-medium text-gray-500">
<%= ApplicationHelper.humanize_file_format spectrum.format %>
</span>
<div class="my-auto">
<div class="my-auto mr-2 text-sm text-gray-500">
&middot;
</div>
<span class="my-auto">
<%= ApplicationHelper.humanize_file_format spectrum.format %>
<span class="my-auto mr-2 text-xs font-medium text-gray-500">
id: <%= spectrum.id %>
</span>
</div>
</div>
Expand Down
13 changes: 13 additions & 0 deletions app/views/samples/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,19 @@
<%= spectrum.file.filename.to_s.truncate(20) %>
</span>
</div>
<% if spectrum.is_reference? %>
<div class="my-auto">
<%= render TooltipComponent.new(tooltip: "Reference", user: current_user) do %>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-box w-4 h-4" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 3l8 4.5l0 9l-8 4.5l-8 -4.5l0 -9l8 -4.5"></path>
<path d="M12 12l8 -4.5"></path>
<path d="M12 12l0 9"></path>
<path d="M12 12l-8 -4.5"></path>
</svg>
<% end %>
</div>
<% end %>
</div>
<% end %>
</li>
Expand Down
10 changes: 10 additions & 0 deletions app/views/spectra/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<%= f.input :category, default: @spectrum.category, collection: SpectraHelper::HUMANIZED_CATEGORIES_COLLECTION, input_html: { class: "w-full p-4 pr-6 text-sm border-gray-300 rounded-md shadow-sm focus:ring-1 focus:ring-primary-500 focus:border-primary-600 peer" }, hint: false, label: false %>
</div>

<div>
<%= render Forms::LabelComponent.new(optional: true).with_content("Sample thickness (mm)") %>
<%= f.input :sample_thickness, as: :float, input_html: { class: "w-full p-4 pr-6 text-sm border-gray-300 rounded-md shadow-sm focus:ring-1 focus:ring-primary-500 focus:border-primary-600", min: 0, step: 0.1 }, error_html: { data: { controller: 'flash', 'flash-target': 'flash' } }, placeholder: "3.61", required: false, disabled: false, readonly: false, hint: false, label: false, error: false %>
</div>

<div class="flex my-auto space-x-2">
<%= f.input :is_reference, default: false, input_html: { class: "w-4 h-4 text-primary-600 bg-gray-100 border-gray-300 rounded focus:ring-primary-500" } %>
<%= render Forms::LabelComponent.new(optional: true, cls: "!mb-0").with_content("Reference spectrum") %>
</div>

<div class="col-span-2 mb-4">
<%= render Forms::LabelComponent.new().with_content("Description") %>
<%= render Forms::TextInputComponent.new(form: f, as: :rich_text_area, field: :description, required: false, placeholder: "General description") %>
Expand Down
10 changes: 10 additions & 0 deletions app/views/spectra/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@
<%= f.input :category, default: @spectrum.category, collection: SpectraHelper::HUMANIZED_CATEGORIES_COLLECTION, input_html: { class: "w-full p-4 pr-6 text-sm border-gray-300 rounded-md shadow-sm focus:ring-1 focus:ring-primary-500 focus:border-primary-600 peer" }, hint: false, label: false %>
</div>

<div>
<%= render Forms::LabelComponent.new(optional: true).with_content("Sample thickness (mm)") %>
<%= f.input :sample_thickness, as: :float, input_html: { class: "w-full p-4 pr-6 text-sm border-gray-300 rounded-md shadow-sm focus:ring-1 focus:ring-primary-500 focus:border-primary-600", min: 0.1, step: 0.1 }, error_html: { data: { controller: 'flash', 'flash-target': 'flash' } }, placeholder: "3.61", required: false, disabled: false, readonly: false, hint: false, label: false, error: false %>
</div>

<div class="flex my-auto space-x-2">
<%= f.input :is_reference, default: false, input_html: { class: "w-4 h-4 text-primary-600 bg-gray-100 border-gray-300 rounded focus:ring-primary-500" } %>
<%= render Forms::LabelComponent.new(optional: true, cls: "!mb-0").with_content("Reference spectrum") %>
</div>

<div class="col-span-2 mb-4">
<%= render Forms::LabelComponent.new().with_content("Description") %>
<%= render Forms::TextInputComponent.new(form: f, as: :rich_text_area, field: :description, required: false, placeholder: "General description") %>
Expand Down

0 comments on commit 9b8c8a5

Please sign in to comment.