Skip to content

Instantly share code, notes, and snippets.

@russelh15
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russelh15/ec1bc7284ef1388bd906 to your computer and use it in GitHub Desktop.
Save russelh15/ec1bc7284ef1388bd906 to your computer and use it in GitHub Desktop.
//Main.js File
//Create our firebase base reference
Alloy.Globals.fb = Firebase.new('https://myaccount.com/account/' + args.accountId);
//Items.js File
var orderRef = Alloy.Globals.fb.child("/orders/" + args.order.orderId);
_xItems = {
init : function(){
//Boostrap functions go here, including opening the window and building table rows, etc....
//Set the title
$.header.title.text = "#" + this.order.orderNumber;
this.build_item_rows();
$.itemsWindow.open({
transition : Titanium.UI.iPhone.AnimationStyle.FLIP_FROM_LEFT
});
this.bind_events();
},
/**
* Display the items in the table view
*/
build_item_rows: function()
{
var items = this.items;
var data = [];
var row;
var itemLabel;
var itemName;
var image_url = '';
var full_image = '';
for(var i in items)
{
//Set a barcode scanned and barcode exists property
items[i].barcodeScanned = false;
items[i].barcodeExists = false;
//Check to see if a barcode exists
if(items[i].barcode != "" && items[i].barcode != null)
{
items[i].barcodeExists = true;
}
//Thumbnail
if(Alloy.Globals.string.trim(items[i].thumbnail) != "")
{
image_url = items[i].thumbnail;
}
else
{
image_url = 'images/no_image_logo.png';
}
//Full Image
if(Alloy.Globals.utils.object.count(items[i].productImages) > 0)
{
full_image = items[i].productImages[0].imageURL;
}
else
{
full_image = 'images/no_image_logo.png';
}
var args = {
title : items[i].productName,
sku : items[i].sku,
bin : items[i].bin,
image : image_url,
fullImage : full_image,
check : Alloy.Globals.fa.icon('icon-ok'),
qty : items[i].quantity,
barcode : items[i].barcode
};
row = Alloy.createController('orders/itemrow', args).getView();
row.fullItem = items[i];
data.push(row);
}
$.itemsTable.setData(data);
}
};
orderRef.on('value', function (snapshot) {
_xItems.init();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment