From 1078fae0d4f97de911ac89ef665a7c1cde12c946 Mon Sep 17 00:00:00 2001 From: Shane Wilson Date: Tue, 26 Apr 2016 15:32:42 -0400 Subject: [PATCH] fix(components): handle empty fields in gql/facets Closes #2126, #2124 --- app/scripts/components/facets/facets.controllers.ts | 1 + app/scripts/components/gql/gql.filters.ts | 2 +- app/scripts/components/gql/module.ts | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/scripts/components/facets/facets.controllers.ts b/app/scripts/components/facets/facets.controllers.ts index 8df7965f1..92a07f4dd 100644 --- a/app/scripts/components/facets/facets.controllers.ts +++ b/app/scripts/components/facets/facets.controllers.ts @@ -515,6 +515,7 @@ module ngApp.components.facets.controllers { addFacet() { var selectedField = this.$scope.filteredFields[this.selectedIndex]; + if (!selectedField) return; var fileOptions = { fields: [], expand: [], diff --git a/app/scripts/components/gql/gql.filters.ts b/app/scripts/components/gql/gql.filters.ts index d2052843d..1193aa867 100644 --- a/app/scripts/components/gql/gql.filters.ts +++ b/app/scripts/components/gql/gql.filters.ts @@ -3,7 +3,7 @@ module ngApp.components.gql.filters { class GqlHighlight { constructor() { return function (value: string, query: string): string { - return value.replace(query, '' + query + ''); + return (value || '').replace(query, '' + query + ''); }; } } diff --git a/app/scripts/components/gql/module.ts b/app/scripts/components/gql/module.ts index 001b8bf8a..658616229 100644 --- a/app/scripts/components/gql/module.ts +++ b/app/scripts/components/gql/module.ts @@ -151,7 +151,7 @@ module ngApp.components.gql { if (parts.docType === "files") { return this.FilesService.getFiles(params) .then((fs: IFiles): IDdItem[] => { - var f: IFacet = fs.aggregations[parts.facet]; + var f: IFacet = (fs.aggregations || {})[parts.facet] || []; return _.map(f.buckets, (b) => { return {field: b.key, full: b.key}; }); @@ -159,7 +159,7 @@ module ngApp.components.gql { } else { return this.ParticipantsService.getParticipants(params) .then((fs: IParticipants): IDdItem[] => { - var f: IFacet = fs.aggregations[parts.facet]; + var f: IFacet = (fs.aggregations || {})[parts.facet] || []; return _.map(f.buckets, (b) => { return {field: b.key, full: b.key}; });