-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModels.js
More file actions
79 lines (66 loc) · 1.96 KB
/
Models.js
File metadata and controls
79 lines (66 loc) · 1.96 KB
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
72
73
74
75
76
77
78
79
/**
* Base Model
*
* @author Raymond Nunez
*/
System.Models.Base = function(ModelDefaults, ModelOptions, Callback = null) {
// Reference to Base
let _this = this;
// Helpers
var _commonHelper = new System.Helpers.Common();
// Properties shared across all Models
let BaseDefaults = {
_uuid: _commonHelper.generateUUID(),
_callback: Callback != null ? Callback : null
};
// Model constructor
_this._construct = function() {
_.extend(BaseDefaults, ModelDefaults);
// Replace and/or add properties from our model options
_.extend(BaseDefaults, ModelOptions);
// Make each property in our base defaults into a property into this model
for (let prop in BaseDefaults) {
if (BaseDefaults.hasOwnProperty(prop)) {
//_this[prop] = BaseDefaults[prop];
Object.defineProperty(_this, prop, {
value: BaseDefaults[prop],
writable: true,
configurable: true,
enumerable: true
});
}
}
};
// Fire constructor
_this._construct();
// Fire callback if it is not null
if (_this._callback != null) {
_this._callback(_this);
}
Object.defineProperty(_this, '_construct', {
enumerable: false,
writable: false,
configurable: false,
});
};
System.Models.Record = function(Options, Callback = null){
//System.Models.Base.call(this);
System.Models.Base.call(
this,
{
ID: null,
Name: null,
Body: ""
},
Options,
Callback
);
};
System.Models.Record.prototype = Object.create(System.Models.Base.prototype);
System.Models.Record.prototype.constructor = System.Models.Record;
System.Models.Record.prototype.setName = (name) => {
this.Name = name;
}
System.Models.Record.prototype.getName = () => {
return this.Name;
}