Created
July 10, 2013 03:29
-
-
Save adelevie/5963273 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListFilings < PM::TableScreen | |
title "Docket No. 13-5" | |
def format_cell_title(item) | |
item["type_of_filing"].downcase.capitalize + " of " + item["name_of_filer"] | |
end | |
def on_load | |
url = "http://ruby-sample.initwithcode.com/promotion/dockets/13-5.json" | |
@request = BW::HTTP.get(url) do |response| | |
if response.ok? | |
json = BW::JSON.parse(response.body.to_str) | |
@json_table_data = [{ | |
cells: json.map do |item| | |
{ | |
title: item["title"], | |
subtitle: item["subtitle"], | |
action: :tapped_item, | |
arguments: { item: item }, | |
cell_style: UITableViewCellStyleSubtitle | |
} | |
end | |
}] | |
update_table_data | |
elsif response.status_code.to_s =~ /40\d/ | |
App.alert("Error") | |
else | |
App.alert(response.error_message) | |
end | |
end | |
end | |
def table_data | |
@json_table_data ||= [] | |
end | |
def tapped_item(args={}) | |
#open ViewFiling.new(nav_bar: true, filing: args[:item]) | |
PM.logger.info args[:item] # => { name: "whatever", property: "prop" } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment