switch to angular expression evaluation syntax, update usage and tests accordingly

This commit is contained in:
Joe Fleming 2014-09-04 12:58:42 -07:00
parent 53d376d6c4
commit 17fa030f97
10 changed files with 13 additions and 13 deletions

View file

@ -113,7 +113,7 @@ define(function (require) {
.then(function () {
notify.info('Saved Dashboard as "' + dash.title + '"');
if (dash.id !== $routeParams.id) {
kbnUrl.change('/dashboard/{id}', {id: dash.id});
kbnUrl.change('/dashboard/{{id}}', {id: dash.id});
}
})
.catch(notify.fatal);

View file

@ -23,7 +23,7 @@ define(function (require) {
};
this.urlFor = function (id) {
return kbnUrl.eval('#/dashboard/{id}', {id: id});
return kbnUrl.eval('#/dashboard/{{id}}', {id: id});
};
this.delete = function (ids) {

View file

@ -228,7 +228,7 @@ define(function (require) {
.then(function () {
notify.info('Saved Data Source "' + savedSearch.title + '"');
if (savedSearch.id !== $route.current.params.id) {
kbnUrl.change('/discover/{id}', { id: savedSearch.id });
kbnUrl.change('/discover/{{id}}', { id: savedSearch.id });
}
});
})

View file

@ -27,7 +27,7 @@ define(function (require) {
};
this.urlFor = function (id) {
return kbnUrl.eval('#/discover/{id}', {id: id});
return kbnUrl.eval('#/discover/{{id}}', {id: id});
};
this.delete = function (ids) {

View file

@ -31,7 +31,7 @@ define(function (require) {
.map(function (id) {
return {
id: id,
url: kbnUrl.eval('#/settings/indices/{id}', {id: id}),
url: kbnUrl.eval('#/settings/indices/{{id}}', {id: id}),
class: 'sidebar-item-title ' + ($scope.edittingId === id ? 'active' : ''),
default: $scope.defaultIndex === id
};

View file

@ -157,7 +157,7 @@ define(function (require) {
if (savedVis.id === $route.current.params.id) return;
kbnUrl.change('/visualize/edit/{id}', {id: savedVis.id});
kbnUrl.change('/visualize/edit/{{id}}', {id: savedVis.id});
}, notify.fatal);
};

View file

@ -22,7 +22,7 @@ define(function (require) {
};
this.urlFor = function (id) {
return kbnUrl.eval('#/visualize/edit/{id}', {id: id});
return kbnUrl.eval('#/visualize/edit/{{id}}', {id: id});
};
this.delete = function (ids) {

View file

@ -26,7 +26,7 @@ define(function (require) {
module.controller('VisualizeWizardStep1', function ($route, $scope, $location, timefilter, kbnUrl) {
$scope.step2WithSearchUrl = function (hit) {
return kbnUrl.eval('#/visualize/step/2?savedSearchId={id}', {id: hit.id});
return kbnUrl.eval('#/visualize/step/2?savedSearchId={{id}}', {id: hit.id});
};
timefilter.enabled = false;
@ -38,7 +38,7 @@ define(function (require) {
$scope.$watch('indexPattern.selection', function (pattern) {
if (!pattern) return;
kbnUrl.change('/visualize/step/2?indexPattern={pattern}', {pattern: pattern});
kbnUrl.change('/visualize/step/2?indexPattern={{pattern}}', {pattern: pattern});
});
});

View file

@ -64,7 +64,7 @@ define(function (require) {
$rootScope.$on('$routeChangeStart', reloadingComplete);
function parseUrlPrams(url, paramObj) {
return url.replace(/\{([^\}]+)\}/g, function (match, expr) {
return url.replace(/\{\{([^\}]+)\}\}/g, function (match, expr) {
var key = expr.split('|')[0].trim();
if (_.isUndefined(paramObj[key])) {

View file

@ -137,7 +137,7 @@ define(function (require) {
var params = { replace: faker.Lorem.words(3).join(' ') };
var check = encodeURIComponent(params.replace);
kbnUrl.change(url + '{replace}', params);
kbnUrl.change(url + '{{replace}}', params);
expect(locationUrlSpy.secondCall.args[0]).to.be(url + check);
});
@ -146,7 +146,7 @@ define(function (require) {
// build url by piecing together these parts
var urlParts = ['/', '/', '?', '&', '#'];
// make sure it can parse templates with weird spacing
var wrappers = [ ['{', '}'], ['{ ', ' }'], ['{', ' }'], ['{ ', '}'], ['{ ', ' }']];
var wrappers = [ ['{{', '}}'], ['{{ ', ' }}'], ['{{', ' }}'], ['{{ ', '}}'], ['{{ ', ' }}']];
// make sure filters are evaluated via angular expressions
var objIndex = 4; // used to case one replace as an object
var filters = ['', 'uppercase', '', 'uppercase', 'rison'];
@ -192,7 +192,7 @@ define(function (require) {
});
it('should throw when params are missing', function () {
var url = '/{replace-me}/{but-not-me}';
var url = '/{{replace-me}}/{{but-not-me}}';
var params = {
'replace-me': 'done'
};