FIX 修复易修标题过长导致排版问题
This commit is contained in:
		
						commit
						51597335a4
					
				| 
						 | 
				
			
			@ -101,13 +101,8 @@ class IssuesController < ApplicationController
 | 
			
		|||
  end
 | 
			
		||||
 | 
			
		||||
  def create
 | 
			
		||||
    if params[:subject].blank?
 | 
			
		||||
      normal_status(-1, "标题不能为空")
 | 
			
		||||
    elsif params[:subject].to_s.size > 255
 | 
			
		||||
      normal_status(-1, "标题不能超过255个字符")
 | 
			
		||||
    else
 | 
			
		||||
    issue_params = issue_send_params(params)
 | 
			
		||||
 | 
			
		||||
    Issues::CreateForm.new({subject:issue_params[:subject]}).validate!
 | 
			
		||||
    @issue = Issue.new(issue_params)
 | 
			
		||||
    if @issue.save!
 | 
			
		||||
      if params[:attachment_ids].present?
 | 
			
		||||
| 
						 | 
				
			
			@ -143,9 +138,9 @@ class IssuesController < ApplicationController
 | 
			
		|||
    else
 | 
			
		||||
      normal_status(-1, "创建失败")
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
  rescue Exception => exception
 | 
			
		||||
    puts exception.message
 | 
			
		||||
    normal_status(-1, exception.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def edit
 | 
			
		||||
| 
						 | 
				
			
			@ -199,7 +194,7 @@ class IssuesController < ApplicationController
 | 
			
		|||
      normal_status(-1, "不允许修改为关闭状态")
 | 
			
		||||
    else
 | 
			
		||||
      issue_params = issue_send_params(params).except(:issue_classify, :author_id, :project_id)
 | 
			
		||||
 | 
			
		||||
      Issues::UpdateForm.new({subject:issue_params[:subject]}).validate!
 | 
			
		||||
      if @issue.update_attributes(issue_params)
 | 
			
		||||
        if params[:status_id].to_i == 5  #任务由非关闭状态到关闭状态时
 | 
			
		||||
          @issue.issue_times.update_all(end_time: Time.now)
 | 
			
		||||
| 
						 | 
				
			
			@ -225,6 +220,9 @@ class IssuesController < ApplicationController
 | 
			
		|||
        normal_status(-1, "更新失败")
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
  rescue Exception => exception
 | 
			
		||||
    puts exception.message
 | 
			
		||||
    normal_status(-1, exception.message)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def show
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
class Issues::CreateForm
 | 
			
		||||
  include ActiveModel::Model
 | 
			
		||||
 | 
			
		||||
  attr_accessor :subject
 | 
			
		||||
 | 
			
		||||
  validates :subject, presence: { message: "不能为空" }
 | 
			
		||||
 | 
			
		||||
  validates :subject, length: { maximum: 80, too_long: "不能超过80个字符" }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,10 @@
 | 
			
		|||
class Issues::UpdateForm
 | 
			
		||||
  include ActiveModel::Model
 | 
			
		||||
 | 
			
		||||
  attr_accessor :subject
 | 
			
		||||
 | 
			
		||||
  validates :subject, presence: { message: "不能为空" }
 | 
			
		||||
 | 
			
		||||
  validates :subject, length: { maximum: 80, too_long: "不能超过80个字符" }
 | 
			
		||||
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
'zh-CN':
 | 
			
		||||
  activemodel:
 | 
			
		||||
    attributes:
 | 
			
		||||
      issues/create_form:
 | 
			
		||||
        subject: 标题
 | 
			
		||||
      issues/update_form:
 | 
			
		||||
        subject: 标题
 | 
			
		||||
		Loading…
	
		Reference in New Issue