Permalink
Browse files

Started work on the scanning history module, still really broken. SQL…

… is having some SERIOUS issues, can't figure out why.
  • Loading branch information...
Harry Brundage
Harry Brundage committed Nov 27, 2010
1 parent 96a79a0 commit fee0e940b2fca3a4636b45269e159b378bc8b7b3
Showing with 521 additions and 229 deletions.
  1. +7 −7 Resources/app.js
  2. +24 −0 Resources/app/controllers/code_history_controller.coffee
  3. +37 −0 Resources/app/controllers/code_history_controller.js
  4. +6 −1 Resources/app/controllers/code_reader_controller.coffee
  5. +6 −1 Resources/app/controllers/code_reader_controller.js
  6. 0 Resources/app/controllers/codes.coffee
  7. +0 −3 Resources/app/controllers/codes.js
  8. +2 −2 Resources/app/controllers/controller.coffee
  9. +12 −1 Resources/app/controllers/controller.js
  10. +22 −21 Resources/app/controllers/main.coffee
  11. +4 −3 Resources/app/controllers/main.js
  12. +1 −1 Resources/app/controllers/splash_controller.coffee
  13. +3 −1 Resources/app/controllers/splash_controller.js
  14. +13 −14 Resources/app/models/accounts/account_set.coffee
  15. +7 −1 Resources/app/models/splash.coffee
  16. +5 −0 Resources/app/models/splash.js
  17. +46 −0 Resources/app/models/splash_store.coffee
  18. +67 −0 Resources/app/models/splash_store.js
  19. +1 −2 Resources/app/views/accounts/accounts_table_view_window.coffee
  20. +21 −0 Resources/app/views/code_history/code_history_table_view_window.coffee
  21. +36 −0 Resources/app/views/code_history/code_history_table_view_window.js
  22. +0 −7 Resources/app/views/codes/codes_window.coffee
  23. +0 −21 Resources/app/views/codes/codes_window.js
  24. +0 −30 Resources/app/views/splash/splash_loading_window.js
  25. +20 −35 Resources/test.coffee
  26. +76 −45 Resources/vendor/tiajax.coffee
  27. +104 −32 Resources/vendor/tiajax.js
  28. +1 −1 Resources/vendor/underscore.coffee
View
@@ -80,12 +80,12 @@ Ti.include('app/helpers/icons_helper.js');
// Citrus Specific Abstractions
Ti.include("/app/models/observable.js")
-Ti.include('app/models/object.js');
-Ti.include('app/models/persisted_object.js');
-Ti.include('app/views/generic_window.js');
-Ti.include('app/views/placeholder_window.js');
-Ti.include('app/views/data_collection_window.js');
-Ti.include('app/controllers/controller.js');
+Ti.include('/app/models/object.js');
+Ti.include('/app/models/persisted_object.js');
+Ti.include('/app/views/generic_window.js');
+Ti.include('/app/views/placeholder_window.js');
+Ti.include('/app/views/data_collection_window.js');
+Ti.include('/app/controllers/controller.js');
var root = new Citrus.Object(); // Make sure root gets event listeners
-Ti.include('app/controllers/main.js');
+Ti.include('/app/controllers/main.js');
@@ -0,0 +1,24 @@
+Ti.include('/app/views/code_history/code_history_table_view_window.js')
+Ti.include('/app/models/splash_store.js')
+
+class CodeHistoryController extends Citrus.Controller
+ scans: []
+ page: 0
+
+ constructor: () ->
+ d "Code history controller being created"
+ @window = new Citrus.CodeHistoryTableViewWindow(this)
+ @window.win.addEventListener("focus", (e) => this.focused(e))
+
+ focused: (e) ->
+ d "Code history being shown."
+ if @scans.length == 0
+ this.showNextPage()
+
+ showNextPage: () ->
+ @window.showLoading()
+ @window.hideLoading()
+ # Get scans for page and add to scans array
+ # Add new scans to window
+
+Citrus.CodeHistoryController = CodeHistoryController

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -30,7 +30,12 @@ class CodeReaderController extends Citrus.Controller
success: (data) ->
if data?.barcode?
Titanium.Media.vibrate()
- new Citrus.SplashController(data.barcode, root.accountStore)
+ controller = new Citrus.SplashController(data.barcode, root.accountStore)
+ controller.addEventListener "splash:found", (e) ->
+ root.splashStore.addSplash(e.splash)
+
+ controller.tryToShow()
+
cancel: ->
# alert("Canceled")
error: ->

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
No changes.
@@ -1,3 +0,0 @@
-(function() {
-
-}).call(this);
@@ -1,3 +1,3 @@
-class Controller
+class Controller extends Citrus.Object
-Citrus.Controller = Controller
+Citrus.Controller = Controller

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -4,40 +4,41 @@ Ti.include('app/helpers/icons_helper.js')
# Main controllers
Ti.include('app/controllers/accounts_controller.js')
Ti.include('app/controllers/code_reader_controller.js')
-Ti.include('app/views/codes/codes_window.js')
+Ti.include('app/controllers/code_history_controller.js')
-root.tabGroup = Titanium.UI.createTabGroup({barColor:'#336699'})
-Titanium.UI.setBackgroundColor('#000')
+root.tabGroup = Titanium.UI.createTabGroup
+ barColor:'#336699'
+
+Titanium.UI.setBackgroundColor '#000'
# Code Reader tab group
root.CodeReaderController = new Citrus.CodeReaderController()
-codeReaderTab = Titanium.UI.createTab({
- icon:'images/radar.png',
- title:'Scanner',
- window: root.CodeReaderController.window.win
-})
-
+codeReaderTab = Titanium.UI.createTab
+ icon:'images/radar.png',
+ title:'Scanner',
+ window: root.CodeReaderController.window.win
# Accounts List tab group
root.accountStore = new Citrus.AccountSet()
root.AccountsController = new Citrus.AccountsController(root.accountStore)
-accountsTab = Titanium.UI.createTab({
- icon:'images/id-card.png',
- title:'Accounts',
- window: root.AccountsController.window.win
-})
+accountsTab = Titanium.UI.createTab
+ icon:'images/id-card.png',
+ title:'Accounts',
+ window: root.AccountsController.window.win
# Scanned Codes list tab group
-root.CodesWindow = new Citrus.CodesWindow('Codes','No Codes scanned yet.')
-codesTab = Titanium.UI.createTab({
- icon:'images/clock.png',
- title:'Scanned Codes',
- window: root.CodesWindow.win
-})
+root.splashStore = new Citrus.SplashStore()
+root.CodeHistoryController = new Citrus.CodeHistoryController()
+
+codesTab = Titanium.UI.createTab
+ icon:'images/clock.png'
+ title:'Scanned Codes'
+ window: root.CodeHistoryController.window.win
Titanium.include('test.js')
root.tabGroup.addTab(tab) for tab in [codeReaderTab, accountsTab, codesTab]
root.tabGroup.setActiveTab(accountsTab)
-root.tabGroup.open({transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT})
+root.tabGroup.open
+ transition:Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -7,7 +7,6 @@ class SplashController extends Citrus.Controller
@window = new Citrus.SplashWindow(this)
root.tabGroup.activeTab.open @window.win, {animated:true}
- this.tryToShow()
tryToShow: () ->
d("Trying to show "+@codeData)
@@ -17,6 +16,7 @@ class SplashController extends Citrus.Controller
d("Found a splash in the decoded data, with shortcode "+splash.shortcode)
@splash = splash
@splash.actions = this._prepareActions(@splash.actions)
+ this.fireEvent "splash:found", {splash:@splash}
@window.displaySplash(@splash)
, (xhr, status, error) =>
e("Error finding a Citrus splash from the decoded data. Status: "+status)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,55 +1,54 @@
class AccountSet extends Citrus.Object
-
+
constructor: () ->
@accounts = []
-
this.load()
-
+
# Loads the account set from the app properties
load: ->
# Ti.API.debug("Loading accounts from : ")
# Ti.API.debug(Ti.App.Properties.getString("CitrusAccounts"))
-
+
return [] unless Ti.App.Properties.hasProperty(this.key())
try
datas = JSON.parse(Ti.App.Properties.getString(this.key()))
catch e
Ti.API.error("Error parsing account set JSON from properties: ")
Ti.API.error(e)
return false
-
+
datas ?= []
accounts = []
for datum in datas
account = Citrus.PersistedObject.loadFromPersistable(datum)
if account
Ti.API.info("Loaded "+account.type+" from persistable.")
accounts.push account
-
+
@accounts = accounts
return @accounts
-
+
# Persists the account set so the app can be closed. Works by serializing the accounts
# to JSON and then saving in the app properties.
- save: ->
+ save: ->
Ti.API.debug("Saving accounts store.")
persistable_accounts = []
for account in @accounts
persistable_accounts.push(account.persistable())
-
-
+
+
return Ti.App.Properties.setString(this.key(), JSON.stringify(persistable_accounts))
-
+
key: ->
return "CitrusAccounts"
addAccount: (account) ->
Ti.API.debug("Account Added to store.")
@accounts.push account
this.save()
-
+
removeAccount: (account) ->
@accounts = _.without(@accounts, account)
this.save()
-
-Citrus.AccountSet = AccountSet
+
+Citrus.AccountSet = AccountSet
@@ -29,14 +29,17 @@ class Splash extends Citrus.Object
else
error(false, "not_citrus_code")
return false
-
+
name: ""
description: ""
photo: ""
text: ""
shortcode: ""
+ _persistable: {}
+
constructor: (attributes) ->
super()
+ this._persistable = attributes
@actions = []
for k,v of attributes
if _.isFunction(this[k])
@@ -57,5 +60,8 @@ class Splash extends Citrus.Object
else
Ti.API.error("Invalid/Unknown action! Attributes were:")
Ti.API.debug(attrs)
+
+ persistable: () ->
+ return this._persistable
Citrus.Splash = Splash

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit fee0e94

Please sign in to comment.