From 6f0f17978337f4405d1d68e7fe7403248caa21c1 Mon Sep 17 00:00:00 2001 From: Angelina Uno-Antonison Date: Mon, 23 Oct 2023 16:53:18 -0500 Subject: [PATCH] Animal models updates page correctly (#147) * fixed the endpoints with the updated values * removed histology images hard code --- backend/src/repository/analysis_collection.py | 2 +- frontend/src/views/AnalysisView.vue | 18 +++++++++++------- frontend/test/views/AnalysisView.spec.js | 7 +------ 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/backend/src/repository/analysis_collection.py b/backend/src/repository/analysis_collection.py index 87178bc5..1e015141 100644 --- a/backend/src/repository/analysis_collection.py +++ b/backend/src/repository/analysis_collection.py @@ -441,7 +441,7 @@ def attach_section_supporting_evidence_link( updated_field = None for field in updated_section['content']: - if field['field'] == 'Veterinary Pathology Imaging': + if field['field'] == field_name: field['value'] = [field_value_link] updated_field = field diff --git a/frontend/src/views/AnalysisView.vue b/frontend/src/views/AnalysisView.vue index c390943e..977599d8 100644 --- a/frontend/src/views/AnalysisView.vue +++ b/frontend/src/views/AnalysisView.vue @@ -541,7 +541,8 @@ export default { const updatedFieldIndex = updatedSection.content.findIndex((row) => { return row.field == field; }); - updatedSection.content.splice(updatedFieldIndex, 1, updatedAnalysisSectionField.field_value); + updatedSection.content.splice(updatedFieldIndex, 1, updatedAnalysisSectionField.updated_row); + this.replaceAnalysisSection(updatedSection); } catch (error) { console.error('Updating the analysis did not work'); @@ -554,23 +555,20 @@ export default { .cancelText('Cancel') .confirm(`Removing '${attachment.name}' from ${field} in ${section}?`); - console.log(attachment); - if (!confirmedDelete) { return; } - let updatedAnalysisSectionField; try { if ( 'file' === attachment.type) { - updatedAnalysisSectionField = await Analyses.removeSectionSupportingEvidenceFile( + await Analyses.removeSectionSupportingEvidenceFile( this.analysis_name, section, field, attachment.attachment_id, ); } else if ( 'link' === attachment.type ) { - updatedAnalysisSectionField = await Analyses.removeSectionSupportingEvidenceLink( + await Analyses.removeSectionSupportingEvidenceLink( this.analysis_name, section, field, @@ -584,11 +582,17 @@ export default { return sectionToFind.header == section; }); + const fieldToUpdate = updatedSection.content.find((row) => { + return row.field == field; + }); + const updatedFieldIndex = updatedSection.content.findIndex((row) => { return row.field == field; }); - updatedSection.content.splice(updatedFieldIndex, 1, updatedAnalysisSectionField.field_value); + fieldToUpdate.value = []; + + updatedSection.content.splice(updatedFieldIndex, 1, fieldToUpdate); this.replaceAnalysisSection(updatedSection); } catch (error) { await notificationDialog.title('Failure').confirmText('Ok').alert(error); diff --git a/frontend/test/views/AnalysisView.spec.js b/frontend/test/views/AnalysisView.spec.js index f03b4125..15148171 100644 --- a/frontend/test/views/AnalysisView.spec.js +++ b/frontend/test/views/AnalysisView.spec.js @@ -564,7 +564,7 @@ describe('AnalysisView', () => { mockedAttachSectionSupportingEvidence.returns({ header: 'Mus_musculus (Mouse) Model System', field: 'Veterinary Pathology Imaging', - field_value: { + updated_row: { type: 'section-supporting-evidence', field: 'Veterinary Pathology Imaging', value: [{ @@ -609,11 +609,6 @@ describe('AnalysisView', () => { mockedRemoveSectionSupportingEvidenceFile.resolves({ header: 'Mus_musculus (Mouse) Model System', field: 'Veterinary Histology Report', - field_value: { - type: 'section-supporting-evidence', - field: 'Veterinary Histology Report', - value: [], - }, }); const mouseSection = wrapper.getComponent('[id=Mus_musculus (Mouse) Model System]');