Skip to content

Commit

Permalink
Fixed DOM edits for filtering.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Carter committed Feb 6, 2018
1 parent 0fe41f5 commit 26d3ae2
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -5,7 +5,7 @@
"license": "Apache 2.0",
"main": "index.js",
"kibana": {
"version": "5.5.2"
"version": "5.5.3"
},
"scripts": {
"lint": "eslint",
Expand Down
6 changes: 2 additions & 4 deletions public/hacks/field_mapper_hack.js
Expand Up @@ -7,8 +7,7 @@ import { uiModules } from 'ui/modules';

import defaultSettings from './settings/defaults';

let app = uiModules.get('kibana/courier',
'kibana/index_patterns');
let app = uiModules.get('app/kibana', ['kibana/courier']);

/**
* Add an entry to the Advanced Settings table.
Expand All @@ -33,9 +32,8 @@ app.run(function(config) {
});

/**
* Patch 'mapper.getFieldsForIndexPattern' to allow us to insert additional fields.
* Patch 'fieldsFetcher.fetch' to allow us to insert additional fields.
*/

app.run(function(courier, config) {

let indexPatterns = courier.indexPatterns;
Expand Down
2 changes: 0 additions & 2 deletions public/hacks/object_filtering_hack.js
Expand Up @@ -74,8 +74,6 @@ app.run(function(config, Private) {
path = [path, fieldEntry.filterField].join('.');
}

// TODO Validate var field = indexPattern.fields.byName[path];

filters = addFunc.apply(this, [path, entry_values, operation, index]);
}
});
Expand Down
3 changes: 2 additions & 1 deletion public/stringify/object.js
Expand Up @@ -108,7 +108,8 @@ function ObjectFormatProvider(Private) {
_.forEach(val, function(value){
let fieldModels = _get_field_models(value, field, hit, basePath, objectFields);
htmlSnippets.push(vis_template({filtered: fieldModels.filtered,
fields: fieldModels.fields}));
fields: fieldModels.fields,
uid: Math.floor((Math.random() * 1000000) + 1)}));
});

return htmlSnippets.join('\n');
Expand Down
45 changes: 29 additions & 16 deletions public/stringify/templates/object_format.html
@@ -1,7 +1,7 @@
<% if (!filtered) { %>
<table class="object-table object-table-no-filter">
<table class="object-table object-table-no-filter <%= uid %>">
<% } else { %>
<table class="object-table">
<table class="object-table <%= uid %>">
<% } %>
<tbody>
<%
Expand All @@ -22,24 +22,37 @@
</table>
<!-- [object field formatter] Change the 'white-space' css attribute of our containing div, and remove the warning icon -->
<script>
var parent = $("table.object-table").parent().parent()
parent.css("white-space", "nowrap");
// Run this after angular has done it's thing
setTimeout(() => {
// Discover table row
$(".<%= uid %>").closest(".truncate-by-height").css("white-space", "nowrap");

if (parent.hasClass("doc-viewer-value")) {
var siblings = parent.siblings("i.fa-warning")
if (siblings) {
siblings.remove();
}
}
// Discover expanded row table
$(".<%= uid %>").closest("div.doc-viewer-value").css("white-space", "nowrap");
$(".<%= uid %>").closest("div.doc-viewer-value").siblings("i.fa-warning").remove();
}, 0);
</script>
<!-- [object field formatter] Hide the filter buttons if this formatter doesn't have filtering enabled -->
<script>
var parent = $("table.object-table-no-filter").parent().parent().parent()
// Run this after angular has done it's thing
setTimeout(() => {
// Discover table row
$(".object-table-no-filter.<%= uid %>")
.closest("td.discover-table-datafield")
.children(".table-cell-filter")
.empty();

// Discover expanded row table
var buttonsCell = $(".object-table-no-filter.<%= uid %>")
.closest("div.doc-viewer-value")
.closest("td")
.siblings("td.doc-viewer-buttons");

if (parent.hasClass("discover-table-datafield")) {
var cell_filter = parent.children(".table-cell-filter")
if (cell_filter) {
cell_filter.empty();
if (buttonsCell) {
var span = buttonsCell.children("span:has(i.fa-search-plus)");
span.replaceWith(
"<span><i class=\"fa fa-search-plus text-muted\"></i><i class=\"fa fa-search-minus text-muted\"></span>"
);
}
}
}, 0);
</script>

0 comments on commit 26d3ae2

Please sign in to comment.