Permalink
Browse files

updates

  • Loading branch information...
1 parent 26cc19c commit e25a6a5cfe3a4527d045b7832469cdb8bfe5c2bc Eric Bowden committed Jun 14, 2012
View
@@ -0,0 +1 @@
+node_modules
View
@@ -14,7 +14,7 @@
"appName": "MyApp"
},
"xdsVersion": "2.0.0",
- "xdsBuild": 210000000494,
+ "xdsBuild": 210000000495,
"framework": "touch20",
"topInstanceFileMap": {
"9c7e563e-7ff0-4ba7-9556-9c0d6c286927": {
View
@@ -0,0 +1 @@
+web: node server.js
View
@@ -6,9 +6,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>LoanShark</title>
- <script src="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/sencha-touch-all.js"></script>
+ <script src="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/sencha-touch-all-debug.js"></script>
<link rel="stylesheet" href="http://extjs.cachefly.net/touch/sencha-touch-2.0.0/resources/css/sencha-touch.css">
- <script type="text/javascript" src="app.js?_dc=1339635875912"></script>
+ <script type="text/javascript" src="app.js?_dc=1339715941134"></script>
<script type="text/javascript">
if (!Ext.browser.is.WebKit) {
alert("The current browser is unsupported.\n\nSupported browsers:\n" +
View
@@ -15,6 +15,7 @@
Ext.define('Payback.controller.Contact', {
extend: 'Ext.app.Controller',
+
config: {
stores: [
'PeopleStore'
@@ -23,6 +24,11 @@ Ext.define('Payback.controller.Contact', {
'ContactDetail'
],
+ routes: {
+ 'Prey': 'showContactPanel',
+ 'Prey/:id': 'showContactDetail'
+ },
+
refs: {
ContactDetail: {
selector: 'ContactDetail',
@@ -45,7 +51,7 @@ Ext.define('Payback.controller.Contact', {
},
"#myContactDataView": {
itemswipe: 'onDataviewItemSwipe',
- itemtap: 'onDataviewtemTap'
+ itemtap: 'onDataviewItemTap'
}
}
},
@@ -60,11 +66,11 @@ Ext.define('Payback.controller.Contact', {
Ext.getStore('Debts').clearFilter();
//refresh DataView
- this.getMyDebtDataView().refresh();
+ //this.getMyDebtDataView().refresh(); //??????????
//hides buttons and debt data view on new contacts
- //this.getAddPaymentButton().hide();
- this.getMyDebtDataView().hide();
+ form.down('#addDebt').hide();
+ form.down('dataview').hide();
//set active item
Ext.Viewport.setActiveItem(this.getContactDetail());
@@ -75,9 +81,26 @@ Ext.define('Payback.controller.Contact', {
record = form.getRecord(),
values = form.getValues();
+ //validate
+ var isValid = function(record) {
+ var errors = record.validate();
+
+ if(errors.isValid())// || record.get('email') === "")
+ return true;
+ else {
+ Ext.Msg.alert('Error', 'Invalid Email address', Ext.emptyFn);
+ return false;
+ }
+
+ };
if(record) { //if editing record
record.set(values);
+
+ //validate
+ if(!isValid(record))
+ return;
+
record.save();
if (record.isModified('name')) {
@@ -86,9 +109,17 @@ Ext.define('Payback.controller.Contact', {
}
} else { //if new record
- var record = Ext.getStore('People').add(values)[0];
- record.commit();
- //Ext.getStore('People').sync();
+
+ record = Ext.create('Payback.model.Person',values);
+
+ //validate
+ if(!isValid(record)) {
+ return;
+ }
+ Ext.getStore('People').add(record);
+ //record.commit();
+ //record.save();
+ Ext.getStore('People').sync();
}
//update summary
@@ -120,13 +151,13 @@ Ext.define('Payback.controller.Contact', {
//show item delete button
target.query('button')[0].show();
- //hide delete button after tap
+ //hides delete button if anywhere else is tapped
Ext.Viewport.element.on({tap:function(){
target.query('button')[0].hide();
}, single:true});
},
- onDataviewtemTap: function(dataview, index, target, record, e, options) {
+ onDataviewItemTap: function(dataview, index, target, record, e, options) {
var form = this.getContactDetail(),
debtDataView = this.getMyDebtDataView();
@@ -142,9 +173,27 @@ Ext.define('Payback.controller.Contact', {
//show items if hidden
debtDataView.show();
+ form.down('#addDebt').show();
+
//set active item
Ext.Viewport.setActiveItem(form);
+ },
+
+ showContactPanel: function() {
+
+ //switch to contact panel
+ Ext.Viewport.getActiveItem().setActiveItem(2);
+ },
+
+ showContactDetail: function(id) {
+ this.showContactPanel();
+ var dataItem = this.getMyContactDataView().getItems().getAt(0).getInnerItems()[id];
+
+ if(dataItem) {
+ this.onDataviewItemTap(null,null,null, dataItem.getRecord());
+ location.hash = 'Prey/'+id;
+ }
}
});
View
@@ -15,7 +15,13 @@
Ext.define('Payback.controller.Debt', {
extend: 'Ext.app.Controller',
+
config: {
+ routes: {
+ 'Debt': 'showDebtPanel',
+ 'Debt/:id': 'showDebtDetail'
+ },
+
refs: {
DebtDetail: {
selector: 'DebtDetail',
@@ -53,6 +59,9 @@ Ext.define('Payback.controller.Debt', {
form.reset();
form.setRecord(null); //remove record from form
+ //sets date field to today
+ form.down('datepickerfield').setValue(new Date());
+
//clears filter placed on Payment store
Ext.getStore('Payments').clearFilter();
@@ -61,13 +70,15 @@ Ext.define('Payback.controller.Debt', {
this.getMyPaymentDataView().hide();
this.getEmailDebtButton().hide();
+ //remember previous panel to return to
+ this.prevPanel = Ext.Viewport.getActiveItem();
+
//set active item
Ext.Viewport.setActiveItem(form);
},
onSaveDebtTap: function(button, e, options) {
-
var form = this.getDebtDetail(),
record = form.getRecord(),
values = form.getValues(),
@@ -105,7 +116,6 @@ Ext.define('Payback.controller.Debt', {
}
-
//calc balance for the person
person.calcBalance();
@@ -118,15 +128,24 @@ Ext.define('Payback.controller.Debt', {
},
this);
+ //refresh Debt DataView
+ //this.prevPanel.down('dataview').refresh();
+
+ //location.hash = 'Debt';
+
//set active item
- Ext.Viewport.setActiveItem(0);
+ Ext.Viewport.setActiveItem(this.prevPanel);
},
onCanelButtonTap: function(button, e, options) {
this.getDebtDetail().reset(); //reset form
+ //debugger;
+
//set active item
- Ext.Viewport.setActiveItem(0);
+ Ext.Viewport.setActiveItem(this.prevPanel);
+
+ location.hash = 'af';
},
onDataviewItemSwipe: function(dataview, index, target, record, e, options) {
@@ -140,7 +159,7 @@ Ext.define('Payback.controller.Debt', {
//shows current delete button
target.query('button')[0].show();
- //hides delete button after tapped
+ //hides delete button if anywhere else is tapped
Ext.Viewport.element.on({tap:function(){
target.query('button')[0].hide();
}, single:true});
@@ -160,7 +179,12 @@ Ext.define('Payback.controller.Debt', {
this.getMyPaymentDataView().show();
this.getEmailDebtButton().show();
+ //remember previous panel to return to
+ this.prevPanel = Ext.Viewport.getActiveItem();
+
Ext.Viewport.setActiveItem(form);
+
+ location.hash = 'Debt/'+index;
},
onEmailDebtTap: function(button, e, options) {
@@ -175,6 +199,23 @@ Ext.define('Payback.controller.Debt', {
body = encodeURIComponent("Dear "+name+",\n\nYou owe me $"+record.get('balance')+". Pay soon or my friend Li'l Abe will come pay ya a visit.\n\nSincerely,\n\nYour friendly neighborhood loan shark");
window.location.href = "mailto:"+email+"?subject=" + subject+"&body="+body;
+ },
+
+ showDebtPanel: function() {
+
+ //switch to debt panel
+ Ext.Viewport.getActiveItem().setActiveItem(1);
+ },
+
+ showDebtDetail: function(id) {
+ this.showDebtPanel();
+
+ var dataItem = this.getMyDebtDataView().getItems().getAt(0).getInnerItems()[id];
+
+ if(dataItem) {
+ this.onDataviewItemTap(null,null,null, dataItem.getRecord());
+ location.hash = 'Debt/'+id;
+ }
}
});
@@ -15,6 +15,7 @@
Ext.define('Payback.controller.Payment', {
extend: 'Ext.app.Controller',
+
config: {
stores: [
'PaymentStore'
@@ -58,6 +59,9 @@ Ext.define('Payback.controller.Payment', {
form.reset(); //clears form
form.setRecord(null); //clears record from form
+ //sets date field to today
+ form.down('datepickerfield').setValue(new Date());
+
form.setValues({debt_id:this.getDebtDetail().getRecord().get('id')});
//set active item
@@ -107,6 +111,9 @@ Ext.define('Payback.controller.Payment', {
},
this);
+ //refresh Contact DataView
+ //this.getContactDetail().down('dataview').refresh();
+
//set active item
Ext.Viewport.setActiveItem(this.getDebtDetail());
@@ -130,7 +137,7 @@ Ext.define('Payback.controller.Payment', {
//show current button
target.query('button')[0].show();
- //hide button after being tapped
+ //hides delete button if anywhere else is tapped
Ext.Viewport.element.on({tap:function(){
target.query('button')[0].hide();
}, single:true});
@@ -15,6 +15,7 @@
Ext.define('Payback.controller.Summary', {
extend: 'Ext.app.Controller',
+
config: {
models: [
'Summary'
View
@@ -16,10 +16,12 @@
Ext.define('Payback.model.Debt', {
extend: 'Ext.data.Model',
alias: 'model.Debt',
+
uses: [
'Payback.model.Payment',
'Payback.model.Person'
],
+
config: {
fields: [
{
View
@@ -15,9 +15,11 @@
Ext.define('Payback.model.Payment', {
extend: 'Ext.data.Model',
+
uses: [
'Payback.model.Debt'
],
+
config: {
fields: [
{
View
@@ -15,9 +15,11 @@
Ext.define('Payback.model.Person', {
extend: 'Ext.data.Model',
+
uses: [
'Payback.model.Debt'
],
+
config: {
proxy: {
type: 'localstorage',
@@ -53,6 +55,12 @@ Ext.define('Payback.model.Person', {
name: 'balance',
type: 'float'
}
+ ],
+ validations: [
+ {
+ type: 'email',
+ field: 'email'
+ }
]
},
View
@@ -15,6 +15,7 @@
Ext.define('Payback.model.Summary', {
extend: 'Ext.data.Model',
+
config: {
fields: [
{
View
@@ -15,6 +15,7 @@
Ext.define('Payback.store.DebtsStore', {
extend: 'Ext.data.Store',
+
requires: [
'Payback.model.Debt'
],
Oops, something went wrong.

0 comments on commit e25a6a5

Please sign in to comment.