- @pagetitle = 'Add Repository'
- @metarobots = 'noindex'
- project_bread_crumb @pagetitle
= render partial: '/webui/project/tabs'
%h2
  Add Repositories to #{@project}
- @distributions.each do |vendor, list|
  %h3
    = sprite_tag("distributions-#{vendor.downcase}")
    = vendor
    distributions
  %p
    - list.each do |distribution|
      - selected = @project.has_distribution(distribution['project'], distribution['repository'])
      %span.nowrap
        = check_box_tag 'distributions[]', distribution['reponame'], selected, id: 'repo_' + replace_jquery_meta_characters(distribution['reponame']), class: 'repocheckbox'
        %label{ for: 'repo_' + replace_jquery_meta_characters(distribution['reponame']) }= distribution['name']
  - list.each do |distribution|
    = form_tag({ action: :create, project: @project }, remote: true, class: 'hidden', id: 'repo_' + replace_jquery_meta_characters(distribution['reponame']) + '_create') do
      = hidden_field_tag 'repository', distribution['reponame']
      = hidden_field_tag 'target_project', distribution['project']
      = hidden_field_tag 'target_repo', distribution['repository']
      - distribution['architectures'].each do |arch|
        = hidden_field_tag 'architectures[]', arch
    = form_tag({ action: :destroy }, remote: true, class: 'hidden', id: 'repo_' + replace_jquery_meta_characters(distribution['reponame']) + '_destroy') do
      = hidden_field_tag 'project', @project.name
      = hidden_field_tag 'target', distribution['reponame']
%h3
  = image_tag('distributions/kiwi.png', width: 40)
  Kiwi image builds
%p
  %span.nowrap
    - selected = @project.repositories.where(name: 'images').count > 0
    = check_box_tag 'images', 'true', selected, id: 'repo_images', class: 'repocheckbox'
    %label{ for: "repo_images" }
      KIWI image build
      %i (to be used for appliance and product builds with kiwi)
    = form_tag({ action: :create_image_repository, project: @project }, remote: true, class: 'hidden', id: 'repo_images_create')
    = form_tag({ action: :destroy }, remote: true, class: 'hidden', id: 'repo_images_destroy') do
      = hidden_field_tag 'project', @project.name
      = hidden_field_tag 'target', 'images'
%p
  %span.nowrap
    = link_to 'Expert mode', { action: :new, project: @project }, { style: 'padding-left: 4px' }
= content_for :ready_function do
  :plain
    $('.repocheckbox').click(function() {
      id = $(this).attr('id')
      if($(this).is(':checked')){
        $form = $('#' + id + '_create');
      } else {
        $form = $('#' + id + '_destroy');
      }
      $form.submit();
    });
