internetee/registry

View on GitHub
app/views/admin/api_users/_form.html.erb

Summary

Maintainability
Test Coverage
<%= form_for([:admin, @api_user.registrar, @api_user], html: { class: 'form-horizontal', autocomplete: 'off' }) do |f| %>
    <%= render 'form_errors', target: @api_user %>

    <div class="row">
        <div class="col-md-8">
            <div class="form-group">
                <div class="col-md-4 control-label">
                    <%= f.label :username, nil, class: 'required' %>
                </div>
                <div class="col-md-7">
                    <%= f.text_field :username, required: true, autofocus: true, class: 'form-control' %>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-4 control-label">
                    <%= f.label :plain_text_password, nil, class: 'required' %>
                </div>
                <div class="col-md-7">
                    <%= f.text_field :plain_text_password, required: true, class: 'form-control' %>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-4 control-label">
                    <%= f.label :identity_code %>
                </div>
                <div class="col-md-7">
                    <%= f.text_field(:identity_code, class: 'form-control') %>
                </div>
            </div>

            <div class="form-group">
                <div class="col-md-4 control-label">
                    <%= f.label :roles, nil, for: nil, class: 'required' %>
                </div>

                <div class="col-md-7">
                    <%= select_tag 'api_user[roles][]', options_for_select(ApiUser::ROLES.map { |x| [x, x] }, @api_user.roles.try(:first)), class: 'form-control selectize' %>
                    <div class="checkbox">
                        <label for="api_user_active">
                            <%= f.check_box(:active) %>
                            <%= ApiUser.human_attribute_name :active %>
                        </label>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <hr>

    <div class="row">
        <div class="col-md-8 text-right">
            <%= button_tag t(".#{f.object.new_record? ? 'create' : 'update'}_btn"), class: 'btn btn-success' %>
        </div>
    </div>
<% end %>