-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4200 from SpeciesFileGroup/browse_field_occurrence
Browse field occurrence
- Loading branch information
Showing
63 changed files
with
1,072 additions
and
32 deletions.
There are no files selected for viewing
This file contains 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,4 @@ | ||
class Tasks::FieldOccurrences::BrowseController < ApplicationController | ||
include TaskControllerConfiguration | ||
|
||
end |
This file contains 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 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 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 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
134 changes: 134 additions & 0 deletions
134
app/javascript/vue/tasks/field_occurrences/browse/app.vue
This file contains 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,134 @@ | ||
<template> | ||
<div class="flex flex-separate middle"> | ||
<VSpinner | ||
v-if="isLoading" | ||
full-screen | ||
/> | ||
<h1>Browse field occurrence</h1> | ||
<VAutocomplete | ||
v-if="store.fieldOccurrence" | ||
class="autocomplete" | ||
url="/field_occurrences/autocomplete" | ||
placeholder="Search a field occurrence" | ||
param="term" | ||
label="label_html" | ||
clear-after | ||
@get-item="({ id }) => loadData(id)" | ||
/> | ||
</div> | ||
<FOHeader @select="loadData" /> | ||
<TableGrid | ||
:columns="1" | ||
gap="1em" | ||
> | ||
<TableGrid | ||
:columns="ceStore.collectingEvent ? 3 : 2" | ||
gap="1em" | ||
:column-width="{ | ||
default: 'min-content', | ||
0: '1fr', | ||
1: ceStore.collectingEvent ? '2fr' : '1fr', | ||
2: '1fr' | ||
}" | ||
> | ||
<PanelFO /> | ||
<PanelCE /> | ||
<ColumnThree /> | ||
</TableGrid> | ||
</TableGrid> | ||
</template> | ||
|
||
<script setup> | ||
import { FIELD_OCCURRENCE, COLLECTING_EVENT } from '@/constants' | ||
import { URLParamsToJSON } from '@/helpers' | ||
import { onBeforeMount, ref } from 'vue' | ||
import VAutocomplete from '@/components/ui/Autocomplete.vue' | ||
import FOHeader from './components/FOHeader.vue' | ||
import PanelFO from './components/Panel/PanelFO.vue' | ||
import PanelCE from './components/PanelCE/PanelCE.vue' | ||
import ColumnThree from './components/ColumnThree.vue' | ||
import TableGrid from '@/components/layout/Table/TableGrid.vue' | ||
import VSpinner from '@/components/ui/VSpinner.vue' | ||
import useFieldOccurrenceStore from './store/store.js' | ||
import useCollectingEventStore from './store/collectingEvent.js' | ||
import useDeterminationStore from './store/determinations.js' | ||
import useDepictionStore from './store/depictions.js' | ||
import useBiocurationStore from './store/biocurations.js' | ||
import useBiologicalAssociationStore from './store/biologicalAssociations.js' | ||
import useIdentifierStore from './store/identifiers.js' | ||
import { setParam } from '@/helpers' | ||
import { RouteNames } from '@/routes/routes' | ||
defineOptions({ | ||
name: 'BrowseFieldOccurrence' | ||
}) | ||
const store = useFieldOccurrenceStore() | ||
const ceStore = useCollectingEventStore() | ||
const depictionStore = useDepictionStore() | ||
const biocurationStore = useBiocurationStore() | ||
const determinationStore = useDeterminationStore() | ||
const biologicalAssociationStore = useBiologicalAssociationStore() | ||
const identifierStore = useIdentifierStore() | ||
const isLoading = ref(false) | ||
onBeforeMount(async () => { | ||
const { field_occurrence_id: foId } = URLParamsToJSON(location.href) | ||
if (foId) { | ||
loadData(foId) | ||
} | ||
}) | ||
async function loadData(foId) { | ||
const requests = [] | ||
const args = { | ||
objectId: foId, | ||
objectType: FIELD_OCCURRENCE | ||
} | ||
try { | ||
isLoading.value = true | ||
store.$reset() | ||
ceStore.$reset() | ||
depictionStore.$reset() | ||
biocurationStore.$reset() | ||
determinationStore.$reset() | ||
biologicalAssociationStore.$reset() | ||
identifierStore.$reset() | ||
await store.load(foId) | ||
const ceId = store.fieldOccurrence.collecting_event_id | ||
setParam(RouteNames.BrowseFieldOccurrence, 'field_occurrence_id', foId) | ||
if (ceId) { | ||
requests.push( | ||
ceStore.load(ceId), | ||
identifierStore.load({ | ||
objectId: ceId, | ||
objectType: COLLECTING_EVENT | ||
}) | ||
) | ||
} | ||
requests.push( | ||
depictionStore.load(args), | ||
biocurationStore.load(args), | ||
determinationStore.load(args), | ||
biologicalAssociationStore.load(args), | ||
identifierStore.load(args) | ||
) | ||
Promise.all(requests).finally(() => { | ||
isLoading.value = false | ||
}) | ||
} catch { | ||
TW.workbench.alert.create('No field occurrence found.', 'notice') | ||
} | ||
} | ||
</script> |
22 changes: 22 additions & 0 deletions
22
app/javascript/vue/tasks/field_occurrences/browse/components/ColumnThree.vue
This file contains 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,22 @@ | ||
<template> | ||
<TableGrid | ||
:columns="1" | ||
gap="1em" | ||
> | ||
<SoftValidations | ||
v-if="false" | ||
class="column-validation" | ||
/> | ||
<PanelIdentifier /> | ||
<PanelDepictions /> | ||
<PanelMap /> | ||
</TableGrid> | ||
</template> | ||
|
||
<script setup> | ||
import SoftValidations from '@/components/soft_validations/panel.vue' | ||
import PanelIdentifier from './Panel/PanelIdentifier.vue' | ||
import TableGrid from '@/components/layout/Table/TableGrid.vue' | ||
import PanelDepictions from './Panel/PanelDepictions.vue' | ||
import PanelMap from './Panel/PanelMap.vue' | ||
</script> |
Oops, something went wrong.