Skip to content

Commit

Permalink
Don't credit admins when there's no annotation
Browse files Browse the repository at this point in the history
Fixes the case where there is a HTP datasey from a community curator
but there's no other annotation.  We were showing "Curated by PomBase staff"

Refs #525
  • Loading branch information
kimrutherford committed Oct 23, 2023
1 parent fb099ce commit be9179f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/app/reference-details/reference-details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
Curation by {{curator.name}}
</div>
</div>
<div class="ref-curated-by" *ngIf="onlyStaffCurator && !this.appConfig.show_names_of_staff_curators">
<div class="ref-curated-by" *ngIf="!hasCommunityCurator() && hasAdminCurator() && !this.appConfig.show_names_of_staff_curators">
Curated by {{siteName}} staff
</div>
<div class="ref-curated-by" *ngIf="communityFileCuratorNames">
Expand Down
59 changes: 37 additions & 22 deletions src/app/reference-details/reference-details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export class ReferenceDetailsComponent implements OnInit {
pubMedId?: string;
apiError?: APIError;
cantoCuratorName?: string;
onlyStaffCurator = false;
onlyStaffFileCurator = false;
cantoTriageStatus = 'UNKNOWN';

multiOrgMode = getAppConfig().isMultiOrganismMode();
Expand All @@ -42,7 +40,9 @@ export class ReferenceDetailsComponent implements OnInit {
communityFileCuratorNames?: string;

adminCuratorList: Array<AnnotationCurator> = [];
communityCuratorList: Array<AnnotationCurator> = [];
adminFileCuratorList: Array<AnnotationCurator> = [];
communityFileCuratorList: Array<AnnotationCurator> = [];

externalLinks?: Array<DetailsPageLinkConfig>;

Expand All @@ -68,62 +68,77 @@ export class ReferenceDetailsComponent implements OnInit {
this.meta.updateTag({property: 'description', content: title});
}

hasCommunityCurator(): boolean {
return this.communityCuratorList.length > 0;
}

hasAdminCurator(): boolean {
return this.adminCuratorList.length > 0;
}

hasFileCommunityCurator(): boolean {
return this.communityFileCuratorList.length > 0;
}

hasFileAdminCurator(): boolean {
return this.adminFileCuratorList.length > 0;
}

setCantoFields(): void {
this.cantoCuratorName = undefined;

this.cantoTriageStatus = this.refDetails.canto_triage_status;

this.onlyStaffCurator = true;

this.communityCuratorNames = undefined;
this.adminCuratorList = [];

let communityCuratorList = [];
this.communityCuratorList = [];

for (const curator of this.refDetails.annotation_curators) {
if (curator.community_curator) {
communityCuratorList.push(curator.name);
this.onlyStaffCurator = false
this.communityCuratorList.push(curator);
} else {
if (this.appConfig.show_names_of_staff_curators) {
this.adminCuratorList.push(curator);
}
}
}

if (communityCuratorList.length == 1) {
this.communityCuratorNames = communityCuratorList[0];
if (this.communityCuratorList.length == 1) {
this.communityCuratorNames = this.communityCuratorList[0].name;
} else {
if (communityCuratorList.length > 1) {
const lastName = communityCuratorList.pop();
this.communityCuratorNames = communityCuratorList.join(', ') + ' and ' + lastName;
if (this.communityCuratorList && this.communityCuratorList.length > 1) {
const lastName = this.communityCuratorList.pop()!.name;
this.communityCuratorNames = this.communityCuratorList
.map(curator => curator.name)
.join(', ') + ' and ' + lastName;
}
}

this.onlyStaffFileCurator = true;

this.communityFileCuratorNames = undefined;
this.adminFileCuratorList = [];

let communityFileCuratorList = [];
this.communityFileCuratorList = [];

for (const curator of this.refDetails.annotation_file_curators) {
if (curator.community_curator) {
communityFileCuratorList.push(curator.name);
this.onlyStaffFileCurator = false
this.communityFileCuratorList.push(curator);

} else {
if (this.appConfig.show_names_of_staff_file_curators) {
this.adminFileCuratorList.push(curator);
}
}
}

if (communityFileCuratorList.length == 1) {
this.communityFileCuratorNames = communityFileCuratorList[0];
if (this.communityFileCuratorList.length == 1) {
this.communityFileCuratorNames = this.communityFileCuratorList[0].name;
} else {
if (communityFileCuratorList.length > 1) {
const lastName = communityFileCuratorList.pop();
this.communityFileCuratorNames = communityFileCuratorList.join(', ') + ' and ' + lastName;
if (this.communityFileCuratorList.length > 1) {
const lastName = this.communityFileCuratorList.pop()?.name;
this.communityFileCuratorNames = this.communityFileCuratorList
.map(curator => curator.name)
.join(', ') + ' and ' + lastName;
}
}
}
Expand Down

0 comments on commit be9179f

Please sign in to comment.