Skip to content
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

Animal models updates page correctly #147

Merged
merged 4 commits into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/src/repository/analysis_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 11 additions & 7 deletions frontend/src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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,
Expand All @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions frontend/test/views/AnalysisView.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [{
Expand Down Expand Up @@ -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]');
Expand Down