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
|
def self.status_keys
|
||||||
{upcoming: 0, active: 1, backlog: 2, completed: 3}
|
{upcoming: 0, active: 1, backlog: 2, completed: 3}
|
||||||
end
|
end
|
||||||
|
|
||||||
enum status: self.status_keys
|
enum status: self.status_keys
|
||||||
|
|
||||||
|
# HTML
|
||||||
def requirements
|
def requirements
|
||||||
check_date_overdue_output requirements_completed?, requirements_due
|
check_date_overdue_output requirements_completed?, requirements_due
|
||||||
end
|
end
|
||||||
@ -22,14 +23,38 @@ class Project < ActiveRecord::Base
|
|||||||
check_date_overdue_output qalaunch_completed?, qalaunch_due
|
check_date_overdue_output qalaunch_completed?, qalaunch_due
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
def check_date_overdue_output completed, due
|
def check_date_overdue_output completed, due, options = {}
|
||||||
if completed
|
if completed
|
||||||
|
if options[:json]
|
||||||
|
"completed"
|
||||||
|
else
|
||||||
"<span class='checkmark'>✓</span>".html_safe
|
"<span class='checkmark'>✓</span>".html_safe
|
||||||
|
end
|
||||||
elsif Date.today > due
|
elsif Date.today > due
|
||||||
|
if options[:json]
|
||||||
|
"overdue"
|
||||||
|
else
|
||||||
"<span class='overdue'>Overdue</span>".html_safe
|
"<span class='overdue'>Overdue</span>".html_safe
|
||||||
|
end
|
||||||
else
|
else
|
||||||
due
|
due
|
||||||
end
|
end
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
<h1>Roadmap
|
<h1><%= link_to "Roadmap", root_path %>
|
||||||
<p class="lead"></p>
|
<p class="lead"></p>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
json.array!(@projects) do |project|
|
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)
|
json.url project_url(project, format: :json)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user