projects
/
civicrm-core.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update 5.19.0.md
[civicrm-core.git]
/
ang
/
crmRouteBinder.js
diff --git
a/ang/crmRouteBinder.js
b/ang/crmRouteBinder.js
index 16947a3d79dc0d65e38238789fccc9f2ec1b4332..a8563fd0c1deaf17e41c8357eecc4b8cfbce051d 100644
(file)
--- a/
ang/crmRouteBinder.js
+++ b/
ang/crmRouteBinder.js
@@
-50,23
+50,23
@@
registerGlobalListener($injector);
options.format = options.format || 'json';
registerGlobalListener($injector);
options.format = options.format || 'json';
- var fmt =
formats[options.format]
;
+ var fmt =
_.clone(formats[options.format])
;
if (options.deep) {
fmt.watcher = '$watch';
}
if (options.default === undefined) {
options.default = fmt.default;
}
if (options.deep) {
fmt.watcher = '$watch';
}
if (options.default === undefined) {
options.default = fmt.default;
}
- var _scope = this;
+ var value,
+ _scope = this,
+ $route = $injector.get('$route'),
+ $timeout = $injector.get('$timeout');
- var $route = $injector.get('$route'), $timeout = $injector.get('$timeout');
-
- var value;
if (options.param in $route.current.params) {
value = fmt.decode($route.current.params[options.param]);
}
else {
if (options.param in $route.current.params) {
value = fmt.decode($route.current.params[options.param]);
}
else {
- value = _.
isObject(options.default) ? angular.extend({}, options.default) : options.default
;
+ value = _.
cloneDeep(options.default)
;
ignorable[options.param] = fmt.encode(options.default);
}
$parse(options.expr).assign(_scope, value);
ignorable[options.param] = fmt.encode(options.default);
}
$parse(options.expr).assign(_scope, value);
@@
-74,12
+74,25
@@
// Keep the URL bar up-to-date.
_scope[fmt.watcher](options.expr, function (newValue) {
var encValue = fmt.encode(newValue);
// Keep the URL bar up-to-date.
_scope[fmt.watcher](options.expr, function (newValue) {
var encValue = fmt.encode(newValue);
- if ($route.current.params[options.param] === encValue) return;
+ if (!_.isEqual(newValue, options.default) && $route.current.params[options.param] === encValue) {
+ return;
+ }
pendingUpdates = pendingUpdates || {};
pendingUpdates[options.param] = encValue;
var p = angular.extend({}, $route.current.params, pendingUpdates);
pendingUpdates = pendingUpdates || {};
pendingUpdates[options.param] = encValue;
var p = angular.extend({}, $route.current.params, pendingUpdates);
- angular.forEach(ignorable, function(v,k){ if (p[k] === v) delete p[k]; });
+
+ angular.forEach(ignorable, function(v, k) {
+ if (p[k] === v) {
+ delete p[k];
+ }
+ });
+
+ // Remove params from url if they equal their defaults
+ if (_.isEqual(newValue, options.default)) {
+ p[options.param] = null;
+ }
+
$route.updateParams(p);
if (activeTimer) $timeout.cancel(activeTimer);
$route.updateParams(p);
if (activeTimer) $timeout.cancel(activeTimer);