/
Context.js
54 lines (49 loc) · 1.33 KB
/
Context.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
define([
"dojo/_base/declare",//
"./controller/StoreRegistry",
"./controller/SchemaRegistry"
], function (declare, StoreRegistry, SchemaRegistry) {
// module:
// gform/Context
return declare([], {
// summary:
// the Context is available to all GroupFactories and AttributeFactories during creation of an editor.
// It's purpose is to share editor instance specifc information.
// opener: gform/opener/Opener
// opens an editor for creation or editing
opener: null,
// storeRegistry:
// A registry for stores
storeRegistry: null,
// schemaRegistry:
// A registry for schemas
schemaRegistry: null,
constructor: function () {
this.storeRegistry = new StoreRegistry();
this.schemaRegistry = new SchemaRegistry();
},
// summary:
// get a shared store
// id: String
// the id of the store. Usually its url.
// props: Object
// the properites of the store (e.g.: idProperty and url)
getStore: function (id, props) {
return this.storeRegistry.get(id, props);
},
getBaseUrl: function(url) {
return this.storeRegistry.getBaseUrl(url);
},
getUrl: function (id) {
var actualUrl = this.getStore(id).target;
if (actualUrl) {
return actualUrl;
} else {
return id;
}
},
getSchema: function (url) {
return this.schemaRegistry.get(url);
}
});
});