= render "header", division: @division

%h2 Related Policies

= render "current_policies_list", division: @division, display: @display

%h3 Make a new connection

- if user_signed_in?
  = simple_form_for @policy_division, url: create_policy_division_path(division_params(@division)), html: {class: 'form-inline policyvote'} do |f|
    %legend.small
      %p Connect this division with relevant policies.
      %p Please read policy definitions and the division’s description before altering list.
    - if @policy_division.errors.any?
      .alert.alert-danger= @policy_division.errors.full_messages.to_sentence
    %fieldset
      %label People who are for
      - # TODO: Don't display policies already selected
      = f.collection_select :policy_id, Policy.all, "id", "name", {prompt: "Select related policy"}, size: 1, class: "selectpicker", data: {width: "auto"}
      would have
      %label voted
      = vote_select(f, nil, prompt: "Select vote")
    = f.submit 'Connect policy', class: 'btn btn-primary'
- else
  %p
    = link_to "Login", new_user_session_path, title: "Login to edit policies"
    to edit policy connections.

= render "header", division: @division

%h2 Related Policies

= render "current_policies_list", division: @division, display: @display

%h3 Make a new connection

- if user_signed_in?
  = simple_form_for @policy_division, url: create_policy_division_path(division_params(@division)), html: {class: 'form-inline policyvote'} do |f|
    %legend.small
      %p Connect this division with relevant policies.
      %p Please read policy definitions and the division’s description before altering list.
    - if @policy_division.errors.any?
      .alert.alert-danger= @policy_division.errors.full_messages.to_sentence
    %fieldset
      %label People who are for
      - # TODO: Don't display policies already selected
      = f.collection_select :policy_id, Policy.all.order(:name), "id", "name", {prompt: "Select related policy"}, size: 1, class: "selectpicker", data: {width: "auto"}
      would have
      %label voted
      = vote_select(f, nil, prompt: "Select vote")
    = f.submit 'Connect policy', class: 'btn btn-primary'
- else
  %p
    = link_to "Login", new_user_session_path, title: "Login to edit policies"
    to edit policy connections.

Sort policies by name in select
Sort policies by name in select
