Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BI-1614] - Add Term Type to Ontology Term display and form #284

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/breeding-insight/model/Sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ export enum OntologySortField {
MethodDescription = 'methodDescription',
ScaleClass = 'scaleClass',
ScaleName = 'scaleName',
entityAttributeSortLabel = 'entityAttribute'
entityAttributeSortLabel = 'entityAttribute',
TermType = 'termType'
}

export class OntologySort {
Expand Down
6 changes: 5 additions & 1 deletion src/breeding-insight/model/Trait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import {ProgramObservationLevel} from "@/breeding-insight/model/ProgramObservationLevel";
import {Method} from "@/breeding-insight/model/Method";
import {Scale} from "@/breeding-insight/model/Scale";
import {TermType} from "@/breeding-insight/model/TraitSelector";

export class Trait {
id?: string;
Expand All @@ -35,6 +36,7 @@ export class Trait {
tags?: string[] = [];
fullName?: string;
isDup?: boolean;
termType?: TermType;

constructor(id?: string,
traitName?: string,
Expand All @@ -50,6 +52,7 @@ export class Trait {
tags?: string[],
fullName?: string,
isDup?: boolean,
termType?: TermType
) {
this.id = id;
this.traitName = traitName;
Expand Down Expand Up @@ -89,7 +92,7 @@ export class Trait {

static assign(trait: Trait): Trait {
return new Trait(trait.id, trait.traitName, trait.observationVariableName, trait.programObservationLevel, trait.entity, trait.attribute,
trait.traitDescription, trait.method, trait.scale, trait.synonyms, trait.active, trait.tags, trait.fullName, trait.isDup);
trait.traitDescription, trait.method, trait.scale, trait.synonyms, trait.active, trait.tags, trait.fullName, trait.isDup, trait.termType);
}

checkStringListEquals(list: string[] | undefined, otherList: string[] | undefined): boolean {
Expand All @@ -111,6 +114,7 @@ export class Trait {
(this.traitName === trait.traitName) &&
(this.observationVariableName === trait.observationVariableName) &&
(this.fullName === trait.fullName) &&
(this.termType === trait.termType) &&
(this.checkStringListEquals(this.synonyms, trait.synonyms)) &&
(this.mainAbbreviation === trait.mainAbbreviation) &&
(this.entity === trait.entity) &&
Expand Down
6 changes: 6 additions & 0 deletions src/breeding-insight/model/TraitSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ export enum TraitField {
UPDATED_BY_USER_NAME = 'updatedByUserName'
}

export enum TermType {
PHENOTYPE = 'Phenotype',
GERM_ATTRIBUTE = 'Germplasm Attribute',
GERM_PASSPORT = 'Germplasm Passport'
}

export class TraitFilter {
field?: TraitField;
value?: string | number | boolean;
Expand Down
13 changes: 13 additions & 0 deletions src/components/ontology/OntologyTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,18 @@
>
{{ data.observationVariableName }}
</TableColumn>
<TableColumn
name="termType"
v-bind:label="'Term Type'"
v-bind:sortField="ontologySort.field"
v-bind:sortFieldLabel="termTypeSortLabel"
v-bind:sortable="true"
v-bind:sortOrder="ontologySort.order"
v-on:newSortColumn="$emit('newSortColumn', $event)"
v-on:toggleSortOrder="$emit('toggleSortOrder')"
>
{{ data.termType }}
</TableColumn>
<TableColumn
name="trait"
v-bind:label="'Trait'"
Expand Down Expand Up @@ -314,6 +326,7 @@ export default class OntologyTable extends Vue {
private scaleClassSortLabel: string = OntologySortField.ScaleClass;
private unitSortLabel: string = OntologySortField.ScaleName;
private entityAttributeSortLabel: string = OntologySortField.entityAttributeSortLabel;
private termTypeSortLabel: string = OntologySortField.TermType;

// New trait form
private newTraitActive: boolean = false;
Expand Down
10 changes: 10 additions & 0 deletions src/components/trait/TraitDetailPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
<span class="is-size-7 mb-0">{{data.traitDescription}}</span>
</div>
</div>

<div v-if="data.termType" class="columns is-desktop pt-1 pl-3">
<div class="column is-one-third pt-0 pb-0 has-text-right-desktop">
<span class="has-text-weight-bold">Term Type</span>
</div>
<div class="column pt-0 pb-0">
<span class="is-size-7 mb-0">{{data.termType}}</span>
</div>
</div>

<!-- just shows first abbreviation AKA main abbreviation and first synonym -->
<template v-if="abbreviationsSynonymsString">
<div class="columns is-desktop pt-1 pl-3">
Expand Down
34 changes: 29 additions & 5 deletions src/components/trait/forms/BaseTraitForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@
<label for="newTermActiveToggle" class="is-pulled-right">{{trait.active ? 'Active' : 'Archived'}}</label>
</div>

<!-- term type -->
<div class="column is-2">
<span class="is-pulled-right required new-term pb-2 pr-3">Term Type</span>
</div>
<div class="column new-term is-10">
<BasicSelectField
class="pb-2"
v-bind:selected-id="trait.termType"
v-bind:options="termTypes"
v-bind:field-name="'Term Type'"
v-bind:show-label="false"
v-on:input="setTermType($event)"
/>
</div>

<!-- term name-->
<div class="column is-2">
<span class="is-pulled-right required new-term pb-2 pr-3">Name</span>
Expand Down Expand Up @@ -265,22 +280,22 @@ import BasicInputField from "@/components/forms/BasicInputField.vue";
import BasicSelectField from "@/components/forms/BasicSelectField.vue";
import {Trait} from "@/breeding-insight/model/Trait";
import {Method, MethodClass} from "@/breeding-insight/model/Method";
import { Scale, DataType } from '@/breeding-insight/model/Scale';
import { ProgramObservationLevel } from '@/breeding-insight/model/ProgramObservationLevel';
import {DataType, Scale} from '@/breeding-insight/model/Scale';
import {ProgramObservationLevel} from '@/breeding-insight/model/ProgramObservationLevel';
import OrdinalTraitForm from "@/components/trait/forms/CategoryTraitForm.vue";
import CategoryTraitForm from "@/components/trait/forms/CategoryTraitForm.vue";
import TextTraitForm from "@/components/trait/forms/TextTraitForm.vue";
import DateTraitForm from "@/components/trait/forms/DateTraitForm.vue";
import DurationTraitForm from "@/components/trait/forms/DurationTraitForm.vue";
import NumericalTraitForm from "@/components/trait/forms/NumericalTraitForm.vue";
import CategoryTraitForm from "@/components/trait/forms/CategoryTraitForm.vue";
import {TraitError} from "@/breeding-insight/model/errors/TraitError";
import {ValidationError} from "@/breeding-insight/model/errors/ValidationError";
import AutoCompleteField from "@/components/forms/AutoCompleteField.vue";
import { StringFormatters } from '@/breeding-insight/utils/StringFormatters';
import {StringFormatters} from '@/breeding-insight/utils/StringFormatters';
import {Category} from "@/breeding-insight/model/Category";
import {integer} from "vuelidate/lib/validators";
import TagField from "@/components/forms/TagField.vue";
import BaseFieldWrapper from "@/components/forms/BaseFieldWrapper.vue";
import {TermType} from "@/breeding-insight/model/TraitSelector";

@Component({
components: {
Expand Down Expand Up @@ -323,6 +338,8 @@ export default class BaseTraitForm extends Vue {
@Prop()
tags?: string[];

private termTypes: TermType[] = Object.values(TermType);

private methodHistory: {[key: string]: Method} = {};
private scaleHistory: {[key: string]: Scale} = {};
private lastCategoryType: string = '';
Expand Down Expand Up @@ -362,6 +379,9 @@ export default class BaseTraitForm extends Vue {
if ((this.trait.scale) && (this.trait.scale.categories)) {
this.categories = this.trait.scale.categories;
}
if (!this.trait.termType) {
this.trait.termType = TermType.PHENOTYPE;
}
}

@Watch('trait', {deep: true})
Expand Down Expand Up @@ -529,6 +549,10 @@ export default class BaseTraitForm extends Vue {
}
}

setTermType(value: TermType) {
this.trait.termType = value;
}

setFullName(value: string) {
this.trait.fullName = value;
this.trait.synonyms = this.trait.synonyms || [];
Expand Down