46 lines
1.6 KiB
Text
46 lines
1.6 KiB
Text
%h3.page-title
|
|
= @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
|
|
%hr
|
|
.snippet-form-holder
|
|
= form_for @snippet, as: :personal_snippet, url: url do |f|
|
|
-if @snippet.errors.any?
|
|
.alert.alert-error
|
|
%ul
|
|
- @snippet.errors.full_messages.each do |msg|
|
|
%li= msg
|
|
|
|
.control-group
|
|
= f.label :title
|
|
.controls= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true
|
|
.control-group
|
|
= f.label "Private?"
|
|
.controls
|
|
= f.check_box :private, {class: ''}
|
|
.control-group
|
|
.file-editor
|
|
= f.label :file_name, "File"
|
|
.controls
|
|
.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
|
|
- if @snippet.new_record?
|
|
= f.submit 'Create snippet', class: "btn-create btn"
|
|
- else
|
|
= f.submit 'Save', class: "btn-save btn"
|
|
|
|
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
|
|
- unless @snippet.new_record?
|
|
.pull-right= link_to 'Destroy', snippet_path(@snippet), confirm: 'Removed snippet cannot be restored! Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}"
|
|
|
|
|
|
:javascript
|
|
var editor = ace.edit("editor");
|
|
$(".snippet-form-holder form").submit(function(){
|
|
$(".snippet-file-content").val(editor.getValue());
|
|
});
|
|
|