/
Person.js
executable file
·71 lines (66 loc) · 1.66 KB
/
Person.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* File: app/model/Person.js
*
* This file was generated by Sencha Architect version 2.0.0.
* http://www.sencha.com/products/architect/
*
* This file requires use of the Sencha Touch 2.0.x library, under independent license.
* License of Sencha Architect does not include license for Sencha Touch 2.0.x. For more
* details see http://www.sencha.com/license or contact license@sencha.com.
*
* This file will be auto-generated each and everytime you save your project.
*
* Do NOT hand edit this file.
*/
Ext.define('Payback.model.Person', {
extend: 'Ext.data.Model',
uses: [
'Payback.model.Debt'
],
config: {
proxy: {
type: 'localstorage',
id: 'Person'
},
hasMany: {
associationKey: 'person_id',
model: 'Payback.model.Debt',
autoLoad: true,
foreignKey: 'person_id',
name: 'debts',
store: {
remoteFilter: false,
modelDefaults: null
}
},
fields: [
{
name: 'id',
type: 'auto'
},
{
name: 'name'
},
{
name: 'phone'
},
{
name: 'email'
},
{
defaultValue: 0,
name: 'balance',
type: 'float'
}
],
validations: [
{
type: 'email',
field: 'email'
}
]
},
calcBalance: function() {
return this.set('balance', this.debts().sum('balance'));
}
});