diff --git a/src/breeding-insight/model/Trait.ts b/src/breeding-insight/model/Trait.ts index df7458791..9b1ad4da1 100644 --- a/src/breeding-insight/model/Trait.ts +++ b/src/breeding-insight/model/Trait.ts @@ -36,7 +36,7 @@ export class Trait { tags?: string[] = []; fullName?: string; isDup?: boolean; - termType?: TermType; + termType: TermType = TermType.PHENOTYPE; //Phenotype is default constructor(id?: string, traitName?: string, @@ -88,6 +88,9 @@ export class Trait { } this.fullName = fullName; this.isDup = isDup; + if (termType) { + this.termType = termType; + } } static assign(trait: Trait): Trait { diff --git a/src/breeding-insight/model/TraitSelector.ts b/src/breeding-insight/model/TraitSelector.ts index b7101ff50..55e4db337 100644 --- a/src/breeding-insight/model/TraitSelector.ts +++ b/src/breeding-insight/model/TraitSelector.ts @@ -18,7 +18,8 @@ export enum TraitField { CREATED_BY_USER_ID = 'createdByUserId', CREATED_BY_USER_NAME = 'createdByUserName', UPDATED_BY_USER_ID = 'updatedByUserId', - UPDATED_BY_USER_NAME = 'updatedByUserName' + UPDATED_BY_USER_NAME = 'updatedByUserName', + TERM_TYPE = 'termType' } export enum TermType { diff --git a/src/breeding-insight/utils/EnumUtils.ts b/src/breeding-insight/utils/EnumUtils.ts new file mode 100644 index 000000000..58cb6082e --- /dev/null +++ b/src/breeding-insight/utils/EnumUtils.ts @@ -0,0 +1,28 @@ +/* + * See the NOTICE file distributed with this work for additional information + * regarding copyright ownership. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class EnumUtils { + static enumKeyToValue(enumKey: string, enumType: Object){ + let index = Object.keys(enumType).indexOf(enumKey); + return Object.values(enumType)[index]; + } + + static enumValueToKey(enumVal: string, enumType: Object){ + let index = Object.values(enumType).indexOf(enumVal); + return Object.keys(enumType)[index]; + } +} \ No newline at end of file diff --git a/src/breeding-insight/utils/TraitStringFormatters.ts b/src/breeding-insight/utils/TraitStringFormatters.ts index 48a61c111..1ae08827a 100644 --- a/src/breeding-insight/utils/TraitStringFormatters.ts +++ b/src/breeding-insight/utils/TraitStringFormatters.ts @@ -17,6 +17,8 @@ import {Scale, DataType} from "@/breeding-insight/model/Scale"; import {StringFormatters} from "@/breeding-insight/utils/StringFormatters"; +import {TermType} from "@/breeding-insight/model/TraitSelector"; +import {EnumUtils} from "@/breeding-insight/utils/EnumUtils"; export class TraitStringFormatters { @@ -32,4 +34,8 @@ export class TraitStringFormatters { return undefined; } + static getTermTypeString(termType: TermType): string | undefined { + return EnumUtils.enumKeyToValue(termType,TermType); + } + } \ No newline at end of file diff --git a/src/components/ontology/OntologyTable.vue b/src/components/ontology/OntologyTable.vue index 1fdb28552..0ae2c148e 100644 --- a/src/components/ontology/OntologyTable.vue +++ b/src/components/ontology/OntologyTable.vue @@ -132,7 +132,7 @@ v-on:newSortColumn="$emit('newSortColumn', $event)" v-on:toggleSortOrder="$emit('toggleSortOrder')" > - {{ data.termType }} + {{ TraitStringFormatters.getTermTypeString(data.termType) }} Term Type
- {{data.termType}} + {{TraitStringFormatters.getTermTypeString(data.termType)}}
@@ -262,6 +262,7 @@ import { DataFormEventBusHandler } from '@/components/forms/DataFormEventBusHandler'; import { HelpCircleIcon } from 'vue-feather-icons' import ProgressBar from '@/components/forms/ProgressBar.vue' + import {TraitStringFormatters} from '@/breeding-insight/utils/TraitStringFormatters'; @Component({ components: {EditDataForm, SidePanel, BaseTraitForm, HelpCircleIcon, ProgressBar}, @@ -270,7 +271,7 @@ 'isSubscribed' ]) }, - data: () => ({DataType, MethodClass, Scale, Method, StringFormatters}), + data: () => ({DataType, MethodClass, Scale, Method, StringFormatters, TraitStringFormatters}), filters: { capitalize: function(value: string | undefined) : string | undefined { if (value === undefined) value = ''; diff --git a/src/components/trait/TraitsImportTable.vue b/src/components/trait/TraitsImportTable.vue index 3e99701cc..8ecf1b70e 100644 --- a/src/components/trait/TraitsImportTable.vue +++ b/src/components/trait/TraitsImportTable.vue @@ -54,6 +54,19 @@ {{ data.observationVariableName }}
+ + {{ TraitStringFormatters.getTermTypeString(data.termType) }} +