= form_for [:admin, @admin_project] do |f|
  -if @admin_project.errors.any?
    .alert-message.block-message.error
      %ul
        - @admin_project.errors.full_messages.each do |msg|
          %li= msg

  .clearfix
    = f.label :name
    .input= f.text_field :name
  .clearfix
    = f.label :path do 
      Path
    .input
      .input-prepend
        %span.add-on= "#{GIT_HOST["git_user"]}@#{GIT_HOST["host"]}:"
        = f.text_field :path, :placeholder => "example_project", :disabled => !@admin_project.new_record?
  .clearfix
    = f.label :code do 
      Code
    .input
      .input-prepend
        %span.add-on= web_app_url
        = f.text_field :code, :placeholder => "example"

  - unless @admin_project.new_record?
    .clearfix
      = f.label :owner_id
      .input= f.select :owner_id, User.all.map { |user| [user.name, user.id] }

    - if @admin_project.repo_exists?  
      .clearfix
        = f.label :default_branch, "Default Branch"
        .input= f.select(:default_branch, @admin_project.heads.map(&:name), {}, :style => "width:210px;")

    .well
      %h5 Features

      .clearfix
        = f.label :issues_enabled, "Issues"
        .input= f.check_box :issues_enabled

      .clearfix
        = f.label :merge_requests_enabled, "Merge Requests"
        .input= f.check_box :merge_requests_enabled

      .clearfix
        = f.label :wall_enabled, "Wall"
        .input= f.check_box :wall_enabled

  .clearfix
    = f.label :description
    .input= f.text_area :description, :class => "xxlarge"
  .clear
  %br
  .actions
    = f.submit 'Save', :class => "btn primary"
    = link_to 'Cancel', [:admin, @admin_project], :class => "btn"
    - unless @admin_project.new_record?
      = link_to 'Destroy', [:admin, @admin_project], :confirm => 'Are you sure?', :method => :delete, :class => "btn danger right"

:javascript
  $(function(){
    $('#project_owner_id').chosen();
    new Projects();
  })
