Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
LocoDelAssembly committed Oct 3, 2024
2 parents 66c50fc + 3c1b945 commit 62e09e6
Show file tree
Hide file tree
Showing 42 changed files with 945 additions and 764 deletions.
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,33 @@ This project <em>does not yet</em> adheres to [Semantic Versioning](https://semv

## [unreleased]

\-

## [0.44.3] - 2024-10-03

### Added

- `dwc_occurrence_id[]` param to dwc_gallery endpoint
- Image matrix link to radial linker and radial matrix

### Fixed

- Date received facet on loans [#4067]
- `api/v1/images/975145cf4d25d7ed35893170abc2e852` style calls finding images by id, not fingerprint [#3918]

### Changed

- Updated Ruby gems
- In DwC Import Otu `name` is now only set via use of `identificationQualifier`

[#3918]: https://github.com/SpeciesFileGroup/taxonworks/issues/3918
[#4067]: https://github.com/SpeciesFileGroup/taxonworks/issues/4067

## [0.44.2] - 2024-09-27

### Added

- Columns in filter results can be copied to clipboard
- Sort by identifier match option [#4065]
- `/collection_objects/123/dwc_compact` - DwC fields for those populated [#3994]
- Pagination to `/api/v1/otus/:otu_id/inventory/dwc_gallery`
Expand Down Expand Up @@ -4877,7 +4900,8 @@ _Special thanks to Tom Klein for his amazing open-source contributions on this r
- Loosing input page numbers when switching tabs on New Taxon Name task

[#1532]: https://github.com/SpeciesFileGroup/taxonworks/issues/1532
[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.44.2..development
[unreleased]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.44.3..development
[0.44.3]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.44.2...v0.44.3
[0.44.2]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.44.1...v0.44.2
[0.44.1]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.44.0...v0.44.1
[0.44.0]: https://github.com/SpeciesFileGroup/taxonworks/compare/v0.43.3...v0.44.0
Expand Down
19 changes: 10 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ GEM
exception_notification (4.5.0)
actionmailer (>= 5.2, < 8)
activesupport (>= 5.2, < 8)
excon (0.111.0)
excon (0.112.0)
execjs (2.8.1)
factory_bot (6.5.0)
activesupport (>= 5.0.0)
Expand Down Expand Up @@ -264,8 +264,8 @@ GEM
gpx (1.2.0)
nokogiri (~> 1.7)
rake
groupdate (6.4.0)
activesupport (>= 6.1)
groupdate (6.5.0)
activesupport (>= 7)
guard (2.18.1)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
Expand All @@ -292,7 +292,7 @@ GEM
indefinite_article (0.2.5)
activesupport
io-console (0.7.2)
irb (1.14.0)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
jbuilder (2.13.0)
Expand Down Expand Up @@ -347,9 +347,10 @@ GEM
marcel (1.0.4)
matrix (0.4.2)
method_source (1.1.0)
mime-types (3.5.2)
mime-types (3.6.0)
logger
mime-types-data (~> 3.2015)
mime-types-data (3.2024.0903)
mime-types-data (3.2024.1001)
mini_mime (1.1.5)
minitest (5.25.1)
modularity (3.0.1)
Expand Down Expand Up @@ -507,7 +508,7 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.3.7)
rexml (3.3.8)
rgb (0.1.2)
rgeo (3.0.1)
rgeo-activerecord (7.0.1)
Expand Down Expand Up @@ -543,7 +544,7 @@ GEM
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-rails (6.1.5)
Expand Down Expand Up @@ -703,7 +704,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webmock (3.23.1)
webmock (3.24.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/images_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def api_index

# GET /api/v1/images/:id
def api_show
@image = Image.where(project_id: sessions_current_project_id).find_by(id: params[:id])
@image = Image.where(project_id: sessions_current_project_id).find_by(id: params.permit(id: :integer)[:id])
@image ||= Image.where(project_id: sessions_current_project_id).find_by(image_file_fingerprint: params[:id])

render plain: 'Not found. You may need to add a &project_token= param to the URL currently in your address bar to access these data. See https://api.taxonworks.org/ for more.', status: :not_found and return if @image.nil?
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/otus_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,14 @@ def api_dwc_inventory
type: 'text',
filename: "dwc_#{helpers.label_for_otu(@otu).gsub(/\W/,'_')}_#{DateTime.now}.csv"
end

format.json do
if params[:page].blank? && params[:per].blank?
render json: DwcOccurrence.scoped_by_otu(@otu).to_json
else # only apply if provided, do not fall back to default scope
render json: DwcOccurrence.scoped_by_otu(@otu).page(params[:page]).per(params[:per]).to_json
r = DwcOccurrence.scoped_by_otu(@otu).page(params[:page]).per(params[:per])
assign_pagination(r)
render json: r.to_json
end
end
end
Expand All @@ -346,7 +349,8 @@ def api_dwc_inventory
# GET /api/v1/otus/:id/inventory/dwc_gallery.json?per=1&page=2
def api_dwc_gallery
# see otus_helper
@data = helpers.dwc_gallery_data(@otu)

@data = helpers.dwc_gallery_data(@otu, dwc_occurrence_id: params[:dwc_occurrence_id])
render '/otus/api/v1/inventory/dwc_gallery'
end

Expand Down
14 changes: 10 additions & 4 deletions app/helpers/otus_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,21 @@ def ranked_otu_table(otus)

# @return Hash
# { dwc_occurrence_id: [ image1, image2 ... ], ... }
def dwc_gallery_data(otu, pagination_headers: true)
def dwc_gallery_data(otu, dwc_occurrence_id: [], pagination_headers: true)
a = DwcOccurrence.scoped_by_otu(otu)
.select(:id, :dwc_occurrence_object_id, :dwc_occurrence_object_type)
.page(params[:page])
.per(params[:per])

dwc_ids = [dwc_occurrence_id].flatten.compact.uniq

if dwc_ids.any?
a = a.where(id: dwc_ids)
end

a = a.page(params[:page]).per(params[:per])

# Somehwhat of a janky pattern, probably needs to be
# moved into Controller.
assign_pagination(a) if pagination_headers
assign_pagination(a) if pagination_headers

b = Image.with(dwc_scope: a)
.joins("JOIN depictions d on d.image_id = images.id" )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ export const TASK_FILTER_IMAGES = {
link: '/tasks/images/filter'
}

export const TASK_IMAGE_MATRIX = {
label: 'Image matrix',
link: '/tasks/matrix_image/matrix_image/index',
parseParams: ({ params }) => ({
otu_filter: params.otu_id?.join('|')
})
}

export const TASK_BIOLOGICAL_ASSOCIATION_EXTENSION = {
label: 'DwC Extension Preview',
link: '/tasks/biological_associations/dwc_extension_preview'
Expand Down
5 changes: 3 additions & 2 deletions app/javascript/vue/components/radials/linker/links/Otu.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
TASK_CACHED_MAP_ITEM,
TASK_FIELD_SYNCHRONIZE
TASK_FIELD_SYNCHRONIZE,
TASK_IMAGE_MATRIX
} from '../constants/links'

export const Otu = {
all: [TASK_CACHED_MAP_ITEM, TASK_FIELD_SYNCHRONIZE],
ids: [TASK_CACHED_MAP_ITEM, TASK_FIELD_SYNCHRONIZE]
ids: [TASK_CACHED_MAP_ITEM, TASK_FIELD_SYNCHRONIZE, TASK_IMAGE_MATRIX]
}
21 changes: 11 additions & 10 deletions app/javascript/vue/components/radials/linker/radial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,12 @@ const menuOptions = computed(() => {
const slices = []
filterLinks.value.forEach((item) => {
const filteredParameters = filterEmptyParams(
isOnlyIds.value ? getParametersForId() : getParametersForAll(item.params)
)
const parameters = item.queryParam
? { [QUERY_PARAM[props.objectType]]: filteredParameters }
: filteredParameters
const parameters = getLinkParameters(item)
const link =
item.link + '?' + qs.stringify(parameters, { arrayFormat: 'brackets' })
if (Object.values(filteredParameters).some(Boolean)) {
if (Object.values(parameters).some(Boolean)) {
if (item.post) {
slices.push(addSlice({ label: item.label }))
} else if (link.length > MAX_LINK_SIZE) {
Expand Down Expand Up @@ -208,14 +202,21 @@ function getItemByName(name) {
}
function getLinkParameters(item) {
const { queryParam, parseParams } = item
const filteredParameters = filterEmptyParams(
isOnlyIds.value ? getParametersForId() : getParametersForAll()
)
const parameters = item.queryParam
const params = queryParam
? { [QUERY_PARAM[props.objectType]]: filteredParameters }
: filteredParameters
return parameters
const args = {
params,
objectType: props.objectType
}
return typeof parseParams === 'function' ? parseParams(args) : params
}
function setParametersFor({ name }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<ButtonImageMatrix
class="button normal-input button-default"
:disabled="!ids.length"
@click="() => openImageMatrix(ids)"
/>
</template>

<script setup>
import { RouteNames } from '@/routes/routes'
import ButtonImageMatrix from '@/tasks/observation_matrices/dashboard/components/buttonImageMatrix.vue'
defineProps({
ids: {
type: Object,
required: true
}
})
function openImageMatrix(ids) {
window.open(
`${RouteNames.ImageMatrix}?otu_filter=${ids.join('|')}&view=true`,
'_blank'
)
}
</script>
18 changes: 16 additions & 2 deletions app/javascript/vue/components/radials/matrix/radial.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,33 @@
</template>

<script setup>
import { OTU } from '@/constants'
import { useAttrs } from 'vue'
import RadialBatch from '@/components/radials/shared/RadialBatch.vue'
import AddSlice from './components/AddSlice.vue'
import AddNewSlice from './components/AddNewSlice.vue'
import ImageMatrix from './components/ImageMatrix.vue'
const attrs = useAttrs()
const props = defineProps({
objectType: {
type: String,
default: undefined
}
})
const SLICES = {
'Add to an existing matrix': AddSlice,
'Add to a new matrix': AddNewSlice
}
if (attrs.ids && props.objectType === OTU) {
Object.assign(SLICES, {
'View image matrix': ImageMatrix
})
}
defineOptions({
name: 'RadialMatrix'
})
const attrs = useAttrs()
</script>
2 changes: 1 addition & 1 deletion app/javascript/vue/directives/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function getLabelFromPath(json, path) {
const properties = path.split('.')

properties.forEach((property) => {
json = json[property]
json = json?.[property]
})

return json
Expand Down
1 change: 1 addition & 0 deletions app/javascript/vue/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const RouteNames = {
NewCollectingEvent: '/tasks/collecting_events/new_collecting_event',
NewContainer: '/tasks/containers/new_container',
NewCombination: '/tasks/nomenclature/new_combination',
NewDescriptor: '/tasks/descriptors/new_descriptor',
NewExtract: '/tasks/extracts/new_extract',
NewLead: '/tasks/leads/new_lead',
NewNamespace: '/tasks/namespaces/new_namespace',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,14 @@ export default {
const store = this.preferences.layout[this.keyStorage]
if (
store &&
Object.keys(this.componentsOrder).every(
(key) => store[key].length === this.componentsOrder[key].length
)
Object.keys(this.componentsOrder).every((key) => {
const section = this.componentsOrder[key]
return (
store[key]?.length === section.length &&
section.every((item) => store[key].includes(item))
)
})
) {
this.componentsOrder = store
}
Expand Down
Loading

0 comments on commit 62e09e6

Please sign in to comment.