]>
git.proxmox.com Git - sencha-touch.git/blob - src/examples/device/app/controller/Purchases.js
1 Ext
.define('Device.controller.Purchases', {
2 extend
: 'Ext.app.Controller',
3 requires
: ['Ext.device.Purchases'],
7 productsList
: 'purchases list#products',
8 purchasesList
: 'purchases list#purchases',
9 purchaseProduct
: 'purchases #purchaseProduct',
10 completePurchase
: 'purchases #completePurchase'
15 deselect
: 'onProductDeselect',
16 select
: 'onProductSelect'
19 deselect
: 'onPurchaseDeselect',
20 select
: 'onPurchaseSelect'
22 'purchases #loadProducts': {
25 'purchases #loadPurchases': {
29 tap
: 'purchaseProduct'
32 tap
: 'completePurchase'
37 loadProducts: function() {
38 var list
= this.getProductsList();
40 Ext
.device
.Purchases
.getProducts({
42 success: function(store
) {
46 Ext
.device
.Notification
.show({
48 message
: 'Problem loading products'
54 purchaseProduct: function() {
55 var list
= this.getProductsList(),
56 record
= list
.getSelection()[0];
66 Ext
.device
.Notification
.show({
67 title
: 'Purchase Product',
68 message
: 'Problem completing purchase'
72 Ext
.device
.Notification
.show({
73 title
: 'Purchase Product',
74 message
: 'Problem purchasing product'
80 completePurchase: function() {
81 var list
= this.getPurchasesList(),
82 record
= list
.getSelection()[0];
92 Ext
.device
.Notification
.show({
93 title
: 'Complete Purchase',
94 message
: 'Purchase completed'
98 Ext
.device
.Notification
.show({
99 title
:'Complete Purchase',
100 message
: 'Problem completing purchase'
106 onProductDeselect: function(view
, record
) {
107 this.getPurchaseProduct().setDisabled(true);
110 onProductSelect: function(view
, record
) {
111 this.getPurchaseProduct().setDisabled(false);
114 onPurchaseDeselect: function(view
, record
) {
115 this.getCompletePurchase().setDisabled(true);
118 onPurchaseSelect: function(view
, record
) {
119 this.getCompletePurchase().setDisabled(false);
122 loadPurchases: function() {
123 var list
= this.getPurchasesList();
125 Ext
.device
.Purchases
.getPendingPurchases({
127 success: function(store
) {
128 list
.setStore(store
);
130 failure: function() {
131 Ext
.device
.Notification
.show({
133 message
: 'Problem loading purchases'