Sha256: c5d269cd75583f54a059d1f57b062ebf4e5b719cb088e75f786cd05e3c2c831d

Contents?: true

Size: 1.95 KB

Versions: 6

Compression:

Stored size: 1.95 KB

Contents

<%= form_for @team, :html => { :class => "form-horizontal" } do |f| %>
  <fieldset>
    <div class="control-group">
      <%= f.label :name, :class => "control-label" %>
      <div class="controls">
        <%= f.text_field :name, :class => "text_field" %>
      </div>
    </div>

    <hr />

    <div class="control-group">
      <%= f.label :roles, "Teammates", :class => "control-label" %>
      <div class="controls changes-nested-editor">
        <%= f.nested_editor_for :roles do |f| -%>
          <%= f.select :user_id, [nil] + User.unretired.pluck("CONCAT(first_name, ' ', last_name)", :id) %>
          <% Houston.config.roles.each do |role| %>
            <% role_slug = role.downcase.gsub(" ", "_").pluralize %>
            <label style="display: inline-block">
              <input type="checkbox" name="team[roles_attributes][0][roles][]" value="<%= role %>" <%= "checked" if f.object.roles.member?(role) %> />
              <%= role %>
            </label>
          <% end %>
        <% end -%>
      </div>
    </div>

    <div class="form-actions">
      <%= f.submit nil, :class => "btn btn-primary" %>
      <%= link_to "Cancel", teams_path, :class => "btn" %>

      <% if @team.persisted? && can?(:destroy, @team) %>
        <button class="btn btn-delete btn-danger" id="delete_team_button">Delete</button>
      <% end %>
    </div>
  </fieldset>
<% end %>

<% content_for :javascripts do %>
<script type="text/javascript">
  $(function() {
    NestedEditorFor.init();

    $(document.body).on('nested-editor.reset', function(e) {
      $(e.target).find(':checkbox').prop('checked', false);
    });

    <% if @team.persisted? && can?(:destroy, @team) %>
    $('#delete_team_button').click(function(e) {
      e.preventDefault();
      $.destroy('<%= team_path(@team) %>')
        .success(function() { window.location = '/teams'; })
        .error(function(response) { Errors.fromResponse(response).renderToAlert(); });
    });
    <% end %>
  });
</script>
<% end %>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
houston-core-0.8.4 app/views/teams/_form.html.erb
houston-core-0.8.3 app/views/teams/_form.html.erb
houston-core-0.8.2 app/views/teams/_form.html.erb
houston-core-0.8.1 app/views/teams/_form.html.erb
houston-core-0.8.0 app/views/teams/_form.html.erb
houston-core-0.8.0.pre2 app/views/teams/_form.html.erb