2013-03-23 15:13:51 -04:00
|
|
|
.snippet-form-holder
|
2014-06-14 05:36:46 -04:00
|
|
|
= form_for @snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
|
|
|
|
- if @snippet.errors.any?
|
2013-12-31 09:34:14 -05:00
|
|
|
.alert.alert-danger
|
2013-03-23 15:13:51 -04:00
|
|
|
%ul
|
|
|
|
- @snippet.errors.full_messages.each do |msg|
|
|
|
|
%li= msg
|
|
|
|
|
2013-12-30 18:27:02 -05:00
|
|
|
.form-group
|
2014-01-11 12:15:47 -05:00
|
|
|
= f.label :title, class: 'control-label'
|
2014-01-01 15:11:18 -05:00
|
|
|
.col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
|
2014-06-14 05:36:46 -04:00
|
|
|
|
2014-10-08 09:44:25 -04: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 18:27:02 -05:00
|
|
|
.form-group
|
2013-03-23 15:13:51 -04:00
|
|
|
.file-editor
|
2014-01-11 12:15:47 -05:00
|
|
|
= f.label :file_name, "File", class: 'control-label'
|
2013-12-30 18:27:02 -05:00
|
|
|
.col-sm-10
|
2013-07-13 02:52:47 -04:00
|
|
|
.file-holder.snippet
|
|
|
|
.file-title
|
2014-01-12 11:32:46 -05:00
|
|
|
= f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true
|
2013-07-13 02:52:47 -04:00
|
|
|
.file-content.code
|
2013-03-23 15:13:51 -04:00
|
|
|
%pre#editor= @snippet.content
|
|
|
|
= f.hidden_field :content, class: 'snippet-file-content'
|
|
|
|
|
|
|
|
.form-actions
|
2013-08-12 05:08:52 -04:00
|
|
|
- if @snippet.new_record?
|
|
|
|
= f.submit 'Create snippet', class: "btn-create btn"
|
|
|
|
- else
|
|
|
|
= f.submit 'Save', class: "btn-save btn"
|
2013-03-23 15:13:51 -04:00
|
|
|
|
2014-06-14 05:36:46 -04:00
|
|
|
- if @snippet.respond_to?(:project)
|
2015-01-24 13:02:58 -05:00
|
|
|
= link_to "Cancel", namespace_project_snippets_path(@project.namespace, @project), class: "btn btn-cancel"
|
2014-06-14 05:36:46 -04:00
|
|
|
- else
|
|
|
|
= link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
|
2013-03-23 15:13:51 -04:00
|
|
|
|
|
|
|
:javascript
|
|
|
|
var editor = ace.edit("editor");
|
|
|
|
$(".snippet-form-holder form").submit(function(){
|
|
|
|
$(".snippet-file-content").val(editor.getValue());
|
|
|
|
});
|