21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-05-05 02:05:09 +02:00
chexpire/app/views/checks/_form.html.erb
Colin Darie 3cbf0e2656
Enforce input of type date, enhancing UX for browser compatible.
Note: the submitted date format is iso8601 YYYY-MM-DD (as we expect), 
even if the displayed date by the browser depends of the user's browser 
locale. Theses browsers then safely ignore input placeholder.

This is why we can't display the expected date format elsewhere in the 
interface: these users will see another format as the one we expect, and 
we don't want to mislead them.
The date format is only displayed as a placeholder, for browser 
non-compatible with input of type date.
2018-08-29 18:14:16 +02:00

55 lines
1.9 KiB
Plaintext

<% # Copyright (C) 2018 Colin Darie <colin@darie.eu>, 2018 Evolix <info@evolix.fr> %>
<% # License: GNU AGPL-3+ (see full text in LICENSE file) %>
<%= simple_form_for(check) do |f| %>
<%= f.input :domain,
autofocus: true,
input_html: { autocapitalize: :none, autocorrect: :off, data: { kind: check.kind } },
label: t(".#{check.kind || "generic" }.domain"),
hint: t(".#{check.kind || "generic" }.unsupported"),
hint_html: {
id: "check_domain_unsupported_container",
class: "#{check.supported? && 'd-none'}",
}
%>
<% if check.new_record? %>
<%= f.input :kind, as: check.kind.present? ? :hidden : :radio_buttons, collection: Check.kinds.keys %>
<% end %>
<div id="check_domain_expires_at_container" class="<%= check.supported? ? "d-none" : "d-block" %>">
<%= f.input :domain_expires_at,
required: true,
input_html: {
type: :date,
value: check.domain_expires_at&.to_date,
min: Date.yesterday,
max: 10.years.from_now.end_of_year.to_date
},
as: :string,
placeholder: t(".domain_expires_at_placeholder")
%>
</div>
<%= f.input :comment %>
<%= f.input :vendor %>
<% if check.persisted? %>
<%= f.input :active %>
<% end %>
<h2 class="mt-5"><%= t(".notifications") %></h2>
<p class="alert alert-light"><%= t(".notifications_hint") %></p>
<%- check.notifications.each_with_index do |notification, index| %>
<div data-notification-id="<%= notification.id %>">
<%= f.fields_for :notifications, notification do |nf| %>
<%= render "notifications/nested_form_headers", f: nf if index.zero? %>
<%= render "notifications/nested_form", f: nf, check: check %>
<% end %>
</div>
<% end %>
<%= f.button :submit, class: "btn-primary mt-5" %>
<% end %>