Skip to content

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
paolotax committed Feb 20, 2013
1 parent 075880b commit 7f099d6
Show file tree
Hide file tree
Showing 14 changed files with 234 additions and 222 deletions.
4 changes: 2 additions & 2 deletions app/app_delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ def application(application, didFinishLaunchingWithOptions:launchOptions)

AFNetworkActivityIndicatorManager.sharedManager.enabled = true

Store.shared.login(lambda do
Store.shared.login do
puts "logged in"
end)
end

if Device.ipad?
storyboard = UIStoryboard.storyboardWithName("MainStoryboard_iPad", bundle:nil)
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/cliente_detail_view_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def viewDidLoad

def sorted_appunti
@sorted_appunti = []
orderAppunti = NSSortDescriptor.sortDescriptorWithKey("remote_id", ascending:false)
orderAppunti = NSSortDescriptor.sortDescriptorWithKey("created_at", ascending:false)
@sorted_appunti = @cliente.appunti.sortedArrayUsingDescriptors([orderAppunti])
@sorted_appunti
end
Expand Down Expand Up @@ -118,6 +118,7 @@ def prepareForSegue(segue, sender:sender)
a.ClienteId = @cliente.ClienteId
a.cliente_nome = @cliente.nome
a.status = "da_fare"
a.created_at = Time.now
end
segue.destinationViewController.visibleViewController.appunto = appunto
end
Expand Down
94 changes: 0 additions & 94 deletions app/controllers/cliente_view_controller.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/controllers/clienti_table_view_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def loadFromBackend
Store.shared.backend.getObjectsAtPath("api/v1/clienti",
parameters: nil,
success: lambda do |operation, result|
@clienti = result.array
Cliente.reset
tableView.reloadData
doneReloadingTableViewData
SVProgressHUD.dismiss
Expand Down
52 changes: 51 additions & 1 deletion app/controllers/menu_view_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,58 @@ def viewDidLoad
end

def login(sender)
Store.shared.login
Store.shared.login {}
end

def importa(sender)
Store.shared.clear
Store.shared.login do
puts "loggato"
Store.shared.backend.getObjectsAtPath("api/v1/clienti",
parameters: nil,
success: lambda do |operation, result|
puts "Clienti: #{result.array.count}"
self.addAppunti
end,
failure: lambda do |operation, error|
puts error
end)
end
end

def addAppunti
Store.shared.backend.getObjectsAtPath("api/v1/appunti",
parameters: nil,
success: lambda do |operation, result|
puts "Appunti: #{result.array.count}"
self.addLibri
end,
failure: lambda do |operation, error|
puts error
end)
end

def addLibri
Store.shared.backend.getObjectsAtPath("api/v1/libri",
parameters: nil,
success: lambda do |operation, result|
puts "Libri: #{result.array.count}"
self.addRighe
end,
failure: lambda do |operation, error|
puts error
end)
end

def addRighe
Store.shared.backend.getObjectsAtPath("api/v1/righe",
parameters: nil,
success: lambda do |operation, result|
puts "Righe: #{result.array.count}"
end,
failure: lambda do |operation, error|
puts error
end)
end

end
4 changes: 2 additions & 2 deletions app/models_old/appunto.rb → app/models/appunto.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Appunto < NSManagedObject
{ name: 'note', type: NSStringAttributeType, default: '', optional: true, transient: false, indexed: false},
{ name: 'telefono', type: NSStringAttributeType, default: '', optional: true, transient: false, indexed: false},
{ name: 'email', type: NSStringAttributeType, default: '', optional: true, transient: false, indexed: false},
{ name: 'created_at', type: NSStringAttributeType, default: '', optional: true, transient: false, indexed: false},
{ name: 'updated_at', type: NSStringAttributeType, default: '', optional: true, transient: false, indexed: false},
{ name: 'created_at', type: NSDateAttributeType, default: nil, optional: true, transient: false, indexed: false},
{ name: 'updated_at', type: NSDateAttributeType, default: nil, optional: true, transient: false, indexed: false},
{ name: 'totale_copie', type: NSInteger32AttributeType, default: 0, optional: true, transient: false, indexed: false},
{ name: 'totale_importo', type: NSDecimalAttributeType, default: 0.0, optional: true, transient: false, indexed: false}
]
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 10 additions & 6 deletions app/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Store
ManagedObjectClasses = [Libro, Cliente, Appunto, Riga]

#BASE_URL = "http://youpropa.com"
BASE_URL = "http://localhost:3000"
BASE_URL = "http://192.168.1.132:3000"

USERNAME = 'paolotax'
PASSWORD = 'sisboccia'
Expand All @@ -20,7 +20,7 @@ class Store

# login

def login(block)
def login(&block)
data = {
grant_type: 'password',
client_id: APP_ID,
Expand Down Expand Up @@ -129,14 +129,18 @@ def initialize
url = NSURL.URLWithString(BASE_URL)
@backend = RKObjectManager.managerWithBaseURL(url)

formatter = NSDateFormatter.new
formatter.setDateFormat("yyyy-MM-dd'T'HH:mm:ssz")
RKObjectMapping.addDefaultDateFormatter(formatter)

@store = RKManagedObjectStore.alloc.initWithManagedObjectModel(@model)
@backend.managedObjectStore = @store
@backend.requestSerializationMIMEType = RKMIMETypeJSON

store_path = RKApplicationDataDirectory().stringByAppendingPathComponent("Libri.sqlite")

# error = Pointer.new(:object)
# NSFileManager.defaultManager.removeItemAtPath(store_path, error:error)
error = Pointer.new(:object)
NSFileManager.defaultManager.removeItemAtPath(store_path, error:error)

error_ptr = Pointer.new(:object)
unless @store.addSQLitePersistentStoreAtPath(store_path,
Expand All @@ -155,8 +159,8 @@ def initialize
@persistent_context = @store.persistentStoreManagedObjectContext
@context = @store.mainQueueManagedObjectContext

#RKlcl_configure_by_name("RestKit/Network", RKLogLevelTrace)
#RKlcl_configure_by_name("RestKit/ObjectMapping", RKLogLevelTrace)
RKlcl_configure_by_name("RestKit/Network", RKLogLevelTrace)
RKlcl_configure_by_name("RestKit/ObjectMapping", RKLogLevelTrace)

MappingProvider.shared.init_mappings(@store, @backend)
end
Expand Down
12 changes: 7 additions & 5 deletions app/views/cells/appunto_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def layoutSubviews
@clienteLabel.frame = CGRectMake(48, 8, 185, 21)
@destinatarioLabel.frame = CGRectMake(48, 35, 231, 21)
@noteLabel.frame = CGRectMake(48, 60, 231, 21)
@dataLabel.frame = CGRectMake(246, 8, 42, 21)
@dataLabel.frame = CGRectMake(240, 8, 48, 21)
@customBadge.frame = CGRectMake(288 - @customBadge.frame.size.width, 34, @customBadge.frame.size.width, @customBadge.frame.size.height)
end

Expand All @@ -55,12 +55,14 @@ def setHighlighted(highlighted, animated:animated)

private

def format_date(date_str)
def format_date(date)
formatter = NSDateFormatter.alloc.init
formatter.setLocale(NSLocale.alloc.initWithLocaleIdentifier("it_IT"))
formatter.setDateFormat("yyyy-MM-dd'T'HH:mm:ssz")
date = formatter.dateFromString(date_str)
formatter.setDateFormat("d MMM")
if date.year == Time.now.year
formatter.setDateFormat("d MMM")
else
formatter.setDateFormat("MMM yy")
end
date_str = formatter.stringFromDate(date)
date_str
end
Expand Down
14 changes: 8 additions & 6 deletions app/views/cells/cliente_appunto_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def initWithFrame(frame)
cell.contentView.addSubview(label)
end

@data_label = UILabel.alloc.initWithFrame([[120, 5], [45, 15]]).tap do |label|
@data_label = UILabel.alloc.initWithFrame([[110, 5], [55, 15]]).tap do |label|
#label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
label.font = UIFont.systemFontOfSize(11.0)
Expand Down Expand Up @@ -73,7 +73,7 @@ def appunto=(appunto)
if @appunto
@destinatario_label.text = @appunto.destinatario
@note_label.text = format_appunto
@importo_label.text = @appunto.righe.count == 0 ? "" : "#{appunto.totale_copie} copie #{@appunto.importo} €"
@importo_label.text = @appunto.righe.count == 0 ? "" : "#{appunto.totale_copie} copie #{@appunto.totale_importo} €"
@data_label.text = format_date @appunto.created_at
@status_image.setImage UIImage.imageNamed("task-#{@appunto.status}")
# if @appunto.totale_copie == 0
Expand All @@ -90,12 +90,14 @@ def appunto=(appunto)

private

def format_date(date_str)
def format_date(date)
formatter = NSDateFormatter.alloc.init
formatter.setLocale(NSLocale.alloc.initWithLocaleIdentifier("it_IT"))
formatter.setDateFormat("yyyy-MM-dd'T'HH:mm:ssz")
date = formatter.dateFromString(date_str)
formatter.setDateFormat("d MMM")
if date.year == Time.now.year
formatter.setDateFormat("d MMM")
else
formatter.setDateFormat("MMM yy")
end
date_str = formatter.stringFromDate(date)
date_str
end
Expand Down
29 changes: 12 additions & 17 deletions app/views/test_modal_picker_view.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,27 +37,22 @@ def killApp
end

def login
Store.shared.login(lambda do
puts "logged in"
end)
Store.shared.login {}
end

def importa
Store.shared.clear
Store.shared.login(
lambda do
puts "loggato"
Store.shared.backend.getObjectsAtPath("api/v1/clienti",
parameters: nil,
success: lambda do |operation, result|
puts "Clienti: #{result.array.count}"
self.addAppunti
end,
failure: lambda do |operation, error|
puts error
end)
end
)
Store.shared.login do
Store.shared.backend.getObjectsAtPath("api/v1/clienti",
parameters: nil,
success: lambda do |operation, result|
puts "Clienti: #{result.array.count}"
self.addAppunti
end,
failure: lambda do |operation, error|
puts error
end)
end
end

def addAppunti
Expand Down
Loading

0 comments on commit 7f099d6

Please sign in to comment.