-
Notifications
You must be signed in to change notification settings - Fork 1
BI-2373 Add Delete Option to Germplasm Lists View #420
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
28d86ba
add delete option to germplasm list management
dmeidlin a18760e
add access control for list delete menu option
dmeidlin 2a6d70f
get germplasm list records via germplasm endpoints
dmeidlin c49c3d8
revert to germplasm endpoints
dmeidlin a3297b8
fix listType query param for lists call
dmeidlin 0560511
incorporate PR feedback
dmeidlin 2bd27e7
upadte package-lock.json
dmeidlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| import {BiResponse} from "@/breeding-insight/model/BiResponse"; | ||
| import {SortOrder} from "@/breeding-insight/model/Sort"; | ||
| import * as api from "@/util/api"; | ||
| import {ListType} from "@/util/ListType"; | ||
|
|
||
| export class ListService { | ||
| static async deleteList(programId: string | undefined, listDbId: string) { | ||
| if (programId == undefined) { | ||
| throw new Error("Not valid program"); | ||
| } | ||
| try { | ||
| const response = await api.call({ | ||
| url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/brapi/v2/lists/${listDbId}`, | ||
| method: 'delete', | ||
| params: { hardDelete: true } | ||
| }) as Response; | ||
|
|
||
| // If we get here, it means the call was successful (likely 200 OK) | ||
| return new BiResponse({ success: true }); | ||
|
|
||
| } catch (error) { | ||
| // Check if the error is actually a 204 No Content response since http clients can be configured to | ||
| // automatically throw an error if the response has no content | ||
| if (error.response && error.response.status === 204) { | ||
| // This is actually a successful deletion | ||
| return new BiResponse({ success: true }); | ||
| } | ||
|
|
||
| // For other errors, log and rethrow | ||
| console.error('Error in deleteList:', error); | ||
| throw error; | ||
| } | ||
| } | ||
|
|
||
| static async getLists<T>(listType: ListType, | ||
| programId: string, | ||
| sort: { field: T, order: SortOrder }, | ||
| pagination: {pageSize: number, page: number}, | ||
| filters?: any): Promise<BiResponse> { | ||
| if (!programId) throw 'Program ID required'; | ||
|
|
||
| // Set list type, sort, and pagination | ||
| let params: any = { listType }; | ||
|
|
||
| if(filters) { | ||
| params = { listType, ...filters }; | ||
| } | ||
|
|
||
| if (sort.field) { | ||
| params['sortField'] = sort.field; | ||
| } | ||
| if (sort.order) { | ||
| params['sortOrder'] = sort.order; | ||
| } | ||
| if (pagination.page || pagination.page == 0) { //have to account for 0-index pagination since 0 falsy | ||
| params['page'] = pagination.page; | ||
| } | ||
| if (pagination.pageSize) { | ||
| params['pageSize'] = pagination.pageSize; | ||
| } | ||
|
|
||
| // Make the GET call | ||
| try { | ||
| const { data }: any = await api.call({ | ||
| url: `${process.env.VUE_APP_BI_API_V1_PATH}/programs/${programId}/brapi/v2/lists`, | ||
| method: 'get', | ||
| params: params | ||
| }); | ||
|
|
||
| return new BiResponse(data); | ||
|
|
||
| } catch (error) { | ||
| throw error; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| <!-- | ||
| - 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. | ||
| --> | ||
|
|
||
| <template> | ||
| <ConfirmationModal | ||
| v-bind:unique-id="listDbId" | ||
| v-bind:modal-title="modalTitle" | ||
| v-bind:confirmedAction="deleteList" | ||
| v-bind:active="active" | ||
| modal-class="germplasm-list-deletion-button" | ||
| v-on:deactivate="cancelDelete" | ||
| > | ||
| <template #form> | ||
| <p>Are you sure you want to delete the germplasm list? Note that deleting a germplasm list will not delete the associated germplasm records.</p> | ||
| </template> | ||
| <slot /> | ||
| </ConfirmationModal> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import {Component, Vue, Prop} from "vue-property-decorator"; | ||
| import {validationMixin} from "vuelidate"; | ||
| import {mapGetters} from "vuex"; | ||
| import {Program} from "@/breeding-insight/model/Program"; | ||
| import {AlertTriangleIcon} from 'vue-feather-icons'; | ||
| import {Trial} from "@/breeding-insight/model/Trial"; | ||
| import ConfirmationModal from "@/components/modals/ConfirmationModal.vue"; | ||
| import {ExperimentService} from "@/breeding-insight/service/ExperimentService"; | ||
| import { Collaborator } from '@/breeding-insight/model/Collaborator'; | ||
| import { ListService } from '@/breeding-insight/service/ListService'; | ||
|
|
||
| @Component({ | ||
| mixins: [validationMixin], | ||
| components: {ConfirmationModal, AlertTriangleIcon}, | ||
| computed: { | ||
| ...mapGetters([ | ||
| 'activeProgram' | ||
| ]) | ||
| } | ||
| }) | ||
| export default class GermplasmListDeletionlModal extends Vue { | ||
|
|
||
| @Prop() | ||
| active!: boolean; | ||
| @Prop() | ||
| listDbId!: string; | ||
| @Prop() | ||
| modalTitle?: string; | ||
|
|
||
| private activeProgram?: Program; | ||
|
|
||
| async deleteList(): Promise<void> { | ||
| if (this.activeProgram) { | ||
| try { | ||
| // Call the service method and await its completion | ||
| await ListService.deleteList(this.activeProgram.id, this.listDbId) | ||
|
|
||
| // If the above call doesn't throw an error, we assume it was successful | ||
| // Emit the event after the promise is resolved | ||
| this.$emit('list-deleted'); | ||
|
|
||
| } catch (error) { | ||
| // Handle any errors that might occur during the async operation | ||
| console.error('Error deleting the list:', error); | ||
| // Optionally emit an error event or handle the error in some way | ||
| this.$emit('show-error-notification', `Error while trying to delete the list`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| cancelDelete(){ | ||
| this.$emit('deactivate'); | ||
| } | ||
| } | ||
| </script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.