BigW Consortium Gitlab

_form.html.haml 1.74 KB
Newer Older
1 2
- content_for :page_specific_javascripts do
  = page_specific_javascript_tag('lib/ace.js')
3
  = page_specific_javascript_bundle_tag('snippet')
4

5
.snippet-form-holder
6
  = form_for @snippet, url: url, html: { class: "form-horizontal snippet-form js-requires-input js-quick-submit common-note-form" } do |f|
7
    = form_errors(@snippet)
8

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

14 15
    = render 'shared/form_elements/description', model: @snippet, project: @project, form: f

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

18 19
    .file-editor
      .form-group
20
        = f.label :file_name, "File", class: 'control-label'
21
        .col-sm-10
22
          .file-holder.snippet
23
            .js-file-title.file-title
24
              = 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'
25
            .file-content.code
26 27
              %pre#editor= @snippet.content
              = f.hidden_field :content, class: 'snippet-file-content'
28 29 30
    - if params[:files]
      - params[:files].each_with_index do |file, index|
        = hidden_field_tag "files[]", file, id: "files_#{index}"
31 32

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

38
      - if @snippet.project_id
39
        = link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel"
40 41
      - else
        = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"