_form.html.haml 3.08 KB
%h3.page-title
  = @service.title

%p #{@service.description} template

= form_for :service, url: admin_application_settings_service_path, method: :put, html: { class: 'form-horizontal fieldset-form' } do |f|
  - if @service.errors.any?
    #error_explanation
      .alert.alert-danger
        - @service.errors.full_messages.each do |msg|
          %p= msg
  - if @service.help.present?
    .alert.alert-info
      = preserve do
        = markdown @service.help

  - if @service.supported_events.length > 1
    .form-group
      = f.label :url, "Trigger", class: 'control-label'
      .col-sm-10
        - if @service.supported_events.include?("push")
          %div
            = f.check_box :push_events, class: 'pull-left'
            .prepend-left-20
              = f.label :push_events, class: 'list-label' do
                %strong Push events
              %p.light
                This url will be triggered by a push to the repository
        - if @service.supported_events.include?("tag_push")
          %div
            = f.check_box :tag_push_events, class: 'pull-left'
            .prepend-left-20
              = f.label :tag_push_events, class: 'list-label' do
                %strong Tag push events
              %p.light
                This url will be triggered when a new tag is pushed to the repository
        - if @service.supported_events.include?("issue")
          %div
            = f.check_box :issues_events, class: 'pull-left'
            .prepend-left-20
              = f.label :issues_events, class: 'list-label' do
                %strong Issues events
              %p.light
                This url will be triggered when an issue is created
        - if @service.supported_events.include?("merge_request")
          %div
            = f.check_box :merge_requests_events, class: 'pull-left'
            .prepend-left-20
              = f.label :merge_requests_events, class: 'list-label' do
                %strong Merge Request events
              %p.light
                This url will be triggered when a merge request is created

  - @service.fields.each do |field|
    - name = field[:name]
    - title = field[:title] || name.humanize
    - value = @service.send(name) unless field[:type] == 'password'
    - type = field[:type]
    - placeholder = field[:placeholder]
    - choices = field[:choices]
    - default_choice = field[:default_choice]
    - help = field[:help]

    .form-group
      = f.label name, title, class: "control-label"
      .col-sm-10
        - if type == 'text'
          = f.text_field name, class: "form-control", placeholder: placeholder
        - elsif type == 'textarea'
          = f.text_area name, rows: 5, class: "form-control", placeholder: placeholder
        - elsif type == 'checkbox'
          = f.check_box name
        - elsif type == 'select'
          = f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" }
        - elsif type == 'password'
          = f.password_field name, class: 'form-control'
        - if help
          %span.help-block= help

  .form-actions
    = f.submit 'Save', class: 'btn btn-save'