Skip to content

Commit

Permalink
remove the guiding message at comment if the section is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
yufuTW committed Sep 11, 2012
1 parent c930d69 commit 35600cb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -26,4 +26,5 @@ doc/
Gemfile
Gemfile.lock
config.ru
config/zendesk.yml

42 changes: 32 additions & 10 deletions lib/zendesk_ticket.rb
Expand Up @@ -31,7 +31,7 @@ class ZendeskTicket
"reset-password" => "password_reset",
"campaign" => "campaign",
"broken-link" => "broken_link",
"publish-tool" => "publishing_tool"
"publish-tool" => "publishing_tool_tech"
}

def initialize(params, from_route)
Expand Down Expand Up @@ -85,27 +85,45 @@ def format_comment(from_route, params)
when "publish-tool" then
format_comment_for_tech_issues(from_route, params)
else
@@in_comments[from_route].map { |comment_param| "[" + comment_param.to_s.capitalize + "]\n" + params[comment_param] }.join("\n\n")
comment = @@in_comments[from_route].map do |comment_param|
if params[comment_param] && !params[comment_param].empty?
"[" + comment_param.to_s.capitalize + "]\n" + params[comment_param]
end
end

if !comment.join().empty?
comment.join("\n\n")
else
comment.join
end
end
end

def format_comment_for_tech_issues(from_route, params)
all_comments = @@in_comments[from_route].map do |comment_param|
comment = "[" + comment_param.to_s.capitalize + "]\n"
if :url == comment_param
comment += build_full_url_path(params[:url])
else
comment += params[comment_param]
comment = ""
if params[comment_param] && !params[comment_param].empty?
comment = "[" + comment_param.to_s.capitalize + "]\n"
if :url == comment_param
comment += build_full_url_path(params[:url])
else
comment += params[comment_param]
end
end
comment
end
all_comments.join("\n\n")

if !all_comments.join.empty?
all_comments.join("\n\n")
else
all_comments.join
end
end

def format_comment_for_amend_content(params)
comments_sections = {"[URl(s) of content to be changed]" => [build_full_url_path(params[:url1]), build_full_url_path(params[:url2]), build_full_url_path(params[:url3])],
"[Details of what should be added, amended or removed]" => [params[:add_content]],
"[Additional Comments]" => [params[:additional]]
"[Details of what should be added, amended or removed]" => [params[:add_content]],
"[Additional Comments]" => [params[:additional]]
}

comments = comments_sections.map do |key, value|
Expand Down Expand Up @@ -147,6 +165,10 @@ def check_for_attachments(params)
filename = params[:uploaded_data][:filename]
@file_token << upload_file_to_create_file_token(tempfile, filename)
end

if !@file_token.empty? && @comment.empty?
@comment = "[Attachment(s)]"
end
end

def doesFieldHaveValue(field_value)
Expand Down

0 comments on commit 35600cb

Please sign in to comment.