ember-source 3.28.5 → 4.0.0-beta.10
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.
- package/CHANGELOG.md +113 -10
- package/blueprints/acceptance-test/qunit-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/acceptance-test/qunit-rfc-232-files/tests/acceptance/__name__-test.js +1 -1
- package/blueprints/component-test/qunit-files/__root__/__testType__/__path__/__test__.js +3 -3
- package/blueprints/helper-test/index.js +4 -22
- package/blueprints/helper-test/mocha-0.12-files/__root__/__testType__/__collection__/__name__-test.js +1 -13
- package/blueprints/helper-test/mocha-files/__root__/__testType__/__collection__/__name__-test.js +0 -13
- package/blueprints/helper-test/mocha-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -12
- package/blueprints/helper-test/qunit-files/__root__/__testType__/__collection__/__name__-test.js +2 -13
- package/blueprints/helper-test/qunit-rfc-232-files/__root__/__testType__/__collection__/__name__-test.js +2 -14
- package/blueprints/initializer/files/__root__/initializers/__name__.js +0 -1
- package/blueprints/instance-initializer/files/__root__/instance-initializers/__name__.js +0 -1
- package/build-metadata.json +3 -3
- package/dist/dependencies/@glimmer/manager.js +19 -98
- package/dist/dependencies/@glimmer/opcode-compiler.js +9 -146
- package/dist/dependencies/@glimmer/runtime.js +1 -55
- package/dist/dependencies/@glimmer/validator.js +19 -51
- package/dist/ember-template-compiler.js +3692 -5667
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +12 -560
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +4357 -12470
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/bootstrap/index.js +2 -55
- package/dist/packages/@ember/-internals/container/index.js +35 -206
- package/dist/packages/@ember/-internals/environment/index.js +3 -46
- package/dist/packages/@ember/-internals/extension-support/lib/container_debug_adapter.js +7 -0
- package/dist/packages/@ember/-internals/extension-support/lib/data_adapter.js +1 -2
- package/dist/packages/@ember/-internals/glimmer/index.js +4774 -7035
- package/dist/packages/@ember/-internals/meta/lib/meta.js +2 -50
- package/dist/packages/@ember/-internals/metal/index.js +785 -1109
- package/dist/packages/@ember/-internals/overrides/index.js +1 -3
- package/dist/packages/@ember/-internals/owner/index.js +1 -19
- package/dist/packages/@ember/-internals/routing/lib/location/auto_location.js +1 -51
- package/dist/packages/@ember/-internals/routing/lib/location/hash_location.js +1 -0
- package/dist/packages/@ember/-internals/routing/lib/location/history_location.js +3 -1
- package/dist/packages/@ember/-internals/routing/lib/location/none_location.js +0 -7
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +34 -2
- package/dist/packages/@ember/-internals/routing/lib/services/routing.js +2 -3
- package/dist/packages/@ember/-internals/routing/lib/system/dsl.js +5 -6
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +192 -652
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +119 -248
- package/dist/packages/@ember/-internals/routing/lib/system/router_state.js +1 -2
- package/dist/packages/@ember/-internals/routing/lib/utils.js +1 -2
- package/dist/packages/@ember/-internals/runtime/index.js +1 -4
- package/dist/packages/@ember/-internals/runtime/lib/mixins/array.js +4 -175
- package/dist/packages/@ember/-internals/runtime/lib/mixins/observable.js +1 -18
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +3 -43
- package/dist/packages/@ember/-internals/runtime/lib/system/array_proxy.js +8 -15
- package/dist/packages/@ember/-internals/runtime/lib/system/core_object.js +10 -141
- package/dist/packages/@ember/-internals/utils/index.js +3 -59
- package/dist/packages/@ember/-internals/views/index.js +0 -2
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +1 -121
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -40
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +115 -190
- package/dist/packages/@ember/-internals/views/lib/views/states/destroying.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/has_element.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/in_dom.js +1 -2
- package/dist/packages/@ember/-internals/views/lib/views/states/pre_render.js +1 -2
- package/dist/packages/@ember/application/instance.js +3 -25
- package/dist/packages/@ember/application/lib/application.js +14 -32
- package/dist/packages/@ember/canary-features/index.js +5 -6
- package/dist/packages/@ember/component/index.js +1 -1
- package/dist/packages/@ember/component/template-only.js +2 -0
- package/dist/packages/@ember/debug/lib/deprecate.js +7 -41
- package/dist/packages/@ember/deprecated-features/index.js +1 -14
- package/dist/packages/@ember/engine/index.js +3 -17
- package/dist/packages/@ember/engine/instance.js +0 -4
- package/dist/packages/@ember/helper/index.js +12 -4
- package/dist/packages/@ember/object/index.js +3 -101
- package/dist/packages/@ember/object/internals.js +0 -1
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +12 -384
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +9 -360
- package/dist/packages/@ember/polyfills/index.js +1 -6
- package/dist/packages/@ember/polyfills/lib/assign.js +12 -28
- package/dist/packages/@ember/routing/index.js +1 -1
- package/dist/packages/@ember/runloop/index.js +1 -83
- package/dist/packages/@ember/string/index.js +1 -206
- package/dist/packages/@ember/utils/index.js +0 -1
- package/dist/packages/ember/index.js +17 -180
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/index.js +0 -2
- package/dist/packages/ember-testing/lib/helpers.js +0 -12
- package/dist/packages/ember-testing/lib/setup_for_testing.js +0 -10
- package/docs/data.json +1637 -3659
- package/lib/index.js +14 -59
- package/lib/overrides.js +0 -61
- package/lib/transforms/inject-babel-helpers.js +1 -3
- package/package.json +27 -23
- package/dist/packages/@ember/-internals/console/index.js +0 -190
- package/dist/packages/@ember/-internals/runtime/lib/copy.js +0 -119
- package/dist/packages/@ember/-internals/runtime/lib/ext/function.js +0 -155
- package/dist/packages/@ember/-internals/runtime/lib/mixins/copyable.js +0 -31
- package/dist/packages/@ember/-internals/views/lib/mixins/text_support.js +0 -357
- package/dist/packages/@ember/-internals/views/lib/system/jquery.js +0 -26
- package/dist/packages/@ember/-internals/views/lib/system/jquery_event_deprecation.js +0 -60
- package/dist/packages/@ember/application/deprecations.js +0 -25
- package/dist/packages/@ember/application/globals-resolver.js +0 -434
- package/dist/packages/@ember/application/resolver.js +0 -1
- package/dist/packages/@ember/component/checkbox.js +0 -17
- package/dist/packages/@ember/component/text-area.js +0 -17
- package/dist/packages/@ember/component/text-field.js +0 -17
- package/dist/packages/@ember/polyfills/lib/merge.js +0 -50
- package/dist/packages/@ember/routing/link-component.js +0 -17
- package/dist/packages/ember-testing/lib/events.js +0 -102
- package/dist/packages/ember-testing/lib/helpers/-is-form-control.js +0 -19
- package/dist/packages/ember-testing/lib/helpers/click.js +0 -32
- package/dist/packages/ember-testing/lib/helpers/fill_in.js +0 -47
- package/dist/packages/ember-testing/lib/helpers/find.js +0 -40
- package/dist/packages/ember-testing/lib/helpers/find_with_assert.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/key_event.js +0 -37
- package/dist/packages/ember-testing/lib/helpers/trigger_event.js +0 -61
- package/dist/packages/ember-testing/lib/support.js +0 -57
- package/dist/packages/jquery/index.js +0 -2
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length,
|
|
3
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
4
|
+
d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
import { privatize as P } from '@ember/-internals/container';
|
|
2
10
|
import { addObserver, computed, defineProperty, descriptorForProperty, flushAsyncObservers, get, getProperties, isEmpty, set, setProperties } from '@ember/-internals/metal';
|
|
3
11
|
import { getOwner } from '@ember/-internals/owner';
|
|
4
12
|
import { A as emberA, ActionHandler, Evented, Object as EmberObject, typeOf } from '@ember/-internals/runtime';
|
|
5
13
|
import { isProxy, lookupDescriptor, symbol } from '@ember/-internals/utils';
|
|
6
|
-
import { assert,
|
|
7
|
-
import { ROUTER_EVENTS } from '@ember/deprecated-features';
|
|
14
|
+
import { assert, info, isTesting } from '@ember/debug';
|
|
8
15
|
import { dependentKeyCompat } from '@ember/object/compat';
|
|
9
|
-
import { assign } from '@ember/polyfills';
|
|
10
16
|
import { once } from '@ember/runloop';
|
|
11
17
|
import { classify } from '@ember/string';
|
|
12
18
|
import { DEBUG } from '@glimmer/env';
|
|
@@ -57,7 +63,7 @@ export function hasDefaultSerialize(route) {
|
|
|
57
63
|
@public
|
|
58
64
|
*/
|
|
59
65
|
|
|
60
|
-
class Route extends EmberObject {
|
|
66
|
+
class Route extends EmberObject.extend(ActionHandler, Evented) {
|
|
61
67
|
constructor(owner) {
|
|
62
68
|
super(...arguments);
|
|
63
69
|
this.context = {};
|
|
@@ -72,29 +78,6 @@ class Route extends EmberObject {
|
|
|
72
78
|
this._environment = owner.lookup('-environment:main');
|
|
73
79
|
}
|
|
74
80
|
}
|
|
75
|
-
/**
|
|
76
|
-
The name of the route, dot-delimited.
|
|
77
|
-
For example, a route found at `app/routes/posts/post.js` will have
|
|
78
|
-
a `routeName` of `posts.post`.
|
|
79
|
-
@property routeName
|
|
80
|
-
@for Route
|
|
81
|
-
@type String
|
|
82
|
-
@since 1.0.0
|
|
83
|
-
@public
|
|
84
|
-
*/
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
The name of the route, dot-delimited, including the engine prefix
|
|
88
|
-
if applicable.
|
|
89
|
-
For example, a route found at `addon/routes/posts/post.js` within an
|
|
90
|
-
engine named `admin` will have a `fullRouteName` of `admin.posts.post`.
|
|
91
|
-
@property fullRouteName
|
|
92
|
-
@for Route
|
|
93
|
-
@type String
|
|
94
|
-
@since 2.10.0
|
|
95
|
-
@public
|
|
96
|
-
*/
|
|
97
|
-
|
|
98
81
|
/**
|
|
99
82
|
Sets the name for this route, including a fully resolved name for routes
|
|
100
83
|
inside engines.
|
|
@@ -214,7 +197,7 @@ class Route extends EmberObject {
|
|
|
214
197
|
let transition = this._router._routerMicrolib.activeTransition;
|
|
215
198
|
let state = transition ? transition[STATE_SYMBOL] : this._router._routerMicrolib.state;
|
|
216
199
|
let fullName = route.fullRouteName;
|
|
217
|
-
let params = assign({}, state.params[fullName]);
|
|
200
|
+
let params = Object.assign({}, state.params[fullName]);
|
|
218
201
|
let queryParams = getQueryParamsFor(route, state);
|
|
219
202
|
return Object.keys(queryParams).reduce((params, key) => {
|
|
220
203
|
assert(`The route '${this.routeName}' has both a dynamic segment and query param with name '${key}'. Please rename one to avoid collisions.`, !params[key]);
|
|
@@ -825,16 +808,7 @@ class Route extends EmberObject {
|
|
|
825
808
|
this.setupController(controller, context, transition);
|
|
826
809
|
|
|
827
810
|
if (this._environment.options.shouldRender) {
|
|
828
|
-
|
|
829
|
-
id: 'route-render-template',
|
|
830
|
-
until: '4.0.0',
|
|
831
|
-
url: 'https://deprecations.emberjs.com/v3.x/#toc_route-render-template',
|
|
832
|
-
for: 'ember-source',
|
|
833
|
-
since: {
|
|
834
|
-
enabled: '3.27.0'
|
|
835
|
-
}
|
|
836
|
-
});
|
|
837
|
-
this.renderTemplate(controller, context);
|
|
811
|
+
this[RENDER]();
|
|
838
812
|
} // Setup can cause changes to QPs which need to be propogated immediately in
|
|
839
813
|
// some situations. Eventually, we should work on making these async somehow.
|
|
840
814
|
|
|
@@ -1123,7 +1097,7 @@ class Route extends EmberObject {
|
|
|
1123
1097
|
@method setupController
|
|
1124
1098
|
@param {Controller} controller instance
|
|
1125
1099
|
@param {Object} model
|
|
1126
|
-
@param {
|
|
1100
|
+
@param {Transition} [transition]
|
|
1127
1101
|
@since 1.0.0
|
|
1128
1102
|
@public
|
|
1129
1103
|
*/
|
|
@@ -1278,276 +1252,6 @@ class Route extends EmberObject {
|
|
|
1278
1252
|
ROUTE_CONNECTIONS.get(this).push(renderOptions);
|
|
1279
1253
|
once(this._router, '_setOutlets');
|
|
1280
1254
|
}
|
|
1281
|
-
/**
|
|
1282
|
-
A hook you can use to render the template for the current route.
|
|
1283
|
-
This method is called with the controller for the current route and the
|
|
1284
|
-
model supplied by the `model` hook. By default, it renders the route's
|
|
1285
|
-
template, configured with the controller for the route.
|
|
1286
|
-
This method can be overridden to set up and render additional or
|
|
1287
|
-
alternative templates.
|
|
1288
|
-
```app/routes/posts.js
|
|
1289
|
-
import Route from '@ember/routing/route';
|
|
1290
|
-
export default class PostsRoute extends Route {
|
|
1291
|
-
renderTemplate(controller, model) {
|
|
1292
|
-
let favController = this.controllerFor('favoritePost');
|
|
1293
|
-
// Render the `favoritePost` template into
|
|
1294
|
-
// the outlet `posts`, and display the `favoritePost`
|
|
1295
|
-
// controller.
|
|
1296
|
-
this.render('favoritePost', {
|
|
1297
|
-
outlet: 'posts',
|
|
1298
|
-
controller: favController
|
|
1299
|
-
});
|
|
1300
|
-
}
|
|
1301
|
-
}
|
|
1302
|
-
```
|
|
1303
|
-
@method renderTemplate
|
|
1304
|
-
@param {Object} controller the route's controller
|
|
1305
|
-
@param {Object} model the route's model
|
|
1306
|
-
@since 1.0.0
|
|
1307
|
-
@public
|
|
1308
|
-
*/
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
renderTemplate(_controller, _model) {
|
|
1312
|
-
// eslint-disable-line no-unused-vars
|
|
1313
|
-
this[RENDER]();
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
`render` is used to render a template into a region of another template
|
|
1317
|
-
(indicated by an `{{outlet}}`). `render` is used both during the entry
|
|
1318
|
-
phase of routing (via the `renderTemplate` hook) and later in response to
|
|
1319
|
-
user interaction.
|
|
1320
|
-
For example, given the following minimal router and templates:
|
|
1321
|
-
```app/router.js
|
|
1322
|
-
// ...
|
|
1323
|
-
Router.map(function() {
|
|
1324
|
-
this.route('photos');
|
|
1325
|
-
});
|
|
1326
|
-
export default Router;
|
|
1327
|
-
```
|
|
1328
|
-
```handlebars
|
|
1329
|
-
<!-- application.hbs -->
|
|
1330
|
-
<div class='something-in-the-app-hbs'>
|
|
1331
|
-
{{outlet "anOutletName"}}
|
|
1332
|
-
</div>
|
|
1333
|
-
```
|
|
1334
|
-
```handlebars
|
|
1335
|
-
<!-- photos.hbs -->
|
|
1336
|
-
<h1>Photos</h1>
|
|
1337
|
-
```
|
|
1338
|
-
You can render `photos.hbs` into the `"anOutletName"` outlet of
|
|
1339
|
-
`application.hbs` by calling `render`:
|
|
1340
|
-
```app/routes/post.js
|
|
1341
|
-
import Route from '@ember/routing/route';
|
|
1342
|
-
export default class PostRoute extends Route {
|
|
1343
|
-
renderTemplate() {
|
|
1344
|
-
this.render('photos', {
|
|
1345
|
-
into: 'application',
|
|
1346
|
-
outlet: 'anOutletName'
|
|
1347
|
-
})
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
```
|
|
1351
|
-
`render` additionally allows you to supply which `controller` and
|
|
1352
|
-
`model` objects should be loaded and associated with the rendered template.
|
|
1353
|
-
```app/routes/posts.js
|
|
1354
|
-
import Route from '@ember/routing/route';
|
|
1355
|
-
export default class PostsRoute extends Route {
|
|
1356
|
-
renderTemplate(controller, model) {
|
|
1357
|
-
this.render('posts', { // the template to render, referenced by name
|
|
1358
|
-
into: 'application', // the template to render into, referenced by name
|
|
1359
|
-
outlet: 'anOutletName', // the outlet inside `options.into` to render into.
|
|
1360
|
-
controller: 'someControllerName', // the controller to use for this template, referenced by name
|
|
1361
|
-
model: model // the model to set on `options.controller`.
|
|
1362
|
-
})
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
```
|
|
1366
|
-
The string values provided for the template name, and controller
|
|
1367
|
-
will eventually pass through to the resolver for lookup. See
|
|
1368
|
-
Resolver for how these are mapped to JavaScript objects in your
|
|
1369
|
-
application. The template to render into needs to be related to either the
|
|
1370
|
-
current route or one of its ancestors.
|
|
1371
|
-
Not all options need to be passed to `render`. Default values will be used
|
|
1372
|
-
based on the name of the route specified in the router or the Route's
|
|
1373
|
-
`controllerName` and `templateName` properties.
|
|
1374
|
-
For example:
|
|
1375
|
-
```app/router.js
|
|
1376
|
-
// ...
|
|
1377
|
-
Router.map(function() {
|
|
1378
|
-
this.route('index');
|
|
1379
|
-
this.route('post', { path: '/posts/:post_id' });
|
|
1380
|
-
});
|
|
1381
|
-
export default Router;
|
|
1382
|
-
```
|
|
1383
|
-
```app/routes/post.js
|
|
1384
|
-
import Route from '@ember/routing/route';
|
|
1385
|
-
export default class PostRoute extends Route {
|
|
1386
|
-
renderTemplate() {
|
|
1387
|
-
this.render(); // all defaults apply
|
|
1388
|
-
}
|
|
1389
|
-
}
|
|
1390
|
-
```
|
|
1391
|
-
The name of the route, defined by the router, is `post`.
|
|
1392
|
-
The following equivalent default options will be applied when
|
|
1393
|
-
the Route calls `render`:
|
|
1394
|
-
```javascript
|
|
1395
|
-
this.render('post', { // the template name associated with 'post' Route
|
|
1396
|
-
into: 'application', // the parent route to 'post' Route
|
|
1397
|
-
outlet: 'main', // {{outlet}} and {{outlet 'main'}} are synonymous,
|
|
1398
|
-
controller: 'post', // the controller associated with the 'post' Route
|
|
1399
|
-
})
|
|
1400
|
-
```
|
|
1401
|
-
By default the controller's `model` will be the route's model, so it does not
|
|
1402
|
-
need to be passed unless you wish to change which model is being used.
|
|
1403
|
-
@method render
|
|
1404
|
-
@param {String} name the name of the template to render
|
|
1405
|
-
@param {Object} [options] the options
|
|
1406
|
-
@param {String} [options.into] the template to render into,
|
|
1407
|
-
referenced by name. Defaults to the parent template
|
|
1408
|
-
@param {String} [options.outlet] the outlet inside `options.into` to render into.
|
|
1409
|
-
Defaults to 'main'
|
|
1410
|
-
@param {String|Object} [options.controller] the controller to use for this template,
|
|
1411
|
-
referenced by name or as a controller instance. Defaults to the Route's paired controller
|
|
1412
|
-
@param {Object} [options.model] the model object to set on `options.controller`.
|
|
1413
|
-
Defaults to the return value of the Route's model hook
|
|
1414
|
-
@since 1.0.0
|
|
1415
|
-
@public
|
|
1416
|
-
*/
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
render(name, options) {
|
|
1420
|
-
deprecate(`Usage of \`render\` is deprecated. Route: \`${this.routeName}\``, false, {
|
|
1421
|
-
id: 'route-render-template',
|
|
1422
|
-
until: '4.0.0',
|
|
1423
|
-
url: 'https://deprecations.emberjs.com/v3.x/#toc_route-render-template',
|
|
1424
|
-
for: 'ember-source',
|
|
1425
|
-
since: {
|
|
1426
|
-
enabled: '3.27.0'
|
|
1427
|
-
}
|
|
1428
|
-
});
|
|
1429
|
-
this[RENDER](name, options);
|
|
1430
|
-
}
|
|
1431
|
-
/**
|
|
1432
|
-
Disconnects a view that has been rendered into an outlet.
|
|
1433
|
-
You may pass any or all of the following options to `disconnectOutlet`:
|
|
1434
|
-
* `outlet`: the name of the outlet to clear (default: 'main')
|
|
1435
|
-
* `parentView`: the name of the view containing the outlet to clear
|
|
1436
|
-
(default: the view rendered by the parent route)
|
|
1437
|
-
Example:
|
|
1438
|
-
```app/routes/application.js
|
|
1439
|
-
import Route from '@ember/routing/route';
|
|
1440
|
-
import { action } from '@ember/object';
|
|
1441
|
-
export default class ApplicationRoute extends Route {
|
|
1442
|
-
@action
|
|
1443
|
-
showModal(evt) {
|
|
1444
|
-
this.render(evt.modalName, {
|
|
1445
|
-
outlet: 'modal',
|
|
1446
|
-
into: 'application'
|
|
1447
|
-
});
|
|
1448
|
-
}
|
|
1449
|
-
@action
|
|
1450
|
-
hideModal() {
|
|
1451
|
-
this.disconnectOutlet({
|
|
1452
|
-
outlet: 'modal',
|
|
1453
|
-
parentView: 'application'
|
|
1454
|
-
});
|
|
1455
|
-
}
|
|
1456
|
-
}
|
|
1457
|
-
```
|
|
1458
|
-
Alternatively, you can pass the `outlet` name directly as a string.
|
|
1459
|
-
Example:
|
|
1460
|
-
```app/routes/application.js
|
|
1461
|
-
import Route from '@ember/routing/route';
|
|
1462
|
-
import { action } from '@ember/object';
|
|
1463
|
-
export default class ApplicationRoute extends Route {
|
|
1464
|
-
@action
|
|
1465
|
-
showModal(evt) {
|
|
1466
|
-
// ...
|
|
1467
|
-
}
|
|
1468
|
-
@action
|
|
1469
|
-
hideModal(evt) {
|
|
1470
|
-
this.disconnectOutlet('modal');
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
```
|
|
1474
|
-
@method disconnectOutlet
|
|
1475
|
-
@param {Object|String} options the options hash or outlet name
|
|
1476
|
-
@since 1.0.0
|
|
1477
|
-
@public
|
|
1478
|
-
*/
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
disconnectOutlet(options) {
|
|
1482
|
-
deprecate('The usage of `disconnectOutlet` is deprecated.', false, {
|
|
1483
|
-
id: 'route-disconnect-outlet',
|
|
1484
|
-
until: '4.0.0',
|
|
1485
|
-
url: 'https://deprecations.emberjs.com/v3.x/#toc_route-disconnect-outlet',
|
|
1486
|
-
for: 'ember-source',
|
|
1487
|
-
since: {
|
|
1488
|
-
enabled: '3.27.0'
|
|
1489
|
-
}
|
|
1490
|
-
});
|
|
1491
|
-
let outletName;
|
|
1492
|
-
let parentView;
|
|
1493
|
-
|
|
1494
|
-
if (options) {
|
|
1495
|
-
if (typeof options === 'string') {
|
|
1496
|
-
outletName = options;
|
|
1497
|
-
} else {
|
|
1498
|
-
outletName = options.outlet;
|
|
1499
|
-
parentView = options.parentView ? options.parentView.replace(/\//g, '.') : undefined;
|
|
1500
|
-
assert('You passed undefined as the outlet name.', !('outlet' in options && options.outlet === undefined));
|
|
1501
|
-
}
|
|
1502
|
-
}
|
|
1503
|
-
|
|
1504
|
-
outletName = outletName || 'main';
|
|
1505
|
-
|
|
1506
|
-
this._disconnectOutlet(outletName, parentView);
|
|
1507
|
-
|
|
1508
|
-
let routeInfos = this._router._routerMicrolib.currentRouteInfos;
|
|
1509
|
-
|
|
1510
|
-
for (let i = 0; i < routeInfos.length; i++) {
|
|
1511
|
-
// This non-local state munging is sadly necessary to maintain
|
|
1512
|
-
// backward compatibility with our existing semantics, which allow
|
|
1513
|
-
// any route to disconnectOutlet things originally rendered by any
|
|
1514
|
-
// other route. This should all get cut in 2.0.
|
|
1515
|
-
routeInfos[i].route._disconnectOutlet(outletName, parentView);
|
|
1516
|
-
}
|
|
1517
|
-
}
|
|
1518
|
-
|
|
1519
|
-
_disconnectOutlet(outletName, parentView) {
|
|
1520
|
-
let parent = parentRoute(this);
|
|
1521
|
-
|
|
1522
|
-
if (parent && parentView === parent.routeName) {
|
|
1523
|
-
parentView = undefined;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
let connections = ROUTE_CONNECTIONS.get(this);
|
|
1527
|
-
|
|
1528
|
-
for (let i = 0; i < connections.length; i++) {
|
|
1529
|
-
let connection = connections[i];
|
|
1530
|
-
|
|
1531
|
-
if (connection.outlet === outletName && connection.into === parentView) {
|
|
1532
|
-
// This neuters the disconnected outlet such that it doesn't
|
|
1533
|
-
// render anything, but it leaves an entry in the outlet
|
|
1534
|
-
// hierarchy so that any existing other renders that target it
|
|
1535
|
-
// don't suddenly blow up. They will still stick themselves
|
|
1536
|
-
// into its outlets, which won't render anywhere. All of this
|
|
1537
|
-
// statefulness should get the machete in 2.0.
|
|
1538
|
-
connections[i] = {
|
|
1539
|
-
owner: connection.owner,
|
|
1540
|
-
into: connection.into,
|
|
1541
|
-
outlet: connection.outlet,
|
|
1542
|
-
name: connection.name,
|
|
1543
|
-
controller: undefined,
|
|
1544
|
-
template: undefined,
|
|
1545
|
-
model: undefined
|
|
1546
|
-
};
|
|
1547
|
-
once(this._router, '_setOutlets');
|
|
1548
|
-
}
|
|
1549
|
-
}
|
|
1550
|
-
}
|
|
1551
1255
|
|
|
1552
1256
|
willDestroy() {
|
|
1553
1257
|
this.teardownViews();
|
|
@@ -1602,11 +1306,181 @@ class Route extends EmberObject {
|
|
|
1602
1306
|
|
|
1603
1307
|
buildRouteInfoMetadata() {}
|
|
1604
1308
|
|
|
1309
|
+
_paramsFor(routeName, params) {
|
|
1310
|
+
let transition = this._router._routerMicrolib.activeTransition;
|
|
1311
|
+
|
|
1312
|
+
if (transition !== undefined) {
|
|
1313
|
+
return this.paramsFor(routeName);
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
return params;
|
|
1317
|
+
}
|
|
1318
|
+
/**
|
|
1319
|
+
Store property provides a hook for data persistence libraries to inject themselves.
|
|
1320
|
+
By default, this store property provides the exact same functionality previously
|
|
1321
|
+
in the model hook.
|
|
1322
|
+
Currently, the required interface is:
|
|
1323
|
+
`store.find(modelName, findArguments)`
|
|
1324
|
+
@property store
|
|
1325
|
+
@type {Object}
|
|
1326
|
+
@private
|
|
1327
|
+
*/
|
|
1328
|
+
|
|
1329
|
+
|
|
1330
|
+
get store() {
|
|
1331
|
+
let owner = getOwner(this);
|
|
1332
|
+
let routeName = this.routeName;
|
|
1333
|
+
let namespace = get(this, '_router.namespace');
|
|
1334
|
+
return {
|
|
1335
|
+
find(name, value) {
|
|
1336
|
+
let modelClass = owner.factoryFor(`model:${name}`);
|
|
1337
|
+
assert(`You used the dynamic segment ${name}_id in your route ${routeName}, but ${namespace}.${classify(name)} did not exist and you did not override your route's \`model\` hook.`, Boolean(modelClass));
|
|
1338
|
+
|
|
1339
|
+
if (!modelClass) {
|
|
1340
|
+
return;
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
modelClass = modelClass.class;
|
|
1344
|
+
assert(`${classify(name)} has no method \`find\`.`, typeof modelClass.find === 'function');
|
|
1345
|
+
return modelClass.find(value);
|
|
1346
|
+
}
|
|
1347
|
+
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
set store(value) {
|
|
1352
|
+
defineProperty(this, 'store', null, value);
|
|
1353
|
+
}
|
|
1354
|
+
/**
|
|
1355
|
+
@private
|
|
1356
|
+
@property _qp
|
|
1357
|
+
*/
|
|
1358
|
+
|
|
1359
|
+
|
|
1360
|
+
get _qp() {
|
|
1361
|
+
let combinedQueryParameterConfiguration;
|
|
1362
|
+
let controllerName = this.controllerName || this.routeName;
|
|
1363
|
+
let owner = getOwner(this);
|
|
1364
|
+
let controller = owner.lookup(`controller:${controllerName}`);
|
|
1365
|
+
let queryParameterConfiguraton = get(this, 'queryParams');
|
|
1366
|
+
let hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0;
|
|
1367
|
+
|
|
1368
|
+
if (controller) {
|
|
1369
|
+
// the developer has authored a controller class in their application for
|
|
1370
|
+
// this route find its query params and normalize their object shape them
|
|
1371
|
+
// merge in the query params for the route. As a mergedProperty,
|
|
1372
|
+
// Route#queryParams is always at least `{}`
|
|
1373
|
+
let controllerDefinedQueryParameterConfiguration = get(controller, 'queryParams') || {};
|
|
1374
|
+
let normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration);
|
|
1375
|
+
combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton);
|
|
1376
|
+
} else if (hasRouterDefinedQueryParams) {
|
|
1377
|
+
// the developer has not defined a controller but *has* supplied route query params.
|
|
1378
|
+
// Generate a class for them so we can later insert default values
|
|
1379
|
+
controller = generateController(owner, controllerName);
|
|
1380
|
+
combinedQueryParameterConfiguration = queryParameterConfiguraton;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
let qps = [];
|
|
1384
|
+
let map = {};
|
|
1385
|
+
let propertyNames = [];
|
|
1386
|
+
|
|
1387
|
+
for (let propName in combinedQueryParameterConfiguration) {
|
|
1388
|
+
if (!Object.prototype.hasOwnProperty.call(combinedQueryParameterConfiguration, propName)) {
|
|
1389
|
+
continue;
|
|
1390
|
+
} // to support the dubious feature of using unknownProperty
|
|
1391
|
+
// on queryParams configuration
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
if (propName === 'unknownProperty' || propName === '_super') {
|
|
1395
|
+
// possible todo: issue deprecation warning?
|
|
1396
|
+
continue;
|
|
1397
|
+
}
|
|
1398
|
+
|
|
1399
|
+
let desc = combinedQueryParameterConfiguration[propName];
|
|
1400
|
+
let scope = desc.scope || 'model';
|
|
1401
|
+
let parts;
|
|
1402
|
+
|
|
1403
|
+
if (scope === 'controller') {
|
|
1404
|
+
parts = [];
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
let urlKey = desc.as || this.serializeQueryParamKey(propName);
|
|
1408
|
+
let defaultValue = get(controller, propName);
|
|
1409
|
+
defaultValue = copyDefaultValue(defaultValue);
|
|
1410
|
+
let type = desc.type || typeOf(defaultValue);
|
|
1411
|
+
let defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type);
|
|
1412
|
+
let scopedPropertyName = `${controllerName}:${propName}`;
|
|
1413
|
+
let qp = {
|
|
1414
|
+
undecoratedDefaultValue: get(controller, propName),
|
|
1415
|
+
defaultValue,
|
|
1416
|
+
serializedDefaultValue: defaultValueSerialized,
|
|
1417
|
+
serializedValue: defaultValueSerialized,
|
|
1418
|
+
type,
|
|
1419
|
+
urlKey,
|
|
1420
|
+
prop: propName,
|
|
1421
|
+
scopedPropertyName,
|
|
1422
|
+
controllerName,
|
|
1423
|
+
route: this,
|
|
1424
|
+
parts,
|
|
1425
|
+
values: null,
|
|
1426
|
+
scope
|
|
1427
|
+
};
|
|
1428
|
+
map[propName] = map[urlKey] = map[scopedPropertyName] = qp;
|
|
1429
|
+
qps.push(qp);
|
|
1430
|
+
propertyNames.push(propName);
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
return {
|
|
1434
|
+
qps,
|
|
1435
|
+
map,
|
|
1436
|
+
propertyNames,
|
|
1437
|
+
states: {
|
|
1438
|
+
/*
|
|
1439
|
+
Called when a query parameter changes in the URL, this route cares
|
|
1440
|
+
about that query parameter, but the route is not currently
|
|
1441
|
+
in the active route hierarchy.
|
|
1442
|
+
*/
|
|
1443
|
+
inactive: (prop, value) => {
|
|
1444
|
+
let qp = map[prop];
|
|
1445
|
+
|
|
1446
|
+
this._qpChanged(prop, value, qp);
|
|
1447
|
+
},
|
|
1448
|
+
|
|
1449
|
+
/*
|
|
1450
|
+
Called when a query parameter changes in the URL, this route cares
|
|
1451
|
+
about that query parameter, and the route is currently
|
|
1452
|
+
in the active route hierarchy.
|
|
1453
|
+
*/
|
|
1454
|
+
active: (prop, value) => {
|
|
1455
|
+
let qp = map[prop];
|
|
1456
|
+
|
|
1457
|
+
this._qpChanged(prop, value, qp);
|
|
1458
|
+
|
|
1459
|
+
return this._activeQPChanged(qp, value);
|
|
1460
|
+
},
|
|
1461
|
+
|
|
1462
|
+
/*
|
|
1463
|
+
Called when a value of a query parameter this route handles changes in a controller
|
|
1464
|
+
and the route is currently in the active route hierarchy.
|
|
1465
|
+
*/
|
|
1466
|
+
allowOverrides: (prop, value) => {
|
|
1467
|
+
let qp = map[prop];
|
|
1468
|
+
|
|
1469
|
+
this._qpChanged(prop, value, qp);
|
|
1470
|
+
|
|
1471
|
+
return this._updatingQPChanged(qp);
|
|
1472
|
+
}
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1605
1477
|
}
|
|
1606
1478
|
|
|
1607
|
-
Route.
|
|
1608
|
-
|
|
1609
|
-
|
|
1479
|
+
Route.isRouteFactory = true;
|
|
1480
|
+
|
|
1481
|
+
__decorate([computed], Route.prototype, "store", null);
|
|
1482
|
+
|
|
1483
|
+
__decorate([computed], Route.prototype, "_qp", null);
|
|
1610
1484
|
|
|
1611
1485
|
function parentRoute(route) {
|
|
1612
1486
|
let routeInfo = routeInfoFor(route, route._router._routerMicrolib.state.routeInfos, -1);
|
|
@@ -1726,7 +1600,7 @@ export function getFullQueryParams(router, state) {
|
|
|
1726
1600
|
|
|
1727
1601
|
let fullQueryParamsState = {};
|
|
1728
1602
|
let haveAllRouteInfosResolved = state.routeInfos.every(routeInfo => routeInfo.route);
|
|
1729
|
-
assign(fullQueryParamsState, state.queryParams);
|
|
1603
|
+
Object.assign(fullQueryParamsState, state.queryParams);
|
|
1730
1604
|
|
|
1731
1605
|
router._deserializeQueryParams(state.routeInfos, fullQueryParamsState); // only cache query params state if all routeinfos have resolved; it's possible
|
|
1732
1606
|
// for lazy routes to not have resolved when `getFullQueryParams` is called, so
|
|
@@ -1793,7 +1667,7 @@ function mergeEachQueryParams(controllerQP, routeQP) {
|
|
|
1793
1667
|
}
|
|
1794
1668
|
|
|
1795
1669
|
let newControllerParameterConfiguration = {};
|
|
1796
|
-
assign(newControllerParameterConfiguration, controllerQP[cqpName], routeQP[cqpName]);
|
|
1670
|
+
Object.assign(newControllerParameterConfiguration, controllerQP[cqpName], routeQP[cqpName]);
|
|
1797
1671
|
qps[cqpName] = newControllerParameterConfiguration; // allows us to skip this QP when we check route QPs.
|
|
1798
1672
|
|
|
1799
1673
|
keysAlreadyMergedOrSkippable[cqpName] = true;
|
|
@@ -1807,7 +1681,7 @@ function mergeEachQueryParams(controllerQP, routeQP) {
|
|
|
1807
1681
|
}
|
|
1808
1682
|
|
|
1809
1683
|
let newRouteParameterConfiguration = {};
|
|
1810
|
-
assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]);
|
|
1684
|
+
Object.assign(newRouteParameterConfiguration, routeQP[rqpName], controllerQP[rqpName]);
|
|
1811
1685
|
qps[rqpName] = newRouteParameterConfiguration;
|
|
1812
1686
|
}
|
|
1813
1687
|
|
|
@@ -1891,298 +1765,14 @@ function getEngineRouteName(engine, routeName) {
|
|
|
1891
1765
|
*/
|
|
1892
1766
|
|
|
1893
1767
|
|
|
1894
|
-
Route.prototype.serialize = defaultSerialize;
|
|
1895
|
-
Route.reopen(ActionHandler, Evented, {
|
|
1896
|
-
mergedProperties: ['queryParams'],
|
|
1768
|
+
Route.prototype.serialize = defaultSerialize; // Set these here so they can be overridden with extend
|
|
1897
1769
|
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
configuration options and their defaults are as follows
|
|
1901
|
-
(assuming a query param whose controller property is `page`):
|
|
1902
|
-
```javascript
|
|
1903
|
-
queryParams: {
|
|
1904
|
-
page: {
|
|
1905
|
-
// By default, controller query param properties don't
|
|
1906
|
-
// cause a full transition when they are changed, but
|
|
1907
|
-
// rather only cause the URL to update. Setting
|
|
1908
|
-
// `refreshModel` to true will cause an "in-place"
|
|
1909
|
-
// transition to occur, whereby the model hooks for
|
|
1910
|
-
// this route (and any child routes) will re-fire, allowing
|
|
1911
|
-
// you to reload models (e.g., from the server) using the
|
|
1912
|
-
// updated query param values.
|
|
1913
|
-
refreshModel: false,
|
|
1914
|
-
// By default, changes to controller query param properties
|
|
1915
|
-
// cause the URL to update via `pushState`, which means an
|
|
1916
|
-
// item will be added to the browser's history, allowing
|
|
1917
|
-
// you to use the back button to restore the app to the
|
|
1918
|
-
// previous state before the query param property was changed.
|
|
1919
|
-
// Setting `replace` to true will use `replaceState` (or its
|
|
1920
|
-
// hash location equivalent), which causes no browser history
|
|
1921
|
-
// item to be added. This options name and default value are
|
|
1922
|
-
// the same as the `link-to` helper's `replace` option.
|
|
1923
|
-
replace: false,
|
|
1924
|
-
// By default, the query param URL key is the same name as
|
|
1925
|
-
// the controller property name. Use `as` to specify a
|
|
1926
|
-
// different URL key.
|
|
1927
|
-
as: 'page'
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
```
|
|
1931
|
-
@property queryParams
|
|
1932
|
-
@for Route
|
|
1933
|
-
@type Object
|
|
1934
|
-
@since 1.6.0
|
|
1935
|
-
@public
|
|
1936
|
-
*/
|
|
1770
|
+
Route.reopen({
|
|
1771
|
+
mergedProperties: ['queryParams'],
|
|
1937
1772
|
queryParams: {},
|
|
1938
|
-
|
|
1939
|
-
/**
|
|
1940
|
-
The name of the template to use by default when rendering this routes
|
|
1941
|
-
template.
|
|
1942
|
-
```app/routes/posts/list.js
|
|
1943
|
-
import Route from '@ember/routing/route';
|
|
1944
|
-
export default class extends Route {
|
|
1945
|
-
templateName = 'posts/list'
|
|
1946
|
-
});
|
|
1947
|
-
```
|
|
1948
|
-
```app/routes/posts/index.js
|
|
1949
|
-
import PostsList from '../posts/list';
|
|
1950
|
-
export default class extends PostsList {};
|
|
1951
|
-
```
|
|
1952
|
-
```app/routes/posts/archived.js
|
|
1953
|
-
import PostsList from '../posts/list';
|
|
1954
|
-
export default class extends PostsList {};
|
|
1955
|
-
```
|
|
1956
|
-
@property templateName
|
|
1957
|
-
@type String
|
|
1958
|
-
@default null
|
|
1959
|
-
@since 1.4.0
|
|
1960
|
-
@public
|
|
1961
|
-
*/
|
|
1962
1773
|
templateName: null,
|
|
1963
|
-
|
|
1964
|
-
/**
|
|
1965
|
-
@private
|
|
1966
|
-
@property _names
|
|
1967
|
-
*/
|
|
1968
|
-
_names: null,
|
|
1969
|
-
|
|
1970
|
-
/**
|
|
1971
|
-
The name of the controller to associate with this route.
|
|
1972
|
-
By default, Ember will lookup a route's controller that matches the name
|
|
1973
|
-
of the route (i.e. `posts.new`). However,
|
|
1974
|
-
if you would like to define a specific controller to use, you can do so
|
|
1975
|
-
using this property.
|
|
1976
|
-
This is useful in many ways, as the controller specified will be:
|
|
1977
|
-
* passed to the `setupController` method.
|
|
1978
|
-
* used as the controller for the template being rendered by the route.
|
|
1979
|
-
* returned from a call to `controllerFor` for the route.
|
|
1980
|
-
@property controllerName
|
|
1981
|
-
@type String
|
|
1982
|
-
@default null
|
|
1983
|
-
@since 1.4.0
|
|
1984
|
-
@public
|
|
1985
|
-
*/
|
|
1986
1774
|
controllerName: null,
|
|
1987
1775
|
|
|
1988
|
-
/**
|
|
1989
|
-
Store property provides a hook for data persistence libraries to inject themselves.
|
|
1990
|
-
By default, this store property provides the exact same functionality previously
|
|
1991
|
-
in the model hook.
|
|
1992
|
-
Currently, the required interface is:
|
|
1993
|
-
`store.find(modelName, findArguments)`
|
|
1994
|
-
@property store
|
|
1995
|
-
@type {Object}
|
|
1996
|
-
@private
|
|
1997
|
-
*/
|
|
1998
|
-
store: computed({
|
|
1999
|
-
get() {
|
|
2000
|
-
let owner = getOwner(this);
|
|
2001
|
-
let routeName = this.routeName;
|
|
2002
|
-
let namespace = get(this, '_router.namespace');
|
|
2003
|
-
return {
|
|
2004
|
-
find(name, value) {
|
|
2005
|
-
let modelClass = owner.factoryFor(`model:${name}`);
|
|
2006
|
-
assert(`You used the dynamic segment ${name}_id in your route ${routeName}, but ${namespace}.${classify(name)} did not exist and you did not override your route's \`model\` hook.`, Boolean(modelClass));
|
|
2007
|
-
|
|
2008
|
-
if (!modelClass) {
|
|
2009
|
-
return;
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
modelClass = modelClass.class;
|
|
2013
|
-
assert(`${classify(name)} has no method \`find\`.`, typeof modelClass.find === 'function');
|
|
2014
|
-
return modelClass.find(value);
|
|
2015
|
-
}
|
|
2016
|
-
|
|
2017
|
-
};
|
|
2018
|
-
},
|
|
2019
|
-
|
|
2020
|
-
set(key, value) {
|
|
2021
|
-
defineProperty(this, key, null, value);
|
|
2022
|
-
}
|
|
2023
|
-
|
|
2024
|
-
}),
|
|
2025
|
-
|
|
2026
|
-
/**
|
|
2027
|
-
@private
|
|
2028
|
-
@property _qp
|
|
2029
|
-
*/
|
|
2030
|
-
_qp: computed(function () {
|
|
2031
|
-
let combinedQueryParameterConfiguration;
|
|
2032
|
-
let controllerName = this.controllerName || this.routeName;
|
|
2033
|
-
let owner = getOwner(this);
|
|
2034
|
-
let controller = owner.lookup(`controller:${controllerName}`);
|
|
2035
|
-
let queryParameterConfiguraton = get(this, 'queryParams');
|
|
2036
|
-
let hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0;
|
|
2037
|
-
|
|
2038
|
-
if (controller) {
|
|
2039
|
-
// the developer has authored a controller class in their application for
|
|
2040
|
-
// this route find its query params and normalize their object shape them
|
|
2041
|
-
// merge in the query params for the route. As a mergedProperty,
|
|
2042
|
-
// Route#queryParams is always at least `{}`
|
|
2043
|
-
let controllerDefinedQueryParameterConfiguration = get(controller, 'queryParams') || {};
|
|
2044
|
-
let normalizedControllerQueryParameterConfiguration = normalizeControllerQueryParams(controllerDefinedQueryParameterConfiguration);
|
|
2045
|
-
combinedQueryParameterConfiguration = mergeEachQueryParams(normalizedControllerQueryParameterConfiguration, queryParameterConfiguraton);
|
|
2046
|
-
} else if (hasRouterDefinedQueryParams) {
|
|
2047
|
-
// the developer has not defined a controller but *has* supplied route query params.
|
|
2048
|
-
// Generate a class for them so we can later insert default values
|
|
2049
|
-
controller = generateController(owner, controllerName);
|
|
2050
|
-
combinedQueryParameterConfiguration = queryParameterConfiguraton;
|
|
2051
|
-
}
|
|
2052
|
-
|
|
2053
|
-
let qps = [];
|
|
2054
|
-
let map = {};
|
|
2055
|
-
let propertyNames = [];
|
|
2056
|
-
|
|
2057
|
-
for (let propName in combinedQueryParameterConfiguration) {
|
|
2058
|
-
if (!Object.prototype.hasOwnProperty.call(combinedQueryParameterConfiguration, propName)) {
|
|
2059
|
-
continue;
|
|
2060
|
-
} // to support the dubious feature of using unknownProperty
|
|
2061
|
-
// on queryParams configuration
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
if (propName === 'unknownProperty' || propName === '_super') {
|
|
2065
|
-
// possible todo: issue deprecation warning?
|
|
2066
|
-
continue;
|
|
2067
|
-
}
|
|
2068
|
-
|
|
2069
|
-
let desc = combinedQueryParameterConfiguration[propName];
|
|
2070
|
-
let scope = desc.scope || 'model';
|
|
2071
|
-
let parts;
|
|
2072
|
-
|
|
2073
|
-
if (scope === 'controller') {
|
|
2074
|
-
parts = [];
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2077
|
-
let urlKey = desc.as || this.serializeQueryParamKey(propName);
|
|
2078
|
-
let defaultValue = get(controller, propName);
|
|
2079
|
-
defaultValue = copyDefaultValue(defaultValue);
|
|
2080
|
-
let type = desc.type || typeOf(defaultValue);
|
|
2081
|
-
let defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type);
|
|
2082
|
-
let scopedPropertyName = `${controllerName}:${propName}`;
|
|
2083
|
-
let qp = {
|
|
2084
|
-
undecoratedDefaultValue: get(controller, propName),
|
|
2085
|
-
defaultValue,
|
|
2086
|
-
serializedDefaultValue: defaultValueSerialized,
|
|
2087
|
-
serializedValue: defaultValueSerialized,
|
|
2088
|
-
type,
|
|
2089
|
-
urlKey,
|
|
2090
|
-
prop: propName,
|
|
2091
|
-
scopedPropertyName,
|
|
2092
|
-
controllerName,
|
|
2093
|
-
route: this,
|
|
2094
|
-
parts,
|
|
2095
|
-
values: null,
|
|
2096
|
-
scope
|
|
2097
|
-
};
|
|
2098
|
-
map[propName] = map[urlKey] = map[scopedPropertyName] = qp;
|
|
2099
|
-
qps.push(qp);
|
|
2100
|
-
propertyNames.push(propName);
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
return {
|
|
2104
|
-
qps,
|
|
2105
|
-
map,
|
|
2106
|
-
propertyNames,
|
|
2107
|
-
states: {
|
|
2108
|
-
/*
|
|
2109
|
-
Called when a query parameter changes in the URL, this route cares
|
|
2110
|
-
about that query parameter, but the route is not currently
|
|
2111
|
-
in the active route hierarchy.
|
|
2112
|
-
*/
|
|
2113
|
-
inactive: (prop, value) => {
|
|
2114
|
-
let qp = map[prop];
|
|
2115
|
-
|
|
2116
|
-
this._qpChanged(prop, value, qp);
|
|
2117
|
-
},
|
|
2118
|
-
|
|
2119
|
-
/*
|
|
2120
|
-
Called when a query parameter changes in the URL, this route cares
|
|
2121
|
-
about that query parameter, and the route is currently
|
|
2122
|
-
in the active route hierarchy.
|
|
2123
|
-
*/
|
|
2124
|
-
active: (prop, value) => {
|
|
2125
|
-
let qp = map[prop];
|
|
2126
|
-
|
|
2127
|
-
this._qpChanged(prop, value, qp);
|
|
2128
|
-
|
|
2129
|
-
return this._activeQPChanged(qp, value);
|
|
2130
|
-
},
|
|
2131
|
-
|
|
2132
|
-
/*
|
|
2133
|
-
Called when a value of a query parameter this route handles changes in a controller
|
|
2134
|
-
and the route is currently in the active route hierarchy.
|
|
2135
|
-
*/
|
|
2136
|
-
allowOverrides: (prop, value) => {
|
|
2137
|
-
let qp = map[prop];
|
|
2138
|
-
|
|
2139
|
-
this._qpChanged(prop, value, qp);
|
|
2140
|
-
|
|
2141
|
-
return this._updatingQPChanged(qp);
|
|
2142
|
-
}
|
|
2143
|
-
}
|
|
2144
|
-
};
|
|
2145
|
-
}),
|
|
2146
|
-
|
|
2147
|
-
/**
|
|
2148
|
-
Sends an action to the router, which will delegate it to the currently
|
|
2149
|
-
active route hierarchy per the bubbling rules explained under `actions`.
|
|
2150
|
-
Example
|
|
2151
|
-
```app/router.js
|
|
2152
|
-
// ...
|
|
2153
|
-
Router.map(function() {
|
|
2154
|
-
this.route('index');
|
|
2155
|
-
});
|
|
2156
|
-
export default Router;
|
|
2157
|
-
```
|
|
2158
|
-
```app/routes/application.js
|
|
2159
|
-
import Route from '@ember/routing/route';
|
|
2160
|
-
import { action } from '@ember/object';
|
|
2161
|
-
export default class ApplicationRoute extends Route {
|
|
2162
|
-
@action
|
|
2163
|
-
track(arg) {
|
|
2164
|
-
console.log(arg, 'was clicked');
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
```
|
|
2168
|
-
```app/routes/index.js
|
|
2169
|
-
import Route from '@ember/routing/route';
|
|
2170
|
-
import { action } from '@ember/object';
|
|
2171
|
-
export default class IndexRoute extends Route {
|
|
2172
|
-
@action
|
|
2173
|
-
trackIfDebug(arg) {
|
|
2174
|
-
if (debug) {
|
|
2175
|
-
this.send('track', arg);
|
|
2176
|
-
}
|
|
2177
|
-
}
|
|
2178
|
-
}
|
|
2179
|
-
```
|
|
2180
|
-
@method send
|
|
2181
|
-
@param {String} name the name of the action to trigger
|
|
2182
|
-
@param {...*} args
|
|
2183
|
-
@since 1.0.0
|
|
2184
|
-
@public
|
|
2185
|
-
*/
|
|
2186
1776
|
send(...args) {
|
|
2187
1777
|
assert(`Attempted to call .send() with the action '${args[0]}' on the destroyed route '${this.routeName}'.`, !this.isDestroying && !this.isDestroyed);
|
|
2188
1778
|
|
|
@@ -2354,54 +1944,4 @@ Route.reopen(ActionHandler, Evented, {
|
|
|
2354
1944
|
|
|
2355
1945
|
}
|
|
2356
1946
|
});
|
|
2357
|
-
export let ROUTER_EVENT_DEPRECATIONS;
|
|
2358
|
-
|
|
2359
|
-
if (ROUTER_EVENTS) {
|
|
2360
|
-
ROUTER_EVENT_DEPRECATIONS = {
|
|
2361
|
-
on(name) {
|
|
2362
|
-
this._super(...arguments);
|
|
2363
|
-
|
|
2364
|
-
let hasDidTransition = name === 'didTransition';
|
|
2365
|
-
let hasWillTransition = name === 'willTransition';
|
|
2366
|
-
|
|
2367
|
-
if (hasDidTransition) {
|
|
2368
|
-
deprecate('You attempted to listen to the "didTransition" event which is deprecated. Please inject the router service and listen to the "routeDidChange" event.', false, {
|
|
2369
|
-
id: 'deprecate-router-events',
|
|
2370
|
-
until: '4.0.0',
|
|
2371
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
2372
|
-
for: 'ember-source',
|
|
2373
|
-
since: {
|
|
2374
|
-
enabled: '3.11.0'
|
|
2375
|
-
}
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
|
|
2379
|
-
if (hasWillTransition) {
|
|
2380
|
-
deprecate('You attempted to listen to the "willTransition" event which is deprecated. Please inject the router service and listen to the "routeWillChange" event.', false, {
|
|
2381
|
-
id: 'deprecate-router-events',
|
|
2382
|
-
until: '4.0.0',
|
|
2383
|
-
url: 'https://deprecations.emberjs.com/v3.x#toc_deprecate-router-events',
|
|
2384
|
-
for: 'ember-source',
|
|
2385
|
-
since: {
|
|
2386
|
-
enabled: '3.11.0'
|
|
2387
|
-
}
|
|
2388
|
-
});
|
|
2389
|
-
}
|
|
2390
|
-
}
|
|
2391
|
-
|
|
2392
|
-
};
|
|
2393
|
-
Route.reopen(ROUTER_EVENT_DEPRECATIONS, {
|
|
2394
|
-
_paramsFor(routeName, params) {
|
|
2395
|
-
let transition = this._router._routerMicrolib.activeTransition;
|
|
2396
|
-
|
|
2397
|
-
if (transition !== undefined) {
|
|
2398
|
-
return this.paramsFor(routeName);
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2401
|
-
return params;
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
});
|
|
2405
|
-
}
|
|
2406
|
-
|
|
2407
1947
|
export default Route;
|