Sha256: 2df77b9c64aa71be830505bd8f6bb32322120c9c0ab81b981fbeb2ae227445f8

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

<%#
The following params are the variables that can be used in this partial.

@param form [Wallaby::FormBuilder] custom form object that adds a few helper methods and delegate missing methods to the view
@param object [Wallaby::ResourceDecorator] decorator instance which wraps the resource (e.g. ActiveRecord) instance
@param field_name [String] name of the field
@param value [Object] value of the field
@param metadata [Hash] metadata of the field
%>
<% picker_id = SecureRandom.uuid %>
<div class="form-group <%= form.error_class field_name %>">
  <%= form.label field_name, metadata[:label] %>
  <div class="row">
    <div class="col-6 col-sm-4">
      <div id="<%= picker_id %>" class="input-group date" data-init="timepicker" data-target-input="nearest">
        <%= form.text_field field_name, class: 'form-control datetimepicker-input', 'data-target': "##{picker_id}" %>
        <span class="input-group-append" data-target="#<%= picker_id %>" data-toggle="datetimepicker"><span class="input-group-text"><%= fa_icon 'clock' %></span></span>
      </div>
    </div>
  </div>
  <%= form.error_messages field_name %>
  <%= hint_of metadata %>
</div>

<% unless @timepicker_init %>
  <% @timepicker_init = true %>
  <% content_for :custom_javascript do %>
    <% javascript_tag do %>
      documentReady('.time', function () {
        $('[data-init="timepicker"]').each(function() {
          var $input = $('input', this),
            val = ($input.attr('value') || '').split(' ').slice(0,2).join(' ');
          $input.val(moment(val).format('HH:mm'));
          $(this).datetimepicker({
            format: 'HH:mm'
          });
        })
      })
    <% end %>
  <% end %>
<% end %>

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wallaby-8.0.0 app/views/wallaby/resources/form/_time.html.erb
wallaby-7.0.0 app/views/wallaby/resources/form/_time.html.erb
wallaby-7.0.0.beta2 app/views/wallaby/resources/form/_time.html.erb
wallaby-7.0.0.beta1 app/views/wallaby/resources/form/_time.html.erb