Skip to content

Commit

Permalink
Fixed topics display
Browse files Browse the repository at this point in the history
  • Loading branch information
chuanlin2018 committed Jul 24, 2024
1 parent d9d4caf commit b848dfb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
15 changes: 13 additions & 2 deletions angular/src/app/landing/topic/topic.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,24 @@
</button>
</div>

<div *ngIf="scienceThemeTopics.length > 0">
<div *ngFor="let col of collectionOrder; let i =index">
<div *ngIf="topics[col] && topics[col].length > 0">
<strong>{{ allCollections[col].tag }}: </strong>
<span class="topics" *ngFor="let topic of topics[col]; let i =index">
<i>{{ topic }}</i>
<span *ngIf="i < scienceThemeTopics.length-1 ">, </span>
</span> &nbsp; &nbsp;
</div>

</div>

<!-- <div *ngIf="scienceThemeTopics.length > 0">
<strong>{{ allCollections[collection].tag }}: </strong>
<span class="topics" *ngFor="let topic of scienceThemeTopics; let i =index">
<i>{{ topic }}</i>
<span *ngIf="i < scienceThemeTopics.length-1 ">, </span>
</span> &nbsp; &nbsp;
</div>
</div> -->
</span>
</div>
<div *ngIf="mdupdsvc.isEditMode"
Expand Down
33 changes: 18 additions & 15 deletions angular/src/app/landing/topic/topic.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { NerdmRes, NERDResource } from '../../nerdm/nerdm';
import { AppConfig } from '../../config/config';
import { deepCopy } from '../../utils';
import { CollectionService } from '../../shared/collection-service/collection.service';
import { Themes, ThemesPrefs, Collections, Collection, CollectionThemes, FilterTreeNode } from '../../shared/globals/globals';

@Component({
selector: 'app-topic',
Expand All @@ -17,8 +18,11 @@ export class TopicComponent implements OnInit {
nistTaxonomyTopics: any[] = [];
scienceThemeTopics: any[] = [];
recordType: string = "";
standardNISTTaxonomyURI: string = "https://data.nist.gov/od/dm/nist-themes/";
// standardNISTTaxonomyURI: string = "https://data.nist.gov/od/dm/nist-themes/";
allCollections: any = {};
// Array to define the collection order
collectionOrder: string[] = [Collections.DEFAULT];
topics: any = {};

@Input() record: NerdmRes = null;
@Input() inBrowser: boolean; // false if running server-side
Expand All @@ -32,7 +36,10 @@ export class TopicComponent implements OnInit {
public collectionService: CollectionService,
private notificationService: NotificationService) {

this.standardNISTTaxonomyURI = this.cfg.get("standardNISTTaxonomyURI", "https://data.nist.gov/od/dm/nist-themes/");
// this.standardNISTTaxonomyURI = this.cfg.get("standardNISTTaxonomyURI", "https://data.nist.gov/od/dm/nist-themes/");

this.collectionOrder = this.collectionService.getCollectionOrder();
this.allCollections = this.collectionService.loadAllCollections();
}

/**
Expand All @@ -53,9 +60,6 @@ export class TopicComponent implements OnInit {

ngOnInit() {
this.updateResearchTopics();
this.allCollections = this.collectionService.loadAllCollections();
console.log("this.record", this.record);
console.log("this.record.topic", this.record["topic"]);
}

/**
Expand All @@ -77,18 +81,17 @@ export class TopicComponent implements OnInit {
if (this.record['topic']) {
this.record['topic'].forEach(topic => {
if (topic['scheme'] && topic.tag) {
if(topic['scheme'].indexOf(this.standardNISTTaxonomyURI) < 0){
if(this.scienceThemeTopics.indexOf(topic.tag) < 0)
this.scienceThemeTopics.push(topic.tag);
for(let col of this.collectionOrder) {
if(topic['scheme'].indexOf(this.allCollections[col].taxonomyURI) >= 0){
if(!this.topics[col]) {
this.topics[col] = [topic.tag];
}else if(this.topics[col].indexOf(topic.tag) < 0) {
this.topics[col].push(topic.tag);
}
}
}
}
});
}

if (this.record['theme']) {
this.record['theme'].forEach(topic => {
if(this.nistTaxonomyTopics.indexOf(topic) < 0)
this.nistTaxonomyTopics.push(topic);
}
});
}
}
Expand Down

0 comments on commit b848dfb

Please sign in to comment.