.nested-fields.kiwi_fields
  %div{ class: "kiwi_list_item #{'has-error' if f.object.errors.present?}"}
    %span
      = link_to f.object.name, '#', class: 'repository_edit kiwi_element_name'
    %span.kiwi_actions.hidden
      = link_to_remove_association(sprite_tag("req-decline", title: 'Delete Repository'), f)

  .dialog.darkgrey_box{ style: "width: 500px; left: 45%;", class: "#{'hidden' if f.object.source_path.present?} #{'new_element' if f.object.new_record?}" }
    .box.box-shadow
      %h2.box-header #{f.object.source_path.present? ? 'Edit' : 'Add'} repository

      .dialog-content
        .normal-mode
          %p
            = label_tag 'Project:'
            = text_field_tag 'target_project', f.object.project_for_type_obs,
              data: { ajaxurl: url_for(controller: '/webui/project', action: 'autocomplete_projects'), default: f.object.project_for_type_obs }
          %p
            = label_tag 'Repository:'
            %br/
            = select_tag "target_repo", options_for_select([f.object.repository_for_type_obs]), disabled: !f.object.obs_source_path?,
              data: { ajaxurl: url_for(controller: '/webui/project', action: :autocomplete_repositories), default: f.object.repository_for_type_obs }
            %span.ui-autocomplete-loading.hidden
              = image_tag('ajax-loader.gif')
          %p
            = label_tag 'Alias:'
            = text_field_tag 'alias_for_repo', f.object.alias, data: { default: f.object.alias }
        .expert-mode.hidden
          %p
            = f.hidden_field :order, data: { default: f.object.order }
            = f.label :repo_type, 'Type:'
            = f.select :repo_type, Kiwi::Repository::REPO_TYPES, {}, { data: {default: f.object.repo_type }}
            = f.label :priority, 'Priority:'
            = f.number_field :priority, maxlength: 4, style: "width: 50px", in: 0...99, data: { default: f.object.priority }
            = f.label :alias, 'Alias:'
            = f.text_field :alias,  style: "width: 170px", data: { default: f.object.alias }
          %p
            = f.label :source_path, 'Source:'
            = f.text_field :source_path, data: { default: f.object.source_path }
            %span.small-text
              Write a valid source path

          %p
            = f.label :username, 'User:'
            = f.text_field :username,  style: "width: 170px", data: { default: f.object.username }
            = f.label :password, 'Password:'
            = f.text_field :password,  style: "width: 170px", data: { default: f.object.password }

          %p
            = f.check_box :prefer_license, data: { default: f.object.prefer_license }
            = f.label :prefer_license
            = f.check_box :imageinclude, data: { default: f.object.imageinclude }
            = f.label :imageinclude, 'Image include'
            = f.check_box :replaceable, data: { default: f.object.replaceable }
            = f.label :replaceable

      %p#flash-messages
        %p.ui-state-error.ui-widget-shadow.hidden

      .dialog-buttons
        = link_to('Expert Mode', '#', title: 'Mode Toggle', class: 'kiwi-repository-mode-toggle')
        = link_to('Cancel', '#', title: 'Cancel', class: 'revert-dialog')
        = link_to('Continue', '#', title: 'Continue', class: 'close-dialog')
