summaryrefslogtreecommitdiff
path: root/app/views/shared/snippets/_form.html.haml
blob: e7f7db732237da83b736ecddd5f6a53ecadfd30b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
- content_for :page_specific_javascripts do
  = page_specific_javascript_tag('lib/ace.js')
  = page_specific_javascript_bundle_tag('snippet')

.snippet-form-holder
  = form_for @snippet, url: url, html: { class: "form-horizontal snippet-form js-requires-input" } do |f|
    = form_errors(@snippet)

    .form-group
      = f.label :title, class: 'control-label'
      .col-sm-10
        = f.text_field :title, class: 'form-control', required: true, autofocus: true

    = render 'shared/visibility_level', f: f, visibility_level: @snippet.visibility_level, can_change_visibility_level: true, form_model: @snippet

    .file-editor
      .form-group
        = f.label :file_name, "File", class: 'control-label'
        .col-sm-10
          .file-holder.snippet
            .js-file-title.file-title
              = f.text_field :file_name, placeholder: "Optionally name this file to add code highlighting, e.g. example.rb for Ruby.", class: 'form-control snippet-file-name'
            .file-content.code
              %pre#editor= @snippet.content
              = f.hidden_field :content, class: 'snippet-file-content'

    .form-actions
      - if @snippet.new_record?
        = f.submit 'Create snippet', class: "btn-create btn"
      - else
        = f.submit 'Save changes', class: "btn-save btn"

      - if @snippet.project_id
        = link_to "Cancel", namespace_project_snippets_path(@project.namespace, @project), class: "btn btn-cancel"
      - else
        = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"