2021-03-24 19:35:49 -04:00
<div class="row justify-content-center">
<div class="col-12 col-md-10 col-xl-8">
<h2>
2022-08-14 10:43:16 -04:00
<i class="bi bi-box-arrow-in-left me-1"></i> Import Shifts
2021-03-24 19:35:49 -04:00
</h2>
<p class="lead">If you have an iCal/ics formatted calendar hosted elsewhere, provide its URL here to import its events.</p>
<div class="row justify-content-center">
<div class="col-12 col-sm-11 col-md-10 col-lg-9 col-xxl-8">
2021-03-25 15:28:39 -04:00
<%= form_for :ics_import, "#", [phx_change: "validate", phx_submit: "save"], fn iimf -> %>
2021-03-24 19:35:49 -04:00
2021-03-25 15:28:39 -04:00
<% show_url_error = @url_validated && !@url_valid || false %>
<% valid_class = @url_validated && "is-valid" || "" %>
<%= label iimf, :ics_url, "iCal/ics URL", class: "form-label" %>
<div class="inner-addon left-addon mb-3">
2022-08-14 10:43:16 -04:00
<i class="bi bi-link icon is-left text-muted fs-5"></i>
2021-03-25 15:28:39 -04:00
<%= url_input iimf, :ics_url,
class: show_url_error && "form-control is-invalid" || "form-control #{valid_class}",
phx_debounce: 500,
aria_describedby: "ics-import-url-error"
%>
<%= if show_url_error do %>
<div class="invalid-feedback d-block" id="ics-import-url-error">
Must be a valid URL
2021-03-24 19:35:49 -04:00
</div>
2021-03-25 15:28:39 -04:00
<% end %>
</div>
<%= label iimf, :time_zone, class: "form-label" %>
<div class="inner-addon left-addon mb-3">
2022-08-14 10:43:16 -04:00
<i class="bi bi-map icon is-left text-muted fs-5"></i>
2021-03-25 15:28:39 -04:00
<%= text_input iimf, :time_zone,
2021-03-26 19:13:57 -04:00
value: Shift73k.app_time_zone(),
2021-03-25 15:28:39 -04:00
class: @tz_valid && "form-control" || "form-control is-invalid",
phx_debounce: 250,
aria_describedby: "ics-import-tz-error",
list: "tz_list"
%>
<datalist id="tz_list">
<%= for tz_name <- Tzdata.zone_list() do %>
2022-08-14 10:43:16 -04:00
<option value={tz_name}></option>
2021-03-25 15:28:39 -04:00
<% end %>
</datalist>
<div class="valid-feedback d-block text-primary">Type to search & select from list of known <%= link "IANA tz database", to: "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones", target: "_blank" %> time zones</div>
<%= if !@tz_valid do %>
<div class="invalid-feedback d-block" id="ics-import-tz-error">
Invalid time zone
</div>
<% end %>
</div>
2021-03-24 19:35:49 -04:00
<div class="row">
<div class="col mb-3 text-end">
2021-03-25 15:28:39 -04:00
<%= submit "Submit", class: "btn btn-primary", disabled: !@tz_valid || !@url_valid %>
2021-03-24 19:35:49 -04:00
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>