mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[fieldFormats] shorten #defaultFor() to #for()
This commit is contained in:
parent
60d05b39e5
commit
32a0dbb663
6 changed files with 8 additions and 12 deletions
|
@ -27,7 +27,7 @@ define(function (require) {
|
|||
if (field && field.type === 'date' && field.format) {
|
||||
return field.format;
|
||||
} else {
|
||||
return fieldFormats.converterFor('number');
|
||||
return fieldFormats.for('number');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ define(function (require) {
|
|||
var type = fieldTypes.byName[spec.type];
|
||||
if (!type) throw new TypeError('unknown field type :' + spec.type);
|
||||
|
||||
var format = fieldFormats.byName[spec.formatName] || fieldFormats.defaultFor(spec.type);
|
||||
var format = fieldFormats.byName[spec.formatName] || fieldFormats.for(spec.type);
|
||||
var indexed = !!spec.indexed;
|
||||
var scripted = !!spec.scripted;
|
||||
var sortable = indexed && type.sortable;
|
||||
|
|
|
@ -270,7 +270,7 @@ define(function (require) {
|
|||
AggConfig.prototype.fieldFormatter = function () {
|
||||
var field = this.field();
|
||||
var format = field && field.format;
|
||||
var strFormat = fieldFormats.defaultByType.string;
|
||||
var strFormat = fieldFormats.for('string');
|
||||
|
||||
if (this.type.getFormat) {
|
||||
format = this.type.getFormat(this) || format;
|
||||
|
|
|
@ -8,7 +8,7 @@ define(function (require) {
|
|||
|
||||
return function ($parent, $scope, field) {
|
||||
$scope.field = field;
|
||||
$scope.defaultFormatName = fieldFormats.defaultFor(field.type).name;
|
||||
$scope.defaultFormatName = fieldFormats.for(field.type).name;
|
||||
$scope.formatOptionNames = [DEFAULT].concat(
|
||||
_.pluck(fieldFormats.byFieldType[field.type], 'name')
|
||||
);
|
||||
|
@ -34,4 +34,4 @@ define(function (require) {
|
|||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
});
|
||||
|
|
|
@ -13,14 +13,10 @@ define(function (require) {
|
|||
|
||||
|
||||
constructor: function (config) {
|
||||
this.defaultFor = function (type, fallbackFormat) {
|
||||
this.for = function (type, fallbackFormat) {
|
||||
var name = config.get('defaultFormat:' + type);
|
||||
return this.byName[name] || (fallbackFormat || defaultFallbackFormat);
|
||||
};
|
||||
|
||||
this.converterFor = function (type) {
|
||||
return this.defaultFor(type).convert;
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ define(function (require) {
|
|||
Object.defineProperty(field, 'format', {
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
return fieldFormats.defaultFor(field.type);
|
||||
return fieldFormats.for(field.type);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue