debian-mirror-gitlab/app/views/shared/snippets/_form.html.haml

42 lines
1.6 KiB
Text
Raw Normal View History

2014-09-02 18:07:02 +05:30
.snippet-form-holder
= form_for @snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
- if @snippet.errors.any?
.alert.alert-danger
%ul
- @snippet.errors.full_messages.each do |msg|
%li= msg
.form-group
= f.label :title, class: 'control-label'
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
2015-09-11 14:41:01 +05:30
= render 'shared/visibility_level', f: f, visibility_level: visibility_level, can_change_visibility_level: true, form_model: @snippet
.file-editor
.form-group
2014-09-02 18:07:02 +05:30
= f.label :file_name, "File", class: 'control-label'
.col-sm-10
.file-holder.snippet
.file-title
2015-09-11 14:41:01 +05:30
= 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'
2014-09-02 18:07:02 +05:30
.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', class: "btn-save btn"
2015-09-11 14:41:01 +05:30
- if @snippet.project_id
2015-04-26 12:48:37 +05:30
= link_to "Cancel", namespace_project_snippets_path(@project.namespace, @project), class: "btn btn-cancel"
2014-09-02 18:07:02 +05:30
- else
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
:javascript
var editor = ace.edit("editor");
$(".snippet-form-holder form").submit(function(){
$(".snippet-file-content").val(editor.getValue());
});