Skip to content

Commit 924a10b

Browse files
committed
Merge branch 'integration' into fix/ODD769-appletouch-icon
2 parents 321b705 + 9f2955c commit 924a10b

2 files changed

Lines changed: 58 additions & 69 deletions

File tree

angular/src/app/search/search.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('SearchComponent', () => {
4949

5050
it('should filter the results by components', (() => {
5151
let results = searchCompService.filterByComponents(searchResults, ['Data File']);
52-
expect(results.length).toBe(1);
52+
expect(results.length).toBe(2);
5353
})
5454
);
5555

angular/src/app/search/search.component.ts

Lines changed: 57 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -296,32 +296,32 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
296296
collectComponents(searchResults: any[]) {
297297
let components: SelectItem[] = [];
298298
let componentsArray: string[] = [];
299-
let componentsAllArray: string[] = [];
300-
let resultItemComp: string[] = [];
301-
let comp: any[] = [];
302299
let compType: string;
303300
this.componentsAllArray = [];
301+
304302
for (let resultItem of searchResults) {
305-
if (resultItem.inventory && resultItem.inventory !== null && resultItem.inventory.length > 0) {
303+
if(resultItem['components'] != null && resultItem['components'] != undefined && resultItem['components'].length > 0){
306304
this.uniqueComp = [];
307-
for (let resultItemComponents of resultItem.inventory) {
308-
comp = resultItemComponents.byType;
309-
for (let type of comp) {
310-
let compType = type.forType;
311-
if ((_.includes(compType, 'nrdp'))) {
312-
//this.componentsAllArray.push(_.startCase(_.split(compType, ':')[1]));
313-
this.uniqueComp.push(_.startCase(_.split(compType, ':')[1]));
314-
if (componentsArray.indexOf(compType) < 0) {
305+
let allcomponents = resultItem['components'];
306+
for(let component of allcomponents){
307+
let resTypeArray = component['@type'];
308+
for (var i = 0; i < resTypeArray.length; i++) {
309+
compType = _.startCase(_.split(resTypeArray[i], ':')[1])
310+
if(this.uniqueComp.indexOf(compType) < 0)
311+
this.uniqueComp.push(compType);
312+
313+
if(compType != null && compType != undefined && _.includes(resTypeArray[i], 'nrdp')){
314+
if (componentsArray.indexOf(resTypeArray[i]) < 0) {
315315
components.push({
316-
label: _.startCase(_.split(compType, ':')[1]),
317-
value: _.startCase(_.split(compType, ':')[1])
316+
label: compType,
317+
value: compType
318318
});
319-
componentsArray.push(compType);
319+
componentsArray.push(resTypeArray[i]);
320320
}
321-
}
321+
}
322322
}
323-
this.uniqueComp = this.uniqueComp.filter(this.onlyUnique);
324323
}
324+
325325
for (let comp of this.uniqueComp) {
326326
this.componentsAllArray.push(comp);
327327
}
@@ -338,9 +338,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
338338
collectResourceTypes(searchResults: any[]) {
339339
let resourceTypes: SelectItem[] = [];
340340
let resourceTypesArray: string[] = [];
341-
let resourceTypesAllArray: string[] = [];
342-
let resultItemResourceType: string[] = [];
343-
let res: any[] = [];
344341
let resType: string;
345342
this.resourceTypesAllArray = [];
346343
for (let resultItem of searchResults) {
@@ -377,6 +374,14 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
377374
authors.push(resultItem.contactPoint.fn);
378375
}
379376
}
377+
378+
if(resultItem.authors && resultItem.authors != null && resultItem.authors.length > 0){
379+
for(let author of resultItem.authors){
380+
if (authors.indexOf(author.fn) < 0) {
381+
authors.push(author.fn);
382+
}
383+
}
384+
}
380385
}
381386
return authors;
382387
}
@@ -505,8 +510,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
505510
this.noResults = false;
506511
this.keyword = '';
507512
let that = this;
508-
let searchPhraseValue = '';
509-
let searchKeyValue = '';
510513

511514
return this.searchService.searchPhrase(this.searchValue, this.searchTaxonomyKey, queryAdvSearch)
512515
.subscribe(
@@ -515,17 +518,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
515518
},
516519
error => that.onError(error)
517520
);
518-
519-
// return this.searchService.searchPhrase(this.searchValue, this.searchTaxonomyKey, queryAdvSearch)
520-
// .subscribe(
521-
// searchResults => {
522-
// console.log("searchResults:");
523-
// console.log(JSON.stringify(searchResults));
524-
// that.onSuccess(searchResults.ResultData);
525-
// },
526-
// error => that.onError(error)
527-
// );
528-
529521
}
530522

531523
doSearch(searchValue: string, searchTaxonomyKey: string, queryAdvSearch: string) {
@@ -557,7 +549,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
557549
}
558550
}, 2000);
559551
setTimeout(() => {
560-
// this.filterResults('','');
561552
this.searching = false;
562553
}, 10000)
563554

@@ -765,22 +756,20 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
765756

766757
if (selectedComponents.length > 0) {
767758
if (searchResults !== null && searchResults.length > 0) {
768-
let components: SelectItem[] = [];
769-
let componentsArray: string[] = [];
770-
let resultItemComp: string[] = [];
759+
let compType: string = "";
760+
771761
for (let resultItem of searchResults) {
772-
if (resultItem.inventory && resultItem.inventory !== null && resultItem.inventory.length > 0) {
773-
for (let resultItemComponents of resultItem.inventory) {
774-
let comp = resultItemComponents.byType;
775-
if (comp !== null) {
776-
for (let type of comp) {
777-
let compType = type.forType;
778-
compType = _.startCase(_.split(compType, ':')[1]);
779-
for (let comps of selectedComponents) {
780-
if (comps !== null) {
781-
if (compType.indexOf(comps) === 0) {
782-
filteredResults.push(resultItem);
783-
}
762+
if(resultItem['components'] != null && resultItem['components'] != undefined && resultItem['components'].length > 0){
763+
let allcomponents = resultItem['components'];
764+
for(let component of allcomponents){
765+
let resTypeArray = component['@type'];
766+
for (var i = 0; i < resTypeArray.length; i++) {
767+
compType = _.startCase(_.split(resTypeArray[i], ':')[1])
768+
769+
for (let comps of selectedComponents) {
770+
if (comps !== null) {
771+
if (compType.indexOf(comps) === 0) {
772+
filteredResults.push(resultItem);
784773
}
785774
}
786775
}
@@ -803,9 +792,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
803792

804793
if (this.selectedResourceType.length > 0) {
805794
if (searchResults !== null && searchResults.length > 0) {
806-
let resourceTypes: SelectItem[] = [];
807-
let resourceTypesArray: string[] = [];
808-
let resultItemRes: string[] = [];
809795
for (let resultItem of searchResults) {
810796
let resTypeArray: string[];
811797
resTypeArray = resultItem['@type']
@@ -834,8 +820,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
834820
var filteredResults: any[] = [];
835821
if (typeof selectedThemes !== 'undefined') {
836822
if (searchResults !== null && searchResults.length > 0) {
837-
let themes: SelectItem[] = [];
838-
let resultItemThemes: string[] = [];
839823
for (let resultItem of searchResults) {
840824
if (resultItem.topic && resultItem.topic !== null && resultItem.topic.length > 0) {
841825
for (let resultItemThemes of resultItem.topic) {
@@ -878,6 +862,13 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
878862
this.containsAllAuthors(resultItem.contactPoint.fn, selectedAuthor)) {
879863
filteredResults.push(resultItem);
880864
}
865+
866+
if (resultItem.authors && resultItem.authors !== null){
867+
for(let author of resultItem.authors){
868+
if(this.containsAllAuthors(author.fn, selectedAuthor))
869+
filteredResults.push(resultItem);
870+
}
871+
}
881872
}
882873
}
883874
return filteredResults;
@@ -925,9 +916,7 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
925916
// Resource types selected
926917
if (typeof this.selectedResourceTypeNode != 'undefined') {
927918
if (this.selectedResourceTypeNode != null && this.selectedResourceTypeNode.length > 0) {
928-
console.log("this.selectedResourceTypeNode", this.selectedResourceTypeNode);
929919
for (let res of this.selectedResourceTypeNode) {
930-
console.log("res", res);
931920
if (typeof res.data !== 'undefined' && res.data !== 'undefined') {
932921
resourceTypesSelected = true;
933922
this.selectedResourceType.push(res.data);
@@ -996,8 +985,8 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
996985
}
997986
}
998987
// Resource Features selected
999-
if (typeof this.selectedComponentsNode != 'undefined') {
1000-
if (this.selectedComponentsNode != null && this.selectedComponentsNode.length > 0) {
988+
if (typeof this.selectedComponentsNode != 'undefined' && this.selectedComponentsNode[0] != undefined) {
989+
if (this.selectedComponentsNode != null && this.selectedComponentsNode != undefined && this.selectedComponentsNode.length > 0) {
1001990
for (let comp of this.selectedComponentsNode) {
1002991
if (typeof comp.data !== 'undefined' && comp.data !== 'undefined') {
1003992
componentSelected = true;
@@ -1030,6 +1019,7 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
10301019
}
10311020
}
10321021

1022+
// Authors and contributors
10331023
if (typeof this.selectedAuthor != 'undefined') {
10341024
if (this.selectedAuthor !== null && this.selectedAuthor.length > 0) {
10351025
authorSelected = true;
@@ -1057,7 +1047,7 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
10571047
}
10581048
}
10591049

1060-
1050+
// Keywords
10611051
if (typeof this.selectedKeywords != 'undefined') {
10621052
if (this.selectedKeywords !== null && this.selectedKeywords.length > 0) {
10631053
keywordSelected = true;
@@ -1084,6 +1074,7 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
10841074
}
10851075
}
10861076

1077+
// If nothing selected
10871078
if (!themeSelected && !componentSelected && !authorSelected && !keywordSelected && !resourceTypesSelected) {
10881079
this.filteredResults = this.searchResults;
10891080
this.suggestedThemes = [];
@@ -1107,6 +1098,8 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
11071098
this.resourceTypes = this.collectResourceTypes(this.filteredResults);
11081099
this.collectResourceTypesWithCount();
11091100
}
1101+
1102+
// If component count is zero
11101103
if (_.isEmpty(this.componentsWithCount)) {
11111104
compNoData = true;
11121105
this.componentsWithCount = [];
@@ -1129,7 +1122,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
11291122
}
11301123
this.themesTree[0].children = this.themesWithCount;
11311124

1132-
11331125
if (event) {
11341126
//window.history.replaceState(null, null, "/search?page=4");
11351127
let params = new URLSearchParams();
@@ -1320,7 +1312,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
13201312
*/
13211313
toSortItems(fields: any[]) {
13221314
this.fieldsArray = fields;
1323-
let items: SelectItem[] = [];
13241315
let sortItems: SelectItem[] = [];
13251316
this.displayFields = [];
13261317
//for (let field of fields) {
@@ -1343,7 +1334,6 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
13431334
}
13441335

13451336
SortByFields() {
1346-
let sortField: string[] = [];
13471337
this.filteredResults = _.sortBy(this.filteredResults, this.sortItemKey);
13481338
for (let field of this.fieldsArray) {
13491339
if (field.name === this.sortItemKey) {
@@ -1464,14 +1454,11 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
14641454
this.searchValue = this.searchValue.replace(/\&logicalOp=AND&/g, ' and ');
14651455
}
14661456
this.doSearch(this.searchValue, this.searchTaxonomyKey, this.queryAdvSearch);
1467-
// console.log('authors inside init: ' + params['authors']);
14681457
});
14691458
}
14701459

14711460
setResourceTypeSelection(node: TreeNode, resType: string) {
14721461
let resTypeParam = resType.toString().split(',');
1473-
console.log("this.resourceTypesWithCount", this.resourceTypesWithCount);
1474-
console.log("this.selectedResourceTypeNode", this.selectedResourceTypeNode);
14751462

14761463
for (var i = 0; i < this.resourceTypesWithCount.length; i++) {
14771464
if (resTypeParam.includes(this.resourceTypeTree[0].children[i].data)) {
@@ -1503,9 +1490,11 @@ export class SearchPanelComponent implements OnInit, OnDestroy {
15031490
}
15041491

15051492
setAuthorsSelection(authors: string) {
1506-
let authorsParam = authors.toString().split(',');
1507-
for (var i = 0; i < authorsParam.length; i++) {
1508-
this.selectedAuthor.push(authorsParam[i]);
1493+
if(this.selectedAuthor != undefined){
1494+
let authorsParam = authors.toString().split(',');
1495+
for (var i = 0; i < authorsParam.length; i++) {
1496+
this.selectedAuthor.push(authorsParam[i]);
1497+
}
15091498
}
15101499
}
15111500

0 commit comments

Comments
 (0)