gitlab-org--gitlab-foss/app/views/shared/snippets/_form.html.haml

42 lines
1.7 KiB
Text
Raw Normal View History

- content_for :page_specific_javascripts do
= page_specific_javascript_tag('lib/ace.js')
= page_specific_javascript_bundle_tag('snippet')
2013-03-23 15:13:51 -04:00
.snippet-form-holder
2017-05-03 11:26:49 -04:00
= form_for @snippet, url: url, html: { class: "form-horizontal snippet-form js-requires-input js-quick-submit common-note-form" } do |f|
= form_errors(@snippet)
2013-03-23 15:13:51 -04:00
.form-group
= f.label :title, class: 'control-label'
.col-sm-10
= f.text_field :title, class: 'form-control', required: true, autofocus: true
2017-05-03 11:26:49 -04:00
= render 'shared/form_elements/description', model: @snippet, project: @project, form: f
= 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
2017-02-05 17:28:48 -05:00
.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
2013-03-23 15:13:51 -04:00
%pre#editor= @snippet.content
= f.hidden_field :content, class: 'snippet-file-content'
2017-05-03 11:26:49 -04:00
- if params[:files]
- params[:files].each_with_index do |file, index|
= hidden_field_tag "files[]", file, id: "files_#{index}"
2013-03-23 15:13:51 -04:00
.form-actions
2013-08-12 05:08:52 -04:00
- if @snippet.new_record?
= f.submit 'Create snippet', class: "btn-create btn"
- else
= f.submit 'Save changes', class: "btn-save btn"
2013-03-23 15:13:51 -04:00
2015-05-14 20:15:06 -04:00
- if @snippet.project_id
= link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel"
- else
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"