2016-06-24 14:26:11 -04:00
- content_for :page_specific_javascripts do
= page_specific_javascript_tag('lib/ace.js')
2013-03-23 15:13:51 -04:00
.snippet-form-holder
2018-07-06 14:49:33 -04:00
= form_for @snippet, url: url,
2020-03-26 08:07:48 -04:00
html: { class: "snippet-form js-requires-input js-quick-submit common-note-form" },
data: { "snippet-type": @snippet.project_id ? 'project' : 'personal'} do |f|
2016-04-04 21:25:38 -04:00
= form_errors(@snippet)
2013-03-23 15:13:51 -04:00
2020-02-13 10:08:52 -05:00
.form-group
= f.label :title, class: 'label-bold'
= f.text_field :title, class: 'form-control qa-snippet-title', required: true, autofocus: true
.form-group.js-description-input
- description_placeholder = s_('Snippets|Optionally add a description about what your snippet does or how to use it...')
- is_expanded = @snippet.description && !@snippet.description.empty?
= f.label :description, s_("Snippets|Description (optional)"), class: 'label-bold'
.js-collapsible-input
.js-collapsed{ class: ('d-none' if is_expanded) }
2020-02-18 04:09:24 -05:00
= text_field_tag nil, nil, class: 'form-control', placeholder: description_placeholder, data: { qa_selector: 'description_placeholder' }
2020-02-13 10:08:52 -05:00
.js-expanded{ class: ('d-none' if !is_expanded) }
= render layout: 'projects/md_preview', locals: { url: preview_markdown_path(@project), referenced_users: true } do
2020-02-18 04:09:24 -05:00
= render 'projects/zen', f: f, attr: :description, classes: 'note-textarea', placeholder: description_placeholder, qa_selector: 'description_field'
2020-02-13 10:08:52 -05:00
= render 'shared/notes/hints'
.form-group.file-editor
= f.label :file_name, s_('Snippets|File')
.file-holder.snippet
.js-file-title.file-title-flex-parent
2020-03-05 13:08:19 -05:00
= f.text_field :file_name, placeholder: s_("Snippets|Give your file a name to add code highlighting, e.g. example.rb for Ruby"), class: 'form-control js-snippet-file-name qa-snippet-file-name'
2020-02-13 10:08:52 -05:00
.file-content.code
2020-02-28 10:09:13 -05:00
%pre#editor{ data: { 'editor-loading': true } }= @snippet.content
2020-02-13 10:08:52 -05:00
= f.hidden_field :content, class: 'snippet-file-content'
.form-group
.font-weight-bold
= _('Visibility level')
= link_to icon('question-circle'), help_page_path("public_access/public_access"), target: '_blank'
= render 'shared/visibility_level', f: f, visibility_level: @snippet.visibility_level, can_change_visibility_level: true, form_model: @snippet, with_label: false
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?
2019-02-19 15:23:34 -05:00
= f.submit 'Create snippet', class: "btn-success btn qa-create-snippet-button"
2013-08-12 05:08:52 -04:00
- else
2018-09-18 05:58:22 -04:00
= f.submit 'Save changes', class: "btn-success btn"
2013-03-23 15:13:51 -04:00
2015-05-14 20:15:06 -04:00
- if @snippet.project_id
2017-06-29 13:06:35 -04:00
= link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel"
2014-06-14 05:36:46 -04:00
- else
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"