-
Notifications
You must be signed in to change notification settings - Fork 1
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
Changes from 4 commits
0e8db00
b4df9b0
a666fa2
b0ad618
ba916ae
ca094f2
7ad8f40
9a2b2cd
fa2adb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 ObservationLevel { | ||
id?: string; | ||
name?: string; | ||
|
||
constructor(id?:string, name?:string) { | ||
this.id = id; | ||
this.name = name; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,15 +20,21 @@ import {Trait} from "@/breeding-insight/model/Trait"; | |
import {Metadata} from "@/breeding-insight/model/BiResponse"; | ||
import {PaginationQuery} from "@/breeding-insight/model/PaginationQuery"; | ||
import {PaginationController} from "@/breeding-insight/model/view_models/PaginationController"; | ||
import {TraitUploadService} from "@/breeding-insight/service/TraitUploadService"; | ||
import {ValidationError} from "@/breeding-insight/model/errors/ValidationError"; | ||
|
||
export class TraitService { | ||
|
||
static async createTraits(programId: string, newTraits: Trait[]): Promise<[Trait[], Metadata] | void> { | ||
static async createTraits(programId: string, newTraits: Trait[]): Promise<[Trait[], Metadata]> { | ||
if (programId) { | ||
const { result: { data }, metadata } = await TraitDAO.createTraits(programId, newTraits); | ||
return [data, metadata]; | ||
} | ||
else return; | ||
try { | ||
const { result: { data }, metadata } = await TraitDAO.createTraits(programId, newTraits); | ||
return [data, metadata]; | ||
} catch (error) { | ||
throw TraitUploadService.parseError(error); | ||
} | ||
} | ||
else throw 'Unable to create trait'; | ||
} | ||
|
||
static getAll(programId: string, paginationQuery?: PaginationQuery, full?: boolean): Promise<[Trait[], Metadata]> { | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
traits = biResponse.result.data.map((trait: any) => { | ||
return trait as Trait; | ||
}); | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.