From e25c3c6dec58390206140e9fcab154ec7997dd96 Mon Sep 17 00:00:00 2001 From: jlpereira Date: Fri, 27 Sep 2024 15:29:57 -0300 Subject: [PATCH 01/16] Fix #4066 --- .../components/CollectingEventForm.vue | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/javascript/vue/tasks/collecting_events/new_collecting_event/components/CollectingEventForm.vue b/app/javascript/vue/tasks/collecting_events/new_collecting_event/components/CollectingEventForm.vue index e159e117d8..e87b8a01c7 100644 --- a/app/javascript/vue/tasks/collecting_events/new_collecting_event/components/CollectingEventForm.vue +++ b/app/javascript/vue/tasks/collecting_events/new_collecting_event/components/CollectingEventForm.vue @@ -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 } From f748488594258cd9d1966a72e218b3fff1dbe970 Mon Sep 17 00:00:00 2001 From: jlpereira Date: Fri, 27 Sep 2024 15:46:24 -0300 Subject: [PATCH 02/16] Fix directive --- app/javascript/vue/directives/help.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/javascript/vue/directives/help.js b/app/javascript/vue/directives/help.js index df2c1ebac5..88d26bcfa0 100644 --- a/app/javascript/vue/directives/help.js +++ b/app/javascript/vue/directives/help.js @@ -10,7 +10,7 @@ function getLabelFromPath(json, path) { const properties = path.split('.') properties.forEach((property) => { - json = json[property] + json = json?.[property] }) return json From bc945792cbc8caa398ada36c9ee2665ca31000e8 Mon Sep 17 00:00:00 2001 From: jlpereira Date: Mon, 30 Sep 2024 12:14:30 -0300 Subject: [PATCH 03/16] Add image matrix link --- CHANGELOG.md | 1 + .../radials/linker/constants/links.js | 8 ++++++ .../components/radials/linker/links/Otu.js | 5 ++-- .../vue/components/radials/linker/radial.vue | 21 ++++++++------- .../radials/matrix/components/ImageMatrix.vue | 26 +++++++++++++++++++ .../vue/components/radials/matrix/radial.vue | 18 +++++++++++-- .../components/buttonImageMatrix.vue | 4 +-- .../tasks/observation_matrices/image/app.vue | 14 +++++----- .../image/components/View/Main.vue | 5 ---- app/javascript/vue/tasks/otu/filter/App.vue | 10 ++++--- 10 files changed, 79 insertions(+), 33 deletions(-) create mode 100644 app/javascript/vue/components/radials/matrix/components/ImageMatrix.vue diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a412ebea1..216d85984a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ This project does not yet adheres to [Semantic Versioning](https://semv - 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` +- Image matrix link to radial linker and radial matrix ### Fixed diff --git a/app/javascript/vue/components/radials/linker/constants/links.js b/app/javascript/vue/components/radials/linker/constants/links.js index df6b7b0fe1..823f0f1360 100644 --- a/app/javascript/vue/components/radials/linker/constants/links.js +++ b/app/javascript/vue/components/radials/linker/constants/links.js @@ -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' diff --git a/app/javascript/vue/components/radials/linker/links/Otu.js b/app/javascript/vue/components/radials/linker/links/Otu.js index ad39427c8d..ed573a8040 100644 --- a/app/javascript/vue/components/radials/linker/links/Otu.js +++ b/app/javascript/vue/components/radials/linker/links/Otu.js @@ -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] } diff --git a/app/javascript/vue/components/radials/linker/radial.vue b/app/javascript/vue/components/radials/linker/radial.vue index 2c7811798f..4b123dec54 100644 --- a/app/javascript/vue/components/radials/linker/radial.vue +++ b/app/javascript/vue/components/radials/linker/radial.vue @@ -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) { @@ -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 }) { diff --git a/app/javascript/vue/components/radials/matrix/components/ImageMatrix.vue b/app/javascript/vue/components/radials/matrix/components/ImageMatrix.vue new file mode 100644 index 0000000000..f972922407 --- /dev/null +++ b/app/javascript/vue/components/radials/matrix/components/ImageMatrix.vue @@ -0,0 +1,26 @@ + + + diff --git a/app/javascript/vue/components/radials/matrix/radial.vue b/app/javascript/vue/components/radials/matrix/radial.vue index 0851e61508..fc349ee2c0 100644 --- a/app/javascript/vue/components/radials/matrix/radial.vue +++ b/app/javascript/vue/components/radials/matrix/radial.vue @@ -9,19 +9,33 @@ diff --git a/app/javascript/vue/tasks/observation_matrices/dashboard/components/buttonImageMatrix.vue b/app/javascript/vue/tasks/observation_matrices/dashboard/components/buttonImageMatrix.vue index d0311c2acb..dc7509f99a 100644 --- a/app/javascript/vue/tasks/observation_matrices/dashboard/components/buttonImageMatrix.vue +++ b/app/javascript/vue/tasks/observation_matrices/dashboard/components/buttonImageMatrix.vue @@ -22,9 +22,7 @@ export default { methods: { openImageMatrix() { window.open( - `${RouteNames.ImageMatrix}?otu_filter=${this.otuIds.join( - '|' - )}&view=true`, + `${RouteNames.ImageMatrix}?otu_filter=${this.otuIds.join('|')}`, '_blank' ) } diff --git a/app/javascript/vue/tasks/observation_matrices/image/app.vue b/app/javascript/vue/tasks/observation_matrices/image/app.vue index 5375a9d133..8aef8a44ef 100644 --- a/app/javascript/vue/tasks/observation_matrices/image/app.vue +++ b/app/javascript/vue/tasks/observation_matrices/image/app.vue @@ -96,7 +96,6 @@ @@ -106,6 +105,7 @@ import { GetterNames } from './store/getters/getters' import { MutationNames } from './store/mutations/mutations.js' import { RouteNames } from '@/routes/routes' import { ActionNames } from './store/actions/actions' +import { URLParamsToJSON } from '@/helpers' import MatrixTable from './components/MatrixTable.vue' import SpinnerComponent from '@/components/ui/VSpinner.vue' @@ -178,13 +178,13 @@ export default { }, created() { - const urlParams = new URLSearchParams(window.location.search) - const obsIdParam = urlParams.get('observation_matrix_id') - const otuFilterParam = urlParams.get('otu_filter') - const rowFilterParam = urlParams.get('row_filter') - const page = urlParams.get('page') + const urlParams = URLParamsToJSON(window.location.href) + const obsIdParam = urlParams.observation_matrix_id + const otuFilterParam = urlParams.otu_filter || urlParams.otu_id?.join('|') + const rowFilterParam = urlParams.row_filter + const page = urlParams.page - this.editMode = urlParams.get('edit') === 'true' + this.editMode = urlParams.edit if (otuFilterParam) { this.otuFilter = otuFilterParam diff --git a/app/javascript/vue/tasks/observation_matrices/image/components/View/Main.vue b/app/javascript/vue/tasks/observation_matrices/image/components/View/Main.vue index f0dcf98f50..096f7e3333 100644 --- a/app/javascript/vue/tasks/observation_matrices/image/components/View/Main.vue +++ b/app/javascript/vue/tasks/observation_matrices/image/components/View/Main.vue @@ -131,11 +131,6 @@ export default { matrixId: { type: [Number, String], default: undefined - }, - - otusId: { - type: [String, Array], - default: () => [] } }, diff --git a/app/javascript/vue/tasks/otu/filter/App.vue b/app/javascript/vue/tasks/otu/filter/App.vue index 8b8ff6088d..1e04d21625 100644 --- a/app/javascript/vue/tasks/otu/filter/App.vue +++ b/app/javascript/vue/tasks/otu/filter/App.vue @@ -25,18 +25,19 @@ />