gitlabhq/app/views/snippets/_form.html.haml

42 lines
1.5 KiB
Text
Raw Normal View History

2012-11-21 05:14:05 +01:00
%h3.page_title
= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
%hr
2012-12-12 18:42:08 +01:00
.snippet-form-holder
= form_for [@project, @snippet] do |f|
-if @snippet.errors.any?
2013-01-30 15:53:18 +01:00
.alert.alert-error
2012-12-12 18:42:08 +01:00
%ul
- @snippet.errors.full_messages.each do |msg|
%li= msg
2012-12-12 18:42:08 +01:00
.clearfix
= f.label :title
.input= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true
.clearfix
= f.label "Lifetime"
.input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
.clearfix
.file-editor
= f.label :file_name, "File"
.input
.file_holder.snippet
.file_title
= f.text_field :file_name, placeholder: "example.rb", class: 'snippet-file-name', required: true
.file_content.code
%pre#editor= @snippet.content
= f.hidden_field :content, class: 'snippet-file-content'
.form-actions
2013-01-29 21:18:19 +01:00
= f.submit 'Save', class: "btn-save btn"
2012-12-12 18:42:08 +01:00
= link_to "Cancel", project_snippets_path(@project), class: " btn"
- unless @snippet.new_record?
2013-01-30 15:40:43 +01:00
.pull-right= link_to 'Destroy', [@project, @snippet], confirm: 'Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}"
2012-12-12 18:42:08 +01:00
:javascript
var editor = ace.edit("editor");
$(".snippet-form-holder form").submit(function(){
$(".snippet-file-content").val(editor.getValue());
});
2011-12-15 07:12:24 +01:00