[refs #90] pull title/body update
This commit is contained in:
parent
ca72504ca2
commit
60aba754ae
|
@ -0,0 +1,31 @@
|
|||
$(document).ready(function() {
|
||||
$('.edit_form.pull').live('submit', function() {
|
||||
var form = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: form.attr("action"),
|
||||
data: form.serialize(),
|
||||
success: function(data){
|
||||
form.fadeOut('slow');
|
||||
$('#edit_pull_content').fadeIn('slow');
|
||||
$('.rightlist.pull_title').html(form.find('#pull_title').attr('value'));
|
||||
$('.rightlist.pull_body').html(form.find('#pull_body').attr('value'));
|
||||
},
|
||||
error: function(data){
|
||||
alert('error'); // TODO remove
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#edit_pull_content').live('click', function() {
|
||||
$('.edit_form.pull').fadeIn('fast');
|
||||
$(this).fadeOut('fast');
|
||||
});
|
||||
|
||||
$('#cancel_edit_pull_content').live('click', function() {
|
||||
$('.edit_form.pull').fadeOut('fast');
|
||||
$('#edit_pull_content').fadeIn('fast');
|
||||
});
|
||||
|
||||
});
|
|
@ -53,7 +53,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
end
|
||||
|
||||
def update
|
||||
redirect_to(project_pull_request_path(@project, @pull)) # dummy
|
||||
render :nothing => true, :status => (@pull.update_attributes(params[:pull_request]) ? 200 : 500), :layout => false
|
||||
end
|
||||
|
||||
def merge
|
||||
|
@ -99,7 +99,7 @@ class Projects::PullRequestsController < Projects::BaseController
|
|||
|
||||
def load_pull
|
||||
if params[:action].to_sym != :index
|
||||
@pull = @project.pull_requests.joins(:issue).where(:issues => {:id => @issue.id}).first
|
||||
@pull = @project.pull_requests.joins(:issue).where(:issues => {:id => @issue.id}).readonly(false).first
|
||||
else
|
||||
@pull_requests = @project.pull_requests
|
||||
end
|
||||
|
|
|
@ -11,6 +11,7 @@ class Issue < ActiveRecord::Base
|
|||
has_many :subscribes, :as => :subscribeable, :dependent => :destroy
|
||||
has_many :labelings, :dependent => :destroy
|
||||
has_many :labels, :through => :labelings, :uniq => true
|
||||
has_one :pull_request
|
||||
|
||||
validates :title, :body, :project_id, :presence => true
|
||||
|
||||
|
|
|
@ -3,8 +3,7 @@ class PullRequest < ActiveRecord::Base
|
|||
belongs_to :base_project, :class_name => 'Project', :foreign_key => 'base_project_id'
|
||||
belongs_to :head_project, :class_name => 'Project', :foreign_key => 'head_project_id'
|
||||
delegate :user, :title, :body, :serial_id, :assignee, :status, :to_param, :to => :issue, :allow_nil => true
|
||||
accepts_nested_attributes_for :issue
|
||||
#attr_accessible #FIXME disable for development
|
||||
|
||||
validate :uniq_merge
|
||||
validates_each :head_ref, :base_ref do |record, attr, value|
|
||||
project = attr == :head_ref ? record.head_project : record.base_project
|
||||
|
@ -16,6 +15,9 @@ class PullRequest < ActiveRecord::Base
|
|||
before_create :clean_dir
|
||||
after_destroy :clean_dir
|
||||
|
||||
accepts_nested_attributes_for :issue
|
||||
attr_accessible :issue_attributes
|
||||
|
||||
scope :needed_checking, includes(:issue).where(:issues => {:status => ['open', 'blocked', 'ready', 'already']})
|
||||
|
||||
state_machine :status, :initial => :open do
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
.rightlist=issue.text_area :body
|
||||
.both
|
||||
|
||||
.leftlist for debug
|
||||
.leftlist=f.label :title, t('activerecord.attributes.issue.status'), :class => :label
|
||||
.rightlist=@pull.status
|
||||
.both
|
||||
.leftlist
|
||||
|
|
|
@ -20,11 +20,24 @@
|
|||
.rightlist=@pull.head_ref
|
||||
.both
|
||||
.leftlist=t('activerecord.attributes.issue.title')
|
||||
.rightlist=@pull.issue.title
|
||||
.rightlist.pull_title=@pull.issue.title
|
||||
.both
|
||||
.leftlist=t('activerecord.attributes.issue.body')
|
||||
.rightlist=@pull.issue.body
|
||||
.rightlist.pull_body=@pull.issue.body
|
||||
.both
|
||||
- if can? :update, @pull.issue
|
||||
%br
|
||||
=link_to t('layout.edit'), '#', :id => 'edit_pull_content', :class => 'button'
|
||||
=form_for @pull, :url => [@project, @pull], :method => :put, :html => { :class => 'edit_form pull', :style => 'display:none;' } do |f|
|
||||
= f.fields_for :issue do |issue|
|
||||
.leftlist= t('activerecord.attributes.issue.title') + ':'
|
||||
.rightlist= issue.text_field :title, :id => 'pull_title'
|
||||
.both
|
||||
.leftlist= t('activerecord.attributes.issue.body') + ':'
|
||||
.rightlist= issue.text_area :body, :id => 'pull_body'
|
||||
.both
|
||||
=f.submit t('layout.update'), :id => 'update_pull_content'
|
||||
=link_to t('layout.issues.cancel_button'), '#', :id => 'cancel_edit_pull_content', :class => 'button'
|
||||
.leftlist=t('activerecord.attributes.issue.status')
|
||||
.rightlist=@pull.issue.status
|
||||
.both
|
||||
|
|
Loading…
Reference in New Issue