move edit to separate controller. This fixes #3265

This commit is contained in:
Dmitriy Zaporozhets 2013-03-24 11:57:44 +02:00
parent b6641d6932
commit 29b0ac489b
5 changed files with 51 additions and 41 deletions

View file

@ -1,7 +1,7 @@
.btn-group.tree-btn-group
-# only show edit link for text files
- if @tree.text?
= link_to "edit", edit_project_tree_path(@project, @id), class: "btn btn-tiny", disabled: !allowed_tree_edit?
= link_to "edit", project_edit_tree_path(@project, @id), class: "btn btn-tiny", disabled: !allowed_tree_edit?
= link_to "raw", project_blob_path(@project, @id), class: "btn btn-tiny", target: "_blank"
-# only show normal/blame view links for text files
- if @tree.text?

View file

@ -1,44 +0,0 @@
.file-editor
= form_tag(project_tree_path(@project, @id), method: :put, class: "form-horizontal") do
.file_holder
.file_title
%i.icon-file
%span.file_name
= @tree.path
%small
on
%strong= @ref
%span.options
.btn-group.tree-btn-group
= link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-tiny btn-cancel", confirm: "Are you sure?"
.file_content.code
%pre#editor= @tree.data
.control-group.commit_message-group
= label_tag 'commit_message', class: "control-label" do
Commit message
.controls
= text_area_tag 'commit_message', '', placeholder: "Update #{@tree.name}", required: true, rows: 3
.form-actions
= hidden_field_tag 'last_commit', @last_commit
= hidden_field_tag 'content', '', id: :file_content
.commit-button-annotation
= button_tag "Commit", class: 'btn commit-btn js-commit-button'
.message
to branch
%strong= @ref
= link_to "Cancel", project_tree_path(@project, @id), class: "btn btn-cancel", confirm: "Are you sure?"
:javascript
var ace_mode = "#{@tree.language.try(:ace_mode)}";
var editor = ace.edit("editor");
if (ace_mode) {
editor.getSession().setMode('ace/mode/' + ace_mode);
}
disableButtonIfEmptyField("#commit_message", ".js-commit-button");
$(".js-commit-button").click(function(){
$("#file_content").val(editor.getValue());
$(".file-editor form").submit();
});