Skip to content

Commit

Permalink
fix: ensure scientific metadata table display correctly when unit is …
Browse files Browse the repository at this point in the history
…missing (#1744)

## Description
This PR fixes metadata table crash when no unit is provided in the
scientific metadata table

![image](https://github.com/user-attachments/assets/b4f96d2b-f047-4c86-bec3-5bbc7caccb37)


## Motivation
Background on use case, changes needed


## Fixes:
Please provide a list of the fixes implemented in this PR

* Items added


## Changes:
Please provide a list of the changes implemented by this PR

* changes made


## Tests included
- [x] Included for each change/fix?
- [x] Passing? (Merge will not be approved unless this is checked) 

## Documentation
- [ ] swagger documentation updated \[required\]
- [ ] official documentation updated \[nice-to-have\]

### official documentation info
If you have updated the official documentation, please provide PR # and
URL of the pages where the updates are included

## Backend version
- [ ] Does it require a specific version of the backend
- which version of the backend is required:

## Summary by Sourcery

Bug Fixes:
- Prevent metadata table crash when no unit is provided.
  • Loading branch information
nitrosx authored Feb 7, 2025
2 parents 9977cfd + d1be644 commit a505802
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export class MetadataEditComponent implements OnInit, OnChanges {
typeof this.metadata[key] === "object" &&
"value" in (this.metadata[key] as ScientificMetadata)
) {
if (this.metadata[key]["unit"].length > 0) {
if (this.metadata[key].unit?.length > 0) {
field = this.formBuilder.group({
fieldType: this.formControlFields["fieldType"]("quantity"),
fieldName: this.formControlFields["fieldName"](key),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Unit
</mat-header-cell>
<mat-cell *matCellDef="let metadata">
<ng-template [ngIf]="metadata.unit.length > 0" [ngIfElse]="noUnit">
<ng-template [ngIf]="metadata.unit?.length > 0" [ngIfElse]="noUnit">
<span class="unit-input">
{{ metadata.unit | prettyUnit }}
<mat-icon
Expand Down

0 comments on commit a505802

Please sign in to comment.