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
5 changes: 4 additions & 1 deletion src/breeding-insight/model/Trait.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -88,6 +88,9 @@ export class Trait {
}
this.fullName = fullName;
this.isDup = isDup;
if (termType) {
this.termType = termType;
}
}

static assign(trait: Trait): Trait {
Expand Down
3 changes: 2 additions & 1 deletion src/breeding-insight/model/TraitSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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);
}

}
11 changes: 7 additions & 4 deletions src/components/ontology/OntologyTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
v-on:newSortColumn="$emit('newSortColumn', $event)"
v-on:toggleSortOrder="$emit('toggleSortOrder')"
>
{{ data.termType }}
{{ TraitStringFormatters.getTermTypeString(data.termType) }}
</TableColumn>
<TableColumn
name="trait"
Expand Down Expand Up @@ -250,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 @@ -271,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 @@ -630,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
5 changes: 3 additions & 2 deletions src/components/trait/TraitDetailPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<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>
<span class="is-size-7 mb-0">{{TraitStringFormatters.getTermTypeString(data.termType)}}</span>
</div>
</div>

Expand Down Expand Up @@ -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},
Expand All @@ -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 = '';
Expand Down
14 changes: 14 additions & 0 deletions src/components/trait/TraitsImportTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@
</AlertTriangleIcon>
{{ data.observationVariableName }}
</TableColumn>
<TableColumn
name="termType"
v-bind:label="'Term Type'"
v-bind:visible="!collapseColumns"
v-bind:sortField="importPreviewOntologySort.field"
v-bind:sortFieldLabel="termTypeSortLabel"
v-bind:sortable="true"
v-bind:sortOrder="importPreviewOntologySort.order"
v-on:newSortColumn="newSortColumn"
v-on:toggleSortOrder="toggleSortOrder"
>
{{ TraitStringFormatters.getTermTypeString(data.termType) }}
</TableColumn>
<TableColumn
name="trait"
v-bind:label="'Trait'"
Expand Down Expand Up @@ -220,6 +233,7 @@ export default class TraitsImportTable extends Vue {
private scaleClassSortLabel: string = OntologySortField.ScaleClass;
private unitSortLabel: string = OntologySortField.ScaleName;
private entityAttributeSortLabel: string = OntologySortField.entityAttributeSortLabel;
private termTypeSortLabel: string = OntologySortField.TermType;

mounted() {
this.updatePagination();
Expand Down
9 changes: 7 additions & 2 deletions src/components/trait/forms/BaseTraitForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
</div>
<div class="column new-term is-10">
<BasicSelectField
id="termTypeField"
class="pb-2"
v-bind:selected-id="trait.termType"
v-bind:options="termTypes"
Expand Down Expand Up @@ -165,6 +166,7 @@
</div>
<div class="column new-term is-10">
<BasicSelectField
id="methodClass"
class="pb-2"
v-bind:selected-id="trait.method.methodClass"
v-bind:options="methodOptions"
Expand All @@ -186,6 +188,7 @@
</div>
<div class="column new-term is-10">
<BasicSelectField
id="scaleClass"
v-bind:selected-id="StringFormatters.toStartCase(trait.scale.dataType)"
v-bind:options="getScaleOptions()"
v-bind:field-name="'Scale Class'"
Expand Down Expand Up @@ -296,6 +299,7 @@ import {Category} from "@/breeding-insight/model/Category";
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 @@ -379,8 +383,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;
//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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/views/trait/TraitsImport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default class TraitsImport extends ProgramsBase {
private showAbortModal = false;

private yesAbortId: string = "traitsimport-yes-abort";
private templateUrl: string = "https://cornell.box.com/shared/static/8mp6ex7c07mregc84pcb81u3fcpjje69.xls";
private templateUrl: string = "https://cornell.box.com/shared/static/7vtd4vkzc2efrdlion74miql9surugqd.xls";

private confirmImportState: DataFormEventBusHandler = new DataFormEventBusHandler();

Expand Down