2013-03-23 19:13:51 +00:00
|
|
|
.snippet-form-holder
|
2014-06-14 09:36:46 +00:00
|
|
|
= form_for @snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
|
|
|
|
- if @snippet.errors.any?
|
2013-12-31 14:34:14 +00:00
|
|
|
.alert.alert-danger
|
2013-03-23 19:13:51 +00:00
|
|
|
%ul
|
|
|
|
- @snippet.errors.full_messages.each do |msg|
|
|
|
|
%li= msg
|
|
|
|
|
2013-12-30 23:27:02 +00:00
|
|
|
.form-group
|
2014-01-11 17:15:47 +00:00
|
|
|
= f.label :title, class: 'control-label'
|
2014-01-01 20:11:18 +00:00
|
|
|
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
|
2014-06-14 09:36:46 +00:00
|
|
|
|
|
|
|
- unless @snippet.respond_to?(:project)
|
|
|
|
.form-group
|
|
|
|
= f.label "Access", class: 'control-label'
|
|
|
|
.col-sm-10
|
|
|
|
= f.label :private_true, class: 'radio-label' do
|
|
|
|
= f.radio_button :private, true
|
|
|
|
%span
|
|
|
|
%strong Private
|
|
|
|
(only you can see this snippet)
|
|
|
|
%br
|
|
|
|
= f.label :private_false, class: 'radio-label' do
|
|
|
|
= f.radio_button :private, false
|
|
|
|
%span
|
|
|
|
%strong Public
|
|
|
|
(GitLab users can see this snippet)
|
|
|
|
|
2013-12-30 23:27:02 +00:00
|
|
|
.form-group
|
2013-03-23 19:13:51 +00:00
|
|
|
.file-editor
|
2014-01-11 17:15:47 +00:00
|
|
|
= f.label :file_name, "File", class: 'control-label'
|
2013-12-30 23:27:02 +00:00
|
|
|
.col-sm-10
|
2013-07-13 06:52:47 +00:00
|
|
|
.file-holder.snippet
|
|
|
|
.file-title
|
2014-01-12 16:32:46 +00:00
|
|
|
= f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true
|
2013-07-13 06:52:47 +00:00
|
|
|
.file-content.code
|
2013-03-23 19:13:51 +00:00
|
|
|
%pre#editor= @snippet.content
|
|
|
|
= f.hidden_field :content, class: 'snippet-file-content'
|
|
|
|
|
|
|
|
.form-actions
|
2013-08-12 09:08:52 +00:00
|
|
|
- if @snippet.new_record?
|
|
|
|
= f.submit 'Create snippet', class: "btn-create btn"
|
|
|
|
- else
|
|
|
|
= f.submit 'Save', class: "btn-save btn"
|
2013-03-23 19:13:51 +00:00
|
|
|
|
2014-06-14 09:36:46 +00:00
|
|
|
- if @snippet.respond_to?(:project)
|
|
|
|
= link_to "Cancel", project_snippets_path(@project), class: "btn btn-cancel"
|
|
|
|
- else
|
|
|
|
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
|
2013-03-23 19:13:51 +00:00
|
|
|
|
|
|
|
:javascript
|
|
|
|
var editor = ace.edit("editor");
|
|
|
|
$(".snippet-form-holder form").submit(function(){
|
|
|
|
$(".snippet-file-content").val(editor.getValue());
|
|
|
|
});
|