Skip to content

Commit

Permalink
Color field format should apply to the whole cell in data table elast…
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre committed Oct 16, 2018
1 parent 8fe71f8 commit 9953d6c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/core_plugins/kibana/common/field_formats/types/color.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import _ from 'lodash';
import { asPrettyString } from '../../utils/as_pretty_string';
import { DEFAULT_COLOR } from './color_default';

const convertTemplate = _.template('<span style="<%- style %>"><%- val %></span>');
const convertTemplate = _.template('<div style="<%- style %>"><%- val %></div>');

export function createColorFormat(FieldFormat) {
class ColorFormat extends FieldFormat {
getParamDefaults() {
return {
fieldType: null, // populated by editor, see controller below
isHtmlFormatter: true, // do not truncate this type of formatter in table cell
colors: [_.cloneDeep(DEFAULT_COLOR)]
};
}
Expand Down
9 changes: 8 additions & 1 deletion src/ui/public/doc_table/components/table_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,16 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl
*/
function _displayField(row, fieldName, truncate) {
const indexPattern = $scope.indexPattern;

// Some fields formatter returned value is
// HTML and MUST not be truncated based on formatted text length
const fieldFormat = indexPattern.fieldFormatMap[fieldName];
const isHtmlFormatter = fieldFormat !== undefined &&
fieldFormat.getParamDefaults().isHtmlFormatter === true;

const text = indexPattern.formatField(row, fieldName);

if (truncate && text.length > MIN_LINE_LENGTH) {
if (!isHtmlFormatter && truncate && text.length > MIN_LINE_LENGTH) {
return truncateByHeightTemplate({
body: text
});
Expand Down

0 comments on commit 9953d6c

Please sign in to comment.