Skip to content

Commit

Permalink
Merge pull request #720 from griffithlab/source_link
Browse files Browse the repository at this point in the history
Add sources as a supported entity to tag linking in comments
  • Loading branch information
acoffman authored Feb 2, 2023
2 parents 8482847 + 060a12c commit 075b724
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<span *ngSwitchCase="'MOLECULAR_PROFILE'">
<cvc-molecular-profile-tag [molecularProfile]="{id: c.entityId, name: c.displayName, link: c.link, deprecated: c.deprecated}"></cvc-molecular-profile-tag>
</span>
<span *ngSwitchCase="'SOURCE'">
<cvc-source-tag [source]="{id: c.entityId, displayName: c.displayName, link: c.link}"></cvc-source-tag>
</span>
<span *ngSwitchCase="'ROLE'">
<nz-tag><i nz-icon
nzType="civic-{{c.displayName.slice(0, -1)}}" nzTheme="twotone" nzTwotoneColor="#A0D8F5"></i> {{c.displayName}}</nz-tag>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { CvcOrganizationTagModule } from '@app/components/organizations/organiza
import { NzTagModule } from 'ng-zorro-antd/tag';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { CvcMolecularProfileTagModule } from '@app/components/molecular-profiles/molecular-profile-tag/molecular-profile-tag.module';
import { CvcSourceTagModule } from '@app/components/sources/source-tag/source-tag.module';

@NgModule({
declarations: [CvcCommentBodyComponent],
Expand All @@ -27,7 +28,8 @@ import { CvcMolecularProfileTagModule } from '@app/components/molecular-profiles
CvcGeneTagModule,
CvcUserTagModule,
CvcOrganizationTagModule,
CvcMolecularProfileTagModule
CvcMolecularProfileTagModule,
CvcSourceTagModule,
],
exports: [CvcCommentBodyComponent]
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export class IconNameForSubscribableEntity implements PipeTransform {
case 'MOLECULAR_PROFILE':
case 'MolecularProfile':
return 'civic-molecularprofile';
case 'SOURCE':
case 'Source':
return 'civic-source';
default:
console.log('String No icon name found for ' + e);
return 'border-outer';
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/forms/comment-input/comment-input.form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ export class CvcCommentInputForm implements OnDestroy, OnChanges {
return `RID${id}`;
case TaggableEntity.MolecularProfile:
return `MPID${id}`
case TaggableEntity.Source:
return `SID${id}`
case TaggableEntity.Role:
return Object.keys(UserRole)[id];
}
Expand Down
1 change: 1 addition & 0 deletions client/src/app/generated/civic.apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4389,6 +4389,7 @@ export enum TaggableEntity {
MolecularProfile = 'MOLECULAR_PROFILE',
Revision = 'REVISION',
Role = 'ROLE',
Source = 'SOURCE',
Variant = 'VARIANT',
VariantGroup = 'VARIANT_GROUP'
}
Expand Down
1 change: 1 addition & 0 deletions client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7246,6 +7246,7 @@ enum TaggableEntity {
MOLECULAR_PROFILE
REVISION
ROLE
SOURCE
VARIANT
VARIANT_GROUP
}
Expand Down
6 changes: 6 additions & 0 deletions client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -30827,6 +30827,12 @@
"description": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "SOURCE",
"description": null,
"isDeprecated": false,
"deprecationReason": null
}
],
"possibleTypes": null
Expand Down
1 change: 1 addition & 0 deletions server/app/graphql/types/commentable/taggable_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ class TaggableEntity < Types::BaseEnum
value 'REVISION'
value 'ROLE'
value 'MOLECULAR_PROFILE'
value 'SOURCE'
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def prepare
Revision
when 'MOLECULAR_PROFILE'
MolecularProfile
when 'SOURCE'
Source
else
#it was a role
nil
Expand Down
2 changes: 1 addition & 1 deletion server/app/graphql/types/queries/typeahead_queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def self.included(klass)
description "Retrieve entity type typeahead fields for a entity mention search term."
argument :query_term, GraphQL::Types::String, required: true
end

klass.field :acmg_codes_typeahead, [Types::Entities::AcmgCodeType], null: false do
description "Retrieve ACMG Code options as a typeahead"
argument :query_term, GraphQL::Types::String, required: true
Expand Down
10 changes: 6 additions & 4 deletions server/app/models/actions/extract_references.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def self.status_value_for_referenced_entity(item)
nil
end
end

def self.deprecation_value_for_referenced_entity(item)
if item.is_a?(Variant) || item.is_a?(MolecularProfile)
item.deprecated
Expand All @@ -72,7 +72,7 @@ def self.typeahead_matches(query_term)
display_name: referenced_item.respond_to?(:display_name) ? referenced_item.display_name : referenced_item.name,
tag_type: tag_type,
status: status_value_for_referenced_entity(referenced_item),
deprecated: self.class.deprecation_value_for_referenced_entity(referenced_item),
deprecated: deprecation_value_for_referenced_entity(referenced_item),
}
end
else
Expand All @@ -99,15 +99,17 @@ def self.extract_type(type)
[Assertion, 'ASSERTION']
when 'MP'
[MolecularProfile, 'MOLECULAR_PROFILE']
when 'S'
[Source, 'SOURCE']
end
end

def self.split_regex
@split_regex ||= Regexp.new(/\s*(#(?:a|v|g|vg|e|r|mp)(?:id)?\d+)\b/i)
@split_regex ||= Regexp.new(/\s*(#(?:a|v|g|vg|e|r|mp|s)(?:id)?\d+)\b/i)
end

def self.scan_regex
@scan_regex ||= Regexp.new(/#(?<type>a|v|g|vg|e|r|mp)(?:id)?(?<id>\d+)\b/i)
@scan_regex ||= Regexp.new(/#(?<type>a|v|g|vg|e|r|mp|s)(?:id)?(?<id>\d+)\b/i)
end
end
end

0 comments on commit 075b724

Please sign in to comment.