35 lines
990 B
Ruby
35 lines
990 B
Ruby
module Mobile
|
|
module Entities
|
|
class Issue <Grape::Entity
|
|
include ApiHelper
|
|
include Redmine::I18n
|
|
def self.issue_expose(f)
|
|
expose f do |issue, opt|
|
|
if issue.is_a?(Hash) && issue.key?(f)
|
|
issue[f]
|
|
elsif issue.is_a?(::Issue)
|
|
if issue.respond_to?(f)
|
|
issue.send(f)
|
|
else
|
|
case f
|
|
when :issue_priority
|
|
get_issue_priority_api issue.priority_id
|
|
when :issue_assigned_to
|
|
(get_user(issue.assigned_to_id)).login
|
|
when :issue_status
|
|
IssueStatus.find(issue.status_id).name
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|
|
expose :subject
|
|
expose :description
|
|
expose :author, using: Mobile::Entities::User
|
|
expose :done_ratio
|
|
issue_expose :issue_priority
|
|
issue_expose :issue_assigned_to
|
|
issue_expose :issue_status
|
|
end
|
|
end
|
|
end |