Skip to content

fix(web-app, observation): Angular 21+ modernizing for part 2 of observation-edit - #609

Merged
newmanw merged 5 commits into
developfrom
fix/observation-edit-angular-upgrading-part2
Nov 14, 2026
Merged

newmanw merged 5 commits into
developfrom
fix/observation-edit-angular-upgrading-part2

Conversation

@ktsorensenWX

@ktsorensenWX ktsorensenWX commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Converts the observation-edit components to standalone / signals / modern control flow as part of the Angular 21 migration.

  • Converted observation-edit-form and observation-edit (+ geometry family) to standalone components, signal inputs/queries, and @if/@for/@switch
  • Replaced deprecated @angular/animations (trigger/state/style/transition) with animate.enter/animate.leave + CSS; removed NoopAnimationsModule from specs (no longer used by Material)
  • Removed dead code (preview, dragHandle, canDeleteObservation, FilterService)
  • Renamed close output to closed (SonarQube: collides with the native DOM close event)
  • Rebased onto develop and reconciled with a parallel independent rewrite there (typed reactive forms, domain entity types), carrying forward its clone-aware default values, a cancel/discard sequencing fix (map no longer reverts unless the user actually discards), and a new ngOnDestroy map cleanup for abandoned new observations

Testing

  • tsc --noEmit clean (both tsconfigs)
  • ng build clean (no NG6008/compile errors)
  • Full Karma suite passing (1659/1659)

Manual Web-Side Testing

  • Create a new observation: default field values populate correctly, geometry adds to map, save succeeds
  • Edit an existing observation: existing values load correctly, save succeeds
  • Cancel with no changes: closes immediately, no discard dialog
  • Cancel with changes → "Discard": map geometry reverts to original, editor closes
  • Cancel with changes → "Keep editing": map is not reverted, editor stays open
  • Add a form, remove a form, reorder forms via drag-and-drop
  • Expand/collapse a form card — smooth animation, no flash
  • Edit geometry on the map from within the editor
  • Upload an attachment while editing; close the editor mid-upload and confirm no errors/leaked upload events
  • Primary/secondary feed field display, including a form whose primary field is archived (should show blank, not error)
  • Trigger a save error (e.g. offline) — error banner shows and dismisses correctly
  • Abandon a brand-new (unsaved) observation by navigating away — its temporary map feature is cleaned up
  • Closing the editor from the sidebar ((closed) binding) still works as before

@ktsorensenWX
ktsorensenWX requested a review from newmanw November 12, 2026 23:04
@ktsorensenWX
ktsorensenWX marked this pull request as draft November 12, 2026 23:04
@ktsorensenWX
ktsorensenWX marked this pull request as ready for review November 13, 2026 15:43
…effect

The geometry form started an edit session from an effect on its feature
input. The effect read currentFeature, so any write to it re-ran the
effect. FeatureEditor calls geometryChanged synchronously when it is
created for a point, and that write re-ran the effect, which created
another editor, in an endless loop that hung the browser when opening
the geometry editor. Map drags and vertex edits also re-ran it, losing
the drag, resetting the selected vertex and stacking feature editors.

Replace the feature input and effect with a startEdit() method that
the geometry component calls from startGeometryEdit().
@newmanw

newmanw commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

Found a regression while testing: clicking the expand/collapse chevron on a form card reloads the whole page.

Cause: before this PR, ObservationEditComponent was declared in HomeModule, which imports FormsModule, so Angular's NgForm directive attached to <form class="observation"> in observation-edit.component.html and blocked native submission. Now that the component is standalone and doesn't import FormsModule, that's a plain HTML form. Buttons without a type default to type="submit", so the chevron button (and "Delete Form") submits the form and the browser reloads. Pressing Enter in a single-line text field inside the form triggers the same implicit submit.

Suggested fix: the <form> isn't actually used as a form: no ngSubmit, no ngForm reference, no [formGroup] binding, and no CSS targets form (styles use .observation). Save reads the formGroup() signal directly. So I think the cleanest fix is to make it a <div>:

-    <form class="observation" name="observationForm" novalidate>
+    <div class="observation">
 ...
-    </form>
+    </div>

Importing FormsModule would also work, but it would just bring back the old accidental protection for a form nothing uses.

@newmanw

newmanw commented Nov 13, 2026

Copy link
Copy Markdown
Collaborator

web-app/src/app/observation/observation-edit/observation-edit.component.ts line 501

Pre-existing, something I found in testing, since we're in here: on a network failure (offline, blocked, CORS) event.response is an HttpErrorResponse whose .error is a ProgressEvent, so this snackbar shows [object ProgressEvent]. It only reads well when the server returns a plain-string error. Can we fall back to a friendly message when it isn't a string?

const error = event.response?.error;
this.snackBar.open(typeof error === 'string' ? error : 'Unable to upload attachment.', undefined, { duration: 4000 });

@ktsorensenWX
ktsorensenWX requested a review from newmanw November 13, 2026 23:09

@newmanw newmanw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the updates look good. One leftover: closed moved to output(), but the other outputs in the folder are still @Output() ... = new EventEmitter(). Can these move too?

  • observation-edit-form.component.ts:57-58: remove, featureEdit
  • observation-edit-geometry.component.ts:32: featureEdit
  • observation-edit-geometry-form.component.ts:80-81: save, cancel
  • observation-edit-geometry-map.component.ts:14: onEdit

@ktsorensenWX
ktsorensenWX requested a review from newmanw November 14, 2026 21:22
@sonarqubecloud

Copy link
Copy Markdown

@newmanw newmanw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Kris

@newmanw
newmanw merged commit ba5ba65 into develop Nov 14, 2026
15 checks passed
@newmanw
newmanw deleted the fix/observation-edit-angular-upgrading-part2 branch November 14, 2026 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants