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
|
|
|
|
2014-10-08 13:44:25 +00:00
|
|
|
= render "shared/snippets/visibility_level", f: f, visibility_level: gitlab_config.default_projects_features.visibility_level, can_change_visibility_level: true
|
|
|
|
|
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)
|
2015-01-24 18:02:58 +00:00
|
|
|
= link_to "Cancel", namespace_project_snippets_path(@project.namespace, @project), class: "btn btn-cancel"
|
2014-06-14 09:36:46 +00:00
|
|
|
- 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());
|
|
|
|
});
|