comparison src/implab/data/_ModelBase.js @ 0:fc2517695ee1

Initial commit, draft import of existing work
author cin
date Thu, 01 Jun 2017 13:20:03 +0300
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fc2517695ee1
1 define(["dojo/_base/declare"], function(declare) {
2
3 return declare(null, {
4 dataContext : null,
5 idField : "id",
6 loaded : false,
7
8 constructor : function(opts){
9 if (opts) {
10 if(opts.dataContext)
11 this.dataContext = opts.dataContext;
12 if(opts.id)
13 this[this.idField] = opts.id;
14 }
15 },
16
17 getId : function() {
18 return this[this.idField];
19 },
20
21 attach : function(id, dc) {
22 if (this.dataContext)
23 throw new Error("The object is already attached");
24 this[this.idField] = id;
25 this.dataContext = dc;
26 },
27
28 isAttached : function() {
29 return this.dataContext ? true : false;
30 },
31
32 onPopulate : function() {
33 this.loaded = true;
34 }
35
36 });
37 });