json formatting no html
This commit is contained in:
parent
292b58180d
commit
b81101aa16
@ -3,9 +3,10 @@ class Project < ActiveRecord::Base
|
||||
def self.status_keys
|
||||
{upcoming: 0, active: 1, backlog: 2, completed: 3}
|
||||
end
|
||||
|
||||
enum status: self.status_keys
|
||||
|
||||
|
||||
# HTML
|
||||
def requirements
|
||||
check_date_overdue_output requirements_completed?, requirements_due
|
||||
end
|
||||
@ -22,14 +23,38 @@ class Project < ActiveRecord::Base
|
||||
check_date_overdue_output qalaunch_completed?, qalaunch_due
|
||||
end
|
||||
|
||||
# JSON
|
||||
def requirements_json
|
||||
check_date_overdue_output requirements_completed?, requirements_due, json: true
|
||||
end
|
||||
|
||||
def design_json
|
||||
check_date_overdue_output design_completed?, design_due, json:true
|
||||
end
|
||||
|
||||
def devops_json
|
||||
check_date_overdue_output devops_completed?, devops_due, json:true
|
||||
end
|
||||
|
||||
def qalaunch_json
|
||||
check_date_overdue_output qalaunch_completed?, qalaunch_due, json:true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_date_overdue_output completed, due
|
||||
def check_date_overdue_output completed, due, options = {}
|
||||
if completed
|
||||
if options[:json]
|
||||
"completed"
|
||||
else
|
||||
"<span class='checkmark'>✓</span>".html_safe
|
||||
end
|
||||
elsif Date.today > due
|
||||
if options[:json]
|
||||
"overdue"
|
||||
else
|
||||
"<span class='overdue'>Overdue</span>".html_safe
|
||||
end
|
||||
else
|
||||
due
|
||||
end
|
||||
|
@ -13,7 +13,7 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-7">
|
||||
<h1>Roadmap
|
||||
<h1><%= link_to "Roadmap", root_path %>
|
||||
<p class="lead"></p>
|
||||
</h1>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
json.array!(@projects) do |project|
|
||||
json.extract! project, :id, :title, :status, :requirements, :design, :devops, :qalaunch
|
||||
json.extract! project, :id, :title, :status, :requirements_json, :design_json, :devops_json, :qalaunch_json
|
||||
json.url project_url(project, format: :json)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user