Skip to content
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
9 changes: 8 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 = TermType.PHENOTYPE; //Phenotype is default

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 @@ -85,11 +88,14 @@ export class Trait {
}
this.fullName = fullName;
this.isDup = isDup;
if (termType) {
this.termType = termType;
}
}

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 +117,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
9 changes: 8 additions & 1 deletion src/breeding-insight/model/TraitSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,14 @@ 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 {
PHENOTYPE = 'Phenotype',
GERM_ATTRIBUTE = 'Germplasm Attribute',
GERM_PASSPORT = 'Germplasm Passport'
}

export class TraitFilter {
Expand Down
28 changes: 28 additions & 0 deletions src/breeding-insight/utils/EnumUtils.ts
Original file line number Diff line number Diff line change
@@ -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];
}
}
6 changes: 6 additions & 0 deletions src/breeding-insight/utils/TraitStringFormatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand All @@ -32,4 +34,8 @@ export class TraitStringFormatters {
return undefined;
}

static getTermTypeString(termType: TermType): string | undefined {
return EnumUtils.enumKeyToValue(termType,TermType);
}

}
22 changes: 19 additions & 3 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')"
>
{{ TraitStringFormatters.getTermTypeString(data.termType) }}
</TableColumn>
<TableColumn
name="trait"
v-bind:label="'Trait'"
Expand Down Expand Up @@ -238,7 +250,7 @@ import WarningModal from '@/components/modals/WarningModal.vue'
import {PlusCircleIcon} from 'vue-feather-icons'
import {validationMixin} from 'vuelidate';
import {Trait} from '@/breeding-insight/model/Trait'
import {mapGetters, mapActions} from 'vuex'
import {mapActions, mapGetters} from 'vuex'
import {Program} from "@/breeding-insight/model/Program";
import NewDataForm from '@/components/forms/NewDataForm.vue'
import BasicInputField from "@/components/forms/BasicInputField.vue";
Expand All @@ -259,10 +271,11 @@ import {DataType, Scale} from "@/breeding-insight/model/Scale";
import {SidePanelTableEventBusHandler} from "@/components/tables/SidePanelTableEventBus";
import {DataFormEventBusHandler} from '@/components/forms/DataFormEventBusHandler';
import {integer, maxLength} from "vuelidate/lib/validators";
import {TraitField, TraitFilter} from "@/breeding-insight/model/TraitSelector";
import {OntologySort, OntologySortField, SortOrder, TraitSortField} from "@/breeding-insight/model/Sort";
import {TermType, TraitField, TraitFilter} from "@/breeding-insight/model/TraitSelector";
import {OntologySort, OntologySortField} from "@/breeding-insight/model/Sort";
import {BackendPaginationController} from "@/breeding-insight/model/view_models/BackendPaginationController";
import {Category} from "@/breeding-insight/model/Category";
import {EnumUtils} from "@/breeding-insight/utils/EnumUtils";

@Component({
mixins: [validationMixin],
Expand Down Expand Up @@ -314,6 +327,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 Expand Up @@ -617,6 +631,8 @@ export default class OntologyTable extends Vue {
category.label = undefined;
});
}
//Translate TermType from user readable to backend storage format
traitToSave.termType = EnumUtils.enumValueToKey(inputTrait.termType, TermType);
return traitToSave;
}

Expand Down
13 changes: 12 additions & 1 deletion 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">{{TraitStringFormatters.getTermTypeString(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 Expand Up @@ -252,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},
Expand All @@ -260,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 = '';
Expand Down
36 changes: 31 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,23 @@ 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";
import {EnumUtils} from "@/breeding-insight/utils/EnumUtils";

@Component({
components: {
Expand Down Expand Up @@ -323,6 +339,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 +380,10 @@ export default class BaseTraitForm extends Vue {
if ((this.trait.scale) && (this.trait.scale.categories)) {
this.categories = this.trait.scale.categories;
}
//If termType pulled from backend (rather than the default for new terms), set to display friendly version
if (this.trait.termType != TermType.PHENOTYPE) {
this.trait.termType = EnumUtils.enumKeyToValue(this.trait.termType, TermType);
}
}

@Watch('trait', {deep: true})
Expand Down Expand Up @@ -529,6 +551,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