extjs-mvc 0.4.0.f → 0.4.0.g
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/extjs-mvc +0 -3
- data/lib/extjs-mvc.rb +10 -6
- data/lib/extjs-mvc/api.rb +0 -1
- metadata +8 -84
- data/lib/src/App.js +0 -219
- data/lib/src/MVC.js +0 -260
- data/lib/src/Presenter.js +0 -52
- data/lib/src/README.rdoc +0 -69
- data/lib/src/controller/Controller.js +0 -278
- data/lib/src/controller/CrudController.js +0 -460
- data/lib/src/lib/Array.js +0 -26
- data/lib/src/lib/Booter.js +0 -416
- data/lib/src/lib/ClassManager.js +0 -191
- data/lib/src/lib/ControllerClassManager.js +0 -95
- data/lib/src/lib/Dependencies.js +0 -44
- data/lib/src/lib/DispatchMatcher.js +0 -98
- data/lib/src/lib/Dispatcher.js +0 -129
- data/lib/src/lib/Environment.js +0 -43
- data/lib/src/lib/Inflector.js +0 -155
- data/lib/src/lib/ModelClassManager.js +0 -19
- data/lib/src/lib/Route.js +0 -139
- data/lib/src/lib/Router.js +0 -282
- data/lib/src/lib/String.js +0 -94
- data/lib/src/lib/ViewClassManager.js +0 -229
- data/lib/src/lib/notes.txt +0 -32
- data/lib/src/model/AdapterManager.js +0 -30
- data/lib/src/model/Association.js +0 -26
- data/lib/src/model/Base.js +0 -63
- data/lib/src/model/BelongsToAssociation.js +0 -116
- data/lib/src/model/Cache.js +0 -131
- data/lib/src/model/HasManyAssociation.js +0 -160
- data/lib/src/model/Model.js +0 -331
- data/lib/src/model/UrlBuilder.js +0 -106
- data/lib/src/model/adapters/AbstractAdapter.js +0 -296
- data/lib/src/model/adapters/MemoryAdapter.js +0 -103
- data/lib/src/model/adapters/RESTAdapter.js +0 -345
- data/lib/src/model/adapters/RESTJSONAdapter.js +0 -68
- data/lib/src/model/adapters/notes.txt +0 -42
- data/lib/src/model/associations/Association.js +0 -192
- data/lib/src/model/associations/notes.txt +0 -87
- data/lib/src/model/validations/Errors.js +0 -136
- data/lib/src/model/validations/Plugin.js +0 -139
- data/lib/src/model/validations/Validations.js +0 -276
- data/lib/src/notes/Charts.graffle +0 -0
- data/lib/src/overrides/Ext.Component.js +0 -21
- data/lib/src/overrides/Ext.extend.js +0 -142
- data/lib/src/spec/Array.spec.js +0 -15
- data/lib/src/spec/ExtMVC.spec.js +0 -65
- data/lib/src/spec/Model.spec.js +0 -370
- data/lib/src/spec/OS.spec.js +0 -83
- data/lib/src/spec/Router.spec.js +0 -99
- data/lib/src/spec/SpecHelper.js +0 -106
- data/lib/src/spec/String.spec.js +0 -83
- data/lib/src/spec/model/AbstractAdapter.spec.js +0 -49
- data/lib/src/spec/model/Associations.spec.js +0 -99
- data/lib/src/spec/model/Cache.spec.js +0 -5
- data/lib/src/spec/model/RESTAdapter.spec.js +0 -19
- data/lib/src/spec/model/ValidationErrors.spec.js +0 -64
- data/lib/src/spec/model/Validations.spec.js +0 -166
- data/lib/src/spec/model/ValidationsPlugin.spec.js +0 -108
- data/lib/src/spec/suite.html +0 -60
- data/lib/src/specs-old/JSSpec.css +0 -216
- data/lib/src/specs-old/JSSpec.js +0 -1512
- data/lib/src/specs-old/all.html +0 -66
- data/lib/src/specs-old/base.js +0 -14
- data/lib/src/specs-old/controller.js +0 -17
- data/lib/src/specs-old/diff_match_patch.js +0 -1
- data/lib/src/specs-old/model.js +0 -70
- data/lib/src/specs-old/route.js +0 -38
- data/lib/src/specs-old/router.js +0 -59
- data/lib/src/specs-old/string.js +0 -22
- data/lib/src/testrunner/JSpecFormatter.js +0 -111
- data/lib/src/testrunner/TestClient.js +0 -181
- data/lib/src/testrunner/TestGrid.js +0 -351
- data/lib/src/testrunner/TestRunner.js +0 -110
- data/lib/src/testrunner/TestViewport.js +0 -94
- data/lib/src/vendor.yml +0 -29
- data/lib/src/vendor/ext-3.1.1/vendor.yml +0 -16
- data/lib/src/view/FormWindow.js +0 -184
- data/lib/src/view/HasManyEditorGridPanel.js +0 -211
- data/lib/src/view/scaffold/Edit.js +0 -46
- data/lib/src/view/scaffold/Index.js +0 -561
- data/lib/src/view/scaffold/New.js +0 -20
- data/lib/src/view/scaffold/ScaffoldFormPanel.js +0 -255
data/Rakefile
CHANGED
@@ -10,8 +10,8 @@ begin
|
|
10
10
|
gem.email = "christocracy@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/christocracy/extjs-mvc"
|
12
12
|
gem.authors = ["Ed Spencer and Chris Scott"]
|
13
|
-
gem.add_dependency "xmvc"
|
14
|
-
gem.add_dependency "extjs"
|
13
|
+
gem.add_dependency "xmvc", ">=0.1.6"
|
14
|
+
gem.add_dependency "extjs", ">=0.1.1"
|
15
15
|
gem.add_dependency "git"
|
16
16
|
gem.add_dependency "thor", ">=0.13.4"
|
17
17
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.0.
|
1
|
+
0.4.0.g
|
data/bin/extjs-mvc
CHANGED
data/lib/extjs-mvc.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
require 'git'
|
2
2
|
require 'thor'
|
3
|
+
|
4
|
+
require 'xmvc'
|
5
|
+
require 'xmvc/cli'
|
6
|
+
require 'extjs'
|
3
7
|
require 'extjs-mvc/api'
|
4
8
|
|
5
9
|
##
|
@@ -8,15 +12,15 @@ require 'extjs-mvc/api'
|
|
8
12
|
module ExtJS
|
9
13
|
module MVC
|
10
14
|
|
11
|
-
VERSION
|
15
|
+
VERSION = "0.4.0.a"
|
12
16
|
|
13
|
-
ROOT
|
17
|
+
ROOT = File.dirname(__FILE__)
|
14
18
|
|
15
|
-
VENDOR_NAME
|
19
|
+
VENDOR_NAME = 'extjs-mvc'
|
16
20
|
|
17
|
-
CONFIG_PATH
|
21
|
+
CONFIG_PATH = File.join(ROOT, "vendor.yml")
|
18
22
|
|
19
|
-
GIT_URL
|
23
|
+
GIT_URL = 'http://github.com/christocracy/extjs-mvc-src.git'
|
20
24
|
|
21
25
|
autoload :API, 'extjs-mvc/api'
|
22
26
|
|
@@ -26,4 +30,4 @@ module ExtJS
|
|
26
30
|
end
|
27
31
|
end
|
28
32
|
end
|
29
|
-
end
|
33
|
+
end
|
data/lib/extjs-mvc/api.rb
CHANGED
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 0
|
7
7
|
- 4
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.4.0.
|
9
|
+
- g
|
10
|
+
version: 0.4.0.g
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ed Spencer and Chris Scott
|
@@ -27,7 +27,9 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 0
|
30
|
-
|
30
|
+
- 1
|
31
|
+
- 6
|
32
|
+
version: 0.1.6
|
31
33
|
type: :runtime
|
32
34
|
version_requirements: *id001
|
33
35
|
- !ruby/object:Gem::Dependency
|
@@ -39,7 +41,9 @@ dependencies:
|
|
39
41
|
- !ruby/object:Gem::Version
|
40
42
|
segments:
|
41
43
|
- 0
|
42
|
-
|
44
|
+
- 1
|
45
|
+
- 1
|
46
|
+
version: 0.1.1
|
43
47
|
type: :runtime
|
44
48
|
version_requirements: *id002
|
45
49
|
- !ruby/object:Gem::Dependency
|
@@ -97,86 +101,6 @@ files:
|
|
97
101
|
- bin/extjs-mvc
|
98
102
|
- lib/extjs-mvc.rb
|
99
103
|
- lib/extjs-mvc/api.rb
|
100
|
-
- lib/src/App.js
|
101
|
-
- lib/src/MVC.js
|
102
|
-
- lib/src/Presenter.js
|
103
|
-
- lib/src/README.rdoc
|
104
|
-
- lib/src/controller/Controller.js
|
105
|
-
- lib/src/controller/CrudController.js
|
106
|
-
- lib/src/lib/Array.js
|
107
|
-
- lib/src/lib/Booter.js
|
108
|
-
- lib/src/lib/ClassManager.js
|
109
|
-
- lib/src/lib/ControllerClassManager.js
|
110
|
-
- lib/src/lib/Dependencies.js
|
111
|
-
- lib/src/lib/DispatchMatcher.js
|
112
|
-
- lib/src/lib/Dispatcher.js
|
113
|
-
- lib/src/lib/Environment.js
|
114
|
-
- lib/src/lib/Inflector.js
|
115
|
-
- lib/src/lib/ModelClassManager.js
|
116
|
-
- lib/src/lib/Route.js
|
117
|
-
- lib/src/lib/Router.js
|
118
|
-
- lib/src/lib/String.js
|
119
|
-
- lib/src/lib/ViewClassManager.js
|
120
|
-
- lib/src/lib/notes.txt
|
121
|
-
- lib/src/model/AdapterManager.js
|
122
|
-
- lib/src/model/Association.js
|
123
|
-
- lib/src/model/Base.js
|
124
|
-
- lib/src/model/BelongsToAssociation.js
|
125
|
-
- lib/src/model/Cache.js
|
126
|
-
- lib/src/model/HasManyAssociation.js
|
127
|
-
- lib/src/model/Model.js
|
128
|
-
- lib/src/model/UrlBuilder.js
|
129
|
-
- lib/src/model/adapters/AbstractAdapter.js
|
130
|
-
- lib/src/model/adapters/MemoryAdapter.js
|
131
|
-
- lib/src/model/adapters/RESTAdapter.js
|
132
|
-
- lib/src/model/adapters/RESTJSONAdapter.js
|
133
|
-
- lib/src/model/adapters/notes.txt
|
134
|
-
- lib/src/model/associations/Association.js
|
135
|
-
- lib/src/model/associations/notes.txt
|
136
|
-
- lib/src/model/validations/Errors.js
|
137
|
-
- lib/src/model/validations/Plugin.js
|
138
|
-
- lib/src/model/validations/Validations.js
|
139
|
-
- lib/src/notes/Charts.graffle
|
140
|
-
- lib/src/overrides/Ext.Component.js
|
141
|
-
- lib/src/overrides/Ext.extend.js
|
142
|
-
- lib/src/spec/Array.spec.js
|
143
|
-
- lib/src/spec/ExtMVC.spec.js
|
144
|
-
- lib/src/spec/Model.spec.js
|
145
|
-
- lib/src/spec/OS.spec.js
|
146
|
-
- lib/src/spec/Router.spec.js
|
147
|
-
- lib/src/spec/SpecHelper.js
|
148
|
-
- lib/src/spec/String.spec.js
|
149
|
-
- lib/src/spec/model/AbstractAdapter.spec.js
|
150
|
-
- lib/src/spec/model/Associations.spec.js
|
151
|
-
- lib/src/spec/model/Cache.spec.js
|
152
|
-
- lib/src/spec/model/RESTAdapter.spec.js
|
153
|
-
- lib/src/spec/model/ValidationErrors.spec.js
|
154
|
-
- lib/src/spec/model/Validations.spec.js
|
155
|
-
- lib/src/spec/model/ValidationsPlugin.spec.js
|
156
|
-
- lib/src/spec/suite.html
|
157
|
-
- lib/src/specs-old/JSSpec.css
|
158
|
-
- lib/src/specs-old/JSSpec.js
|
159
|
-
- lib/src/specs-old/all.html
|
160
|
-
- lib/src/specs-old/base.js
|
161
|
-
- lib/src/specs-old/controller.js
|
162
|
-
- lib/src/specs-old/diff_match_patch.js
|
163
|
-
- lib/src/specs-old/model.js
|
164
|
-
- lib/src/specs-old/route.js
|
165
|
-
- lib/src/specs-old/router.js
|
166
|
-
- lib/src/specs-old/string.js
|
167
|
-
- lib/src/testrunner/JSpecFormatter.js
|
168
|
-
- lib/src/testrunner/TestClient.js
|
169
|
-
- lib/src/testrunner/TestGrid.js
|
170
|
-
- lib/src/testrunner/TestRunner.js
|
171
|
-
- lib/src/testrunner/TestViewport.js
|
172
|
-
- lib/src/vendor.yml
|
173
|
-
- lib/src/vendor/ext-3.1.1/vendor.yml
|
174
|
-
- lib/src/view/FormWindow.js
|
175
|
-
- lib/src/view/HasManyEditorGridPanel.js
|
176
|
-
- lib/src/view/scaffold/Edit.js
|
177
|
-
- lib/src/view/scaffold/Index.js
|
178
|
-
- lib/src/view/scaffold/New.js
|
179
|
-
- lib/src/view/scaffold/ScaffoldFormPanel.js
|
180
104
|
- lib/vendor.yml
|
181
105
|
- test/helper.rb
|
182
106
|
- test/test_extjs-mvc-gem.rb
|
data/lib/src/App.js
DELETED
@@ -1,219 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @class ExtMVC.App
|
3
|
-
* @extends Ext.util.Observable
|
4
|
-
* @cfg {Boolean} usesHistory True to automatically create required DOM elements for Ext.History,
|
5
|
-
* sets up a listener on Ext.History's change event to fire this.onHistoryChange. False by default
|
6
|
-
*/
|
7
|
-
ExtMVC.App = Ext.extend(Ext.util.Observable, {
|
8
|
-
/**
|
9
|
-
* @constructor
|
10
|
-
* Sets up the Application - adds events, sets up namespaces, optionally sets up history.
|
11
|
-
* Fires the 'before-launch' event before initializing router, viewport and history.
|
12
|
-
* Calls this.launch() once everything else is set up (override the 'launch' method to provide your own logic).
|
13
|
-
* Fires the 'launched' event after calling this.launch()
|
14
|
-
*/
|
15
|
-
constructor: function(config) {
|
16
|
-
ExtMVC.App.superclass.constructor.apply(this, arguments);
|
17
|
-
|
18
|
-
//apply configuration object and set up namespaces
|
19
|
-
Ext.apply(this, config || {});
|
20
|
-
window[this.name] = this;
|
21
|
-
|
22
|
-
this.initializeNamespaces();
|
23
|
-
|
24
|
-
// Ext.onReady(this.onReady, this);
|
25
|
-
|
26
|
-
this.on('launched', function() {
|
27
|
-
/**
|
28
|
-
* TODO: This used to reside in initializeHistory but this.launch() needs to be
|
29
|
-
* called before this dispatches so it is temporarily here... ugly though
|
30
|
-
*/
|
31
|
-
if (this.usesHistory) {
|
32
|
-
if (this.dispatchHistoryOnLoad === true) {
|
33
|
-
Ext.History.init(function(history) {
|
34
|
-
var hash = document.location.hash.replace("#", "");
|
35
|
-
var params = this.router.recognise(hash);
|
36
|
-
|
37
|
-
if (params) {this.dispatch(params);}
|
38
|
-
}, this);
|
39
|
-
} else {
|
40
|
-
Ext.History.init();
|
41
|
-
}
|
42
|
-
}
|
43
|
-
}, this);
|
44
|
-
},
|
45
|
-
|
46
|
-
/**
|
47
|
-
* @private
|
48
|
-
* Called when Ext.onReady fires
|
49
|
-
*/
|
50
|
-
onReady: function() {
|
51
|
-
if (this.fireEvent('before-launch', this)) {
|
52
|
-
this.initializeRouter();
|
53
|
-
// this.initializeViewport();
|
54
|
-
this.initializeEvents();
|
55
|
-
|
56
|
-
if (this.usesHistory === true) this.initializeHistory();
|
57
|
-
|
58
|
-
this.launch();
|
59
|
-
}
|
60
|
-
},
|
61
|
-
|
62
|
-
/**
|
63
|
-
* @property name
|
64
|
-
* @type String
|
65
|
-
* The application's name. This is used when creating namespaces for models, views and controllers,
|
66
|
-
* and automatically set up as a global variable reference to this application. Read only.
|
67
|
-
*/
|
68
|
-
name: 'MyApp',
|
69
|
-
|
70
|
-
/**
|
71
|
-
* @property usesHistory
|
72
|
-
* @type Boolean
|
73
|
-
* True to automatically create required DOM elements for Ext.History,
|
74
|
-
* sets up a listener on Ext.History's change event to fire this.onHistoryChange.
|
75
|
-
* False by default
|
76
|
-
*/
|
77
|
-
usesHistory: false,
|
78
|
-
|
79
|
-
/**
|
80
|
-
* @prop dispatchHistoryOnLoad
|
81
|
-
* @type Boolean
|
82
|
-
* If usesHistory is true and dispatchHistoryOnLoad is also true, the OS will attempt to match
|
83
|
-
* any string currently after the # in the url and dispatch to it
|
84
|
-
*/
|
85
|
-
dispatchHistoryOnLoad: true,
|
86
|
-
|
87
|
-
/**
|
88
|
-
* Called when the application is booted up. Override this to provide your own startup logic (defaults to Ext.emptyFn)
|
89
|
-
*/
|
90
|
-
launch: function() {
|
91
|
-
this.fireEvent('launched', this);
|
92
|
-
},
|
93
|
-
|
94
|
-
/**
|
95
|
-
* @property params
|
96
|
-
* @type Object
|
97
|
-
* An object containing the most current parameters (usually decoded from a url using this.router)
|
98
|
-
* e.g. {controller: 'index', action: 'welcome', id: 10}
|
99
|
-
*/
|
100
|
-
params: {},
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Dispatches a request to a registered controller.
|
104
|
-
* @param {Object} dispatchConfig A config object which should look something like this:
|
105
|
-
* {controller: 'MyController', action: 'index'}, where 'MyController' is the key for a controller
|
106
|
-
* which has been registered to the controller. If action is not specified, it defaults to 'index'
|
107
|
-
* @param {Object} scope The scope in which to fire the event (defaults to the controller)
|
108
|
-
* @param {Array} args An array of arguments which are passed to the controller action.
|
109
|
-
*/
|
110
|
-
dispatch: function dispatch(dispatchConfig, scope, args) {
|
111
|
-
var dispatchConfig = dispatchConfig || {};
|
112
|
-
Ext.applyIf(dispatchConfig, {
|
113
|
-
action: 'index'
|
114
|
-
});
|
115
|
-
|
116
|
-
this.params = dispatchConfig;
|
117
|
-
|
118
|
-
var c = ExtMVC.getController(dispatchConfig.controller);
|
119
|
-
if (c != undefined) {
|
120
|
-
var action = c[dispatchConfig.action];
|
121
|
-
|
122
|
-
if (typeof action == "function") action.apply(scope || c, args || []);
|
123
|
-
else throw new Error(String.format("Action '{0}' not found on Controller '{1}'", dispatchConfig.action, dispatchConfig.controller));
|
124
|
-
}
|
125
|
-
},
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Sets up a Router instance. This is called automatically before onLaunch()
|
129
|
-
* Add routes using this.router.connect
|
130
|
-
*/
|
131
|
-
initializeRouter: function() {
|
132
|
-
if (this.router == undefined) {
|
133
|
-
this.router = new ExtMVC.router.Router();
|
134
|
-
ExtMVC.router.Router.defineRoutes(this.router);
|
135
|
-
}
|
136
|
-
},
|
137
|
-
|
138
|
-
/**
|
139
|
-
* Uses Ext.namespace to create packages view controllers, models and views
|
140
|
-
* E.g. if name = 'Blog' or this.name = 'Blog', this is the same as:
|
141
|
-
* Ext.ns('Blog', 'Blog.controllers', 'Blog.models', 'Blog.views')
|
142
|
-
*/
|
143
|
-
initializeNamespaces: function initializeNamespaces(name) {
|
144
|
-
var name = name || this.name;
|
145
|
-
if (name) {
|
146
|
-
Ext.ns(name, name + '.controllers', name + '.models', name + '.views');
|
147
|
-
};
|
148
|
-
},
|
149
|
-
|
150
|
-
/**
|
151
|
-
* Creates the necessary DOM elements required for Ext.History to manage state
|
152
|
-
* Sets up listeners on Ext.History's change event to fire the dispatch() action in the normal way.
|
153
|
-
* This is not called automatically as not all applications will need it
|
154
|
-
*/
|
155
|
-
initializeHistory: function initializeHistory() {
|
156
|
-
this.historyForm = Ext.getBody().createChild({
|
157
|
-
tag: 'form',
|
158
|
-
action: '#',
|
159
|
-
cls: 'x-hidden',
|
160
|
-
id: 'history-form',
|
161
|
-
children: [
|
162
|
-
{
|
163
|
-
tag: 'div',
|
164
|
-
children: [
|
165
|
-
{
|
166
|
-
tag: 'input',
|
167
|
-
id: 'x-history-field',
|
168
|
-
type: 'hidden'
|
169
|
-
},
|
170
|
-
{
|
171
|
-
tag: 'iframe',
|
172
|
-
id: 'x-history-frame'
|
173
|
-
}
|
174
|
-
]
|
175
|
-
}
|
176
|
-
]
|
177
|
-
});
|
178
|
-
|
179
|
-
Ext.History.on('change', this.onHistoryChange, this);
|
180
|
-
},
|
181
|
-
|
182
|
-
/**
|
183
|
-
* Takes a history token (anything after the # in the url), consults the router and dispatches
|
184
|
-
* to the appropriate controller and action if a match was found
|
185
|
-
* @param {String} token The url token (e.g. the token would be cont/act/id for a url like mydomain.com/#cont/act/id)
|
186
|
-
*/
|
187
|
-
onHistoryChange: function onHistoryChange(token) {
|
188
|
-
var match = this.router.recognise(token);
|
189
|
-
|
190
|
-
if (match) {
|
191
|
-
this.dispatch(match, null, [{url: token}]);
|
192
|
-
};
|
193
|
-
},
|
194
|
-
|
195
|
-
/**
|
196
|
-
* Sets up events emitted by the Application
|
197
|
-
*/
|
198
|
-
initializeEvents: function initializeEvents() {
|
199
|
-
this.addEvents(
|
200
|
-
/**
|
201
|
-
* @event before-launch
|
202
|
-
* Fires before this application launches
|
203
|
-
* @param {ExtMVC.App} this The application about to be launched
|
204
|
-
*/
|
205
|
-
'before-launch',
|
206
|
-
|
207
|
-
/**
|
208
|
-
* @event launched
|
209
|
-
* Fires once the application has been launched
|
210
|
-
* @param {ExtMVC.App} this The application which has been launched
|
211
|
-
*/
|
212
|
-
'launched'
|
213
|
-
);
|
214
|
-
}
|
215
|
-
});
|
216
|
-
|
217
|
-
ExtMVC.App.define = function(config) {
|
218
|
-
ExtMVC.app = new ExtMVC.App(config);
|
219
|
-
};
|
data/lib/src/MVC.js
DELETED
@@ -1,260 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @class ExtMVC
|
3
|
-
* ExtMVC
|
4
|
-
* @singleton
|
5
|
-
*/
|
6
|
-
ExtMVC = Ext.extend(Ext.util.Observable, {
|
7
|
-
version: "0.7a",
|
8
|
-
|
9
|
-
constructor: function() {
|
10
|
-
ExtMVC.superclass.constructor.apply(this, arguments);
|
11
|
-
|
12
|
-
/**
|
13
|
-
* @property dispatcher
|
14
|
-
* @type Ext.lib.Dispatcher
|
15
|
-
* The dispatcher object which finds the right controller and action when ExtMVC.dispatch is called
|
16
|
-
*/
|
17
|
-
// this.dispatcher = new Ext.lib.Dispatcher({
|
18
|
-
//
|
19
|
-
// });
|
20
|
-
},
|
21
|
-
|
22
|
-
dispatch: function() {
|
23
|
-
var dispatcher = this.dispatcher;
|
24
|
-
|
25
|
-
return dispatcher.dispatch.apply(dispatcher, arguments);
|
26
|
-
},
|
27
|
-
|
28
|
-
/**
|
29
|
-
* Sets the Ext.Application instance currently in use. This is currently required :/
|
30
|
-
* @param {Ext.Application} app The application currently in use
|
31
|
-
*/
|
32
|
-
setApplication: function(app) {
|
33
|
-
this.app = app;
|
34
|
-
this.name = app.name;
|
35
|
-
|
36
|
-
ExtMVC.model.modelNamespace = window[app.name].models;
|
37
|
-
},
|
38
|
-
|
39
|
-
fields: {
|
40
|
-
|
41
|
-
},
|
42
|
-
|
43
|
-
registerFields: function(name, fields) {
|
44
|
-
this.fields[name] = fields;
|
45
|
-
},
|
46
|
-
|
47
|
-
getFields: function(name) {
|
48
|
-
return this.fields[name];
|
49
|
-
},
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
/**
|
54
|
-
* Registers a model class with Ext MVC
|
55
|
-
* @param {String} name The name to give this model
|
56
|
-
* @param {Object} config Model definition configuration
|
57
|
-
*/
|
58
|
-
registerModel: function(name, config) {
|
59
|
-
this.registerClass('model', arguments);
|
60
|
-
},
|
61
|
-
|
62
|
-
/**
|
63
|
-
* Registers a controller class with Ext MVC
|
64
|
-
* @param {String} name The name to give this controller
|
65
|
-
* @param {Object} config Controller definition configuration
|
66
|
-
*/
|
67
|
-
registerController: function(name, config) {
|
68
|
-
this.registerClass('controller', arguments);
|
69
|
-
},
|
70
|
-
|
71
|
-
/**
|
72
|
-
* Registers a view class with Ext MVC.
|
73
|
-
* @param {String} namesapce The namespace to add this view to
|
74
|
-
* @param {String} name The name to give this view
|
75
|
-
* @param {Object} config View definition configuration
|
76
|
-
*/
|
77
|
-
registerView: function(namespace, name, config) {
|
78
|
-
this.registerClass('view', arguments);
|
79
|
-
},
|
80
|
-
|
81
|
-
/**
|
82
|
-
* Abstraction for registering views, models and controllers
|
83
|
-
* @param {String} managerName The name of the class manager to register with
|
84
|
-
* @param {Array} args The args to pass to the manager's register method
|
85
|
-
*/
|
86
|
-
registerClass: function(managerName, args) {
|
87
|
-
var manager = this.getClassManager(managerName);
|
88
|
-
|
89
|
-
manager.register.apply(manager, args);
|
90
|
-
},
|
91
|
-
|
92
|
-
/**
|
93
|
-
* @property classManagers
|
94
|
-
* @type Object
|
95
|
-
* {name: classManager} mappings used by this.getClassManager and this.registerClassManager
|
96
|
-
*/
|
97
|
-
classManagers: {},
|
98
|
-
|
99
|
-
/**
|
100
|
-
* @private
|
101
|
-
* Sets up model, view and controller class managers
|
102
|
-
*/
|
103
|
-
initializeClassManagers: function() {
|
104
|
-
this.registerClassManager('model', new ExtMVC.lib.ModelClassManager());
|
105
|
-
this.registerClassManager('view', new ExtMVC.lib.ViewClassManager());
|
106
|
-
this.registerClassManager('controller', new ExtMVC.lib.ControllerClassManager());
|
107
|
-
},
|
108
|
-
|
109
|
-
/**
|
110
|
-
* Returns the class manager for the given name
|
111
|
-
* @param {String} name The name of the manager (model, view or controller)
|
112
|
-
* @return {ExtMVC.lib.ClassManager} The class manager instance
|
113
|
-
*/
|
114
|
-
getClassManager: function(name) {
|
115
|
-
return this.classManagers[name];
|
116
|
-
},
|
117
|
-
|
118
|
-
/**
|
119
|
-
* Registers a class manager instance under a given name
|
120
|
-
* @param {String} name The name of the class manager
|
121
|
-
* @param {ExtMVC.lib.ClassManager} manager The ClassManager instance to register
|
122
|
-
*/
|
123
|
-
registerClassManager: function(name, manager) {
|
124
|
-
this.classManagers[name] = manager;
|
125
|
-
},
|
126
|
-
|
127
|
-
/**
|
128
|
-
* Returns the canonical controller instance for the given controller name
|
129
|
-
* @return {ExtMVC.Controller} The controller instance
|
130
|
-
*/
|
131
|
-
getController: function(name) {
|
132
|
-
return this.getClassManager('controller').getInstance(name);
|
133
|
-
},
|
134
|
-
|
135
|
-
/**
|
136
|
-
* Returns the constructor for a given model name
|
137
|
-
* @param {String} name The name of the model
|
138
|
-
* @return {Function} The model constructor
|
139
|
-
*/
|
140
|
-
getModel: function(name) {
|
141
|
-
return this.getClassManager('model').getConstructor(name);
|
142
|
-
},
|
143
|
-
|
144
|
-
/**
|
145
|
-
* Instantiates a model of the given name with the data supplied
|
146
|
-
* @param {String} modelName The name of the model to instantiate
|
147
|
-
* @param {Object} data Data object to instantiate the instance with
|
148
|
-
* @return {ExtMVC.Model} The new model instance
|
149
|
-
*/
|
150
|
-
buildModel: function(modelName, data) {
|
151
|
-
return new (this.getModel(modelName))(data);
|
152
|
-
},
|
153
|
-
|
154
|
-
/**
|
155
|
-
* Returns the constructor for a given view namespace/name combination
|
156
|
-
* @param {String} namespace The view namespace to look in
|
157
|
-
* @param {String} name The name of the view within the view namespace
|
158
|
-
* @return {Function} The view constructor
|
159
|
-
*/
|
160
|
-
getView: function getView(namespace, name) {
|
161
|
-
return this.getClassManager('view').getConstructor(namespace, name);
|
162
|
-
},
|
163
|
-
|
164
|
-
/**
|
165
|
-
* Returns a new view instance for the given namespace/name combo, using the supplied config
|
166
|
-
* @param {String} namespace The namespace to find the view from
|
167
|
-
* @param {String} name The view name
|
168
|
-
* @param {Object} config Optional config object
|
169
|
-
* @return {Ext.Component} The new view instance
|
170
|
-
*/
|
171
|
-
buildView: function buildView(namespace, name, config) {
|
172
|
-
var constructor = this.getView(namespace, name);
|
173
|
-
|
174
|
-
return new (constructor)(config);
|
175
|
-
},
|
176
|
-
|
177
|
-
/**
|
178
|
-
* Loads packaged classes from a given url, calling a callback when they have been registered. Sample return:
|
179
|
-
<pre>
|
180
|
-
{
|
181
|
-
controllers: [
|
182
|
-
{
|
183
|
-
name: 'comments',
|
184
|
-
superclass: 'crud',
|
185
|
-
config: {
|
186
|
-
index: function() {
|
187
|
-
this.render('index', {
|
188
|
-
title: "Loaded on demand!"
|
189
|
-
});
|
190
|
-
}
|
191
|
-
}
|
192
|
-
}
|
193
|
-
],
|
194
|
-
views: [
|
195
|
-
{
|
196
|
-
name: 'new',
|
197
|
-
namespace: 'comments',
|
198
|
-
config: {
|
199
|
-
xtype: 'scaffoldnew',
|
200
|
-
title: "New Comment"
|
201
|
-
}
|
202
|
-
}
|
203
|
-
],
|
204
|
-
models: [
|
205
|
-
{
|
206
|
-
name : 'Comment',
|
207
|
-
config: {
|
208
|
-
fields: [
|
209
|
-
{name: 'id', type: 'int'},
|
210
|
-
{name: 'title', type: 'string'},
|
211
|
-
{name: 'message', type: 'string'}
|
212
|
-
]
|
213
|
-
}
|
214
|
-
}
|
215
|
-
]
|
216
|
-
}
|
217
|
-
</pre>
|
218
|
-
* @param {String} url The url to retrieve the package from
|
219
|
-
* @param {Function} callback Optional callback function, called after the package has been read and registered
|
220
|
-
* @param {Object} scope The scope to execute the callback function in
|
221
|
-
*/
|
222
|
-
loadOnDemand: function(url, callback, scope) {
|
223
|
-
Ext.Ajax.request({
|
224
|
-
url : url,
|
225
|
-
scope : scope || this,
|
226
|
-
success: function(response) {
|
227
|
-
var pkg = Ext.decode(response.responseText);
|
228
|
-
|
229
|
-
Ext.each(pkg.controllers || [], function(config) {
|
230
|
-
this.registerController(config.name, config);
|
231
|
-
}, this);
|
232
|
-
|
233
|
-
Ext.each(pkg.models || [], function(config) {
|
234
|
-
this.registerModel(config.name, config);
|
235
|
-
}, this);
|
236
|
-
|
237
|
-
Ext.each(pkg.views || [], function(config) {
|
238
|
-
this.registerView(config.namespace, config.name, config);
|
239
|
-
}, this);
|
240
|
-
|
241
|
-
if (Ext.isFunction(callback)) callback.call(scope, pkg);
|
242
|
-
}
|
243
|
-
});
|
244
|
-
}
|
245
|
-
});
|
246
|
-
|
247
|
-
ExtMVC = new ExtMVC();
|
248
|
-
|
249
|
-
// ExtMVC.initializeClassManagers();
|
250
|
-
|
251
|
-
Ext.onReady(function() {
|
252
|
-
/**
|
253
|
-
* @property dispatcher
|
254
|
-
* @type Ext.lib.Dispatcher
|
255
|
-
* The dispatcher object which finds the right controller and action when ExtMVC.dispatch is called
|
256
|
-
*/
|
257
|
-
ExtMVC.dispatcher = new ExtMVC.lib.Dispatcher();
|
258
|
-
});
|
259
|
-
|
260
|
-
Ext.ns('ExtMVC.router', 'ExtMVC.plugin', 'ExtMVC.controller', 'ExtMVC.view', 'ExtMVC.view.scaffold', 'ExtMVC.lib', 'ExtMVC.test');
|