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-85,BI-646] - Create new trait UI #58

Merged
merged 9 commits into from
Dec 7, 2020
Merged

[BI-85,BI-646] - Create new trait UI #58

merged 9 commits into from
Dec 7, 2020

Conversation

ctucker3
Copy link
Contributor

@ctucker3 ctucker3 commented Nov 30, 2020

Adds the ability to create a basic trait from the UI.

Error display is not implemented yet, so you will get a generic error when trait creation fails. Open the developer console to see the errors printed out. You might need the console open before submitting for the errors to be printed.

Some scale classes may fail because the specific scale additionals aren't in there yet. You will get errors like "Missing categories for scale class 'Categories'" or something along those lines.

Some updates to the components. One to allow hiding of the label. One to allow the select field component to accept strings and objects.

@ctucker3 ctucker3 changed the title [BI-85] - Create new trait UI [BI-85,BI-646] - Create new trait UI Nov 30, 2020
@ctucker3 ctucker3 marked this pull request as ready for review December 1, 2020 15:15
Copy link
Member

@nickpalladino nickpalladino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Form looks good, on mobile too.

static async getObservationLevels(programId: string): Promise<BiResponse> {

const { data } = await api.call({
url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/observation_level`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be /programs/${programId}/observation-levels to be consistent with other endpoints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good catch. Changed and pushed.

@@ -48,6 +54,8 @@ export class TraitService {
let traits: Trait[] = [];

if (biResponse.result.data) {
//TODO: Remove when backend default sorting is implemented
biResponse.result.data = PaginationController.mockSortRecords(biResponse.result.data);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Messin with my field book stuff man, haha. Think I removed this so that the order in bi-web and in field book matched but not a big deal if it's needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is needed for now to show the new trait at the top when it is added from the new trait from. Otherwise, it could appear on a different page and the user wouldn't see it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ya, that's right. Now you can do that on this page.

this.$emit('trait-change', val);
}

filteredDataObj(data: string[]): string[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be a nice to have but this seems to match any letter in the observation level rather than a sequence starting with the first letter.

Copy link
Contributor Author

@ctucker3 ctucker3 Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should match any substring with the options. So if typed, lo that should match Plot and Lot and Slot and.... well I'll stop showing off my rhyming skills! When I'm on the interwebs, I usually like search bars like this instead of stricter search bars that search from the beginning.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, works for me.

static async getObservationLevels(programId: string): Promise<BiResponse> {

const { data } = await api.call({
url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/observation-level`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add an 's' making it observation-levels

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed and pushed

@@ -18,7 +18,6 @@
import {Category} from "@/breeding-insight/model/Category";

export enum DataType {
Code = "CODE",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used in TraitDetailPanel, granted it's not really doing anything with it at this point.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

Copy link
Member

@timparsons timparsons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!! I did have a couple of things:

  1. I accidentally ran into an issue where I clicked "Save" twice before the form closed (for whatever reason the app was being slow the first time I tried saving), and the trait table was updated. After the table was updated, I had two records with duplicate information. I verified this again, and was indeed able to create identical traits by double clicking the "Save" button. @ctucker3 and I talked about this, and agreed that it would be best to disable the "Save" button after it's clicked to prevent double clicking, AND to add database constraints to check for uniqueness in the case that two identical trait POST requests are made simultaneously.

  2. For the observation level input, I noticed that the autocomplete values are visible when focus is put on the input. It wasn't obvious to me that a new observation level could be made by typing it into the input. @eawoods could messaging be added to the input (or maybe even in the autocomplete box), and what should that look like?

static async getObservationLevels(programId: string): Promise<BiResponse> {

const { data } = await api.call({
url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/observation-level`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment on lines +184 to +186
private methodClassOptions: string[] = Object.values(MethodClass);
private observationLevelOptions?: string[];
private scaleClassOptions: string[] = Object.values(DataType);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to change the method and scale classes to be arrays of option -> {id: <enum value>, name: <enum but with only first letter capitalized>}?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed and pushed

@eawoods
Copy link
Contributor

eawoods commented Dec 3, 2020

  1. For the observation level input, I noticed that the autocomplete values are visible when focus is put on the input. It wasn't obvious to me that a new observation level could be made by typing it into the input. @eawoods could messaging be added to the input (or maybe even in the autocomplete box), and what should that look like?

How about having placeholder text in the field that says "Start typing to see suggestions" ?

@ctucker3
Copy link
Contributor Author

ctucker3 commented Dec 4, 2020

Looks great!! I did have a couple of things:

  1. I accidentally ran into an issue where I clicked "Save" twice before the form closed (for whatever reason the app was being slow the first time I tried saving), and the trait table was updated. After the table was updated, I had two records with duplicate information. I verified this again, and was indeed able to create identical traits by double clicking the "Save" button. @ctucker3 and I talked about this, and agreed that it would be best to disable the "Save" button after it's clicked to prevent double clicking, AND to add database constraints to check for uniqueness in the case that two identical trait POST requests are made simultaneously.

My database constraints didn't work with the double click, although they would work with a regular query. I'm thinking those queries are being executed simultaneously so the duplicates aren't being caught. I created a new card to look into this:

https://breedinginsight.atlassian.net/browse/BI-689

The prevention of the double click on the UI is implemented for traits. It needs to be added to the other forms still though.

  1. For the observation level input, I noticed that the autocomplete values are visible when focus is put on the input. It wasn't obvious to me that a new observation level could be made by typing it into the input. @eawoods could messaging be added to the input (or maybe even in the autocomplete box), and what should that look like?

Implemented Liz's suggestion of the placeholder.

@ctucker3 ctucker3 merged commit 7f0b1f2 into develop Dec 7, 2020
@ctucker3 ctucker3 deleted the feature/BI-85 branch December 7, 2020 16:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants