annotate src/implab/data/_ModelBase.js @ 14:5fd2a35d65c0

Слияние
author cin
date Fri, 08 Sep 2017 13:45:10 +0300
parents fc2517695ee1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
1 define(["dojo/_base/declare"], function(declare) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
2
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
3 return declare(null, {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
4 dataContext : null,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
5 idField : "id",
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
6 loaded : false,
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
7
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
8 constructor : function(opts){
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
9 if (opts) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
10 if(opts.dataContext)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
11 this.dataContext = opts.dataContext;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
12 if(opts.id)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
13 this[this.idField] = opts.id;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
14 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
15 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
16
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
17 getId : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
18 return this[this.idField];
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
19 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
20
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
21 attach : function(id, dc) {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
22 if (this.dataContext)
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
23 throw new Error("The object is already attached");
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
24 this[this.idField] = id;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
25 this.dataContext = dc;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
26 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
27
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
28 isAttached : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
29 return this.dataContext ? true : false;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
30 },
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
31
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
32 onPopulate : function() {
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
33 this.loaded = true;
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
34 }
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
35
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
36 });
fc2517695ee1 Initial commit, draft import of existing work
cin
parents:
diff changeset
37 });