Skip to content

[MDS-6987] Add Figures and Documents to Condition Data Variable Menu - #3992

Merged
alazar-aot merged 13 commits into
developfrom
MDS-6987-Add-Figures-and-Documents-to-CDV-menu
Sep 22, 2026
Merged

alazar-aot merged 13 commits into
developfrom
MDS-6987-Add-Figures-and-Documents-to-CDV-menu

Conversation

@alazar-aot

@alazar-aot alazar-aot commented Sep 9, 2026 •

Copy link
Copy Markdown
Collaborator

Objective

MDS-6987

Why are you making this change? Provide a short explanation and/or screenshots

To allow permitting inspectors to more easily work with permit package references, the Condition Data Variable (CDV) Menu is to be updated to allow inspectors to insert permit package references into condition text when drafting the permit, so that the references remain accurate when permit package files are reordered or replaced.

  • Commit 1 Removed old CDV menu code and Flagsmith gating - moving forward we only use the 'new' CDV picker without any Flagsmith gate (Cleanup).
  • Commit 2 Add new Flagsmith Flag for this functionality.
  • Commit 3 Moved logic for determining permit-package ordering into single helper/utility function, updated unit tests accordingly and pointed all files that need this functionality to use the new helper. Added 'Permit Package files -> Figures/Documents' to CDV menu, gated by feature flag (these selections insert 'tokens' for the permit package files into the condition text)
  • Commit 4 Replaced the original Permit Condition 'plain text area' with a react-quill editor for the PermitConditionForm's condition filed (this is UI only), which includes a custom Quill embed blot that renders the 'label' (green or red 'pill' of Doc/Fig index and title) for an inserted Figure/Document reference. Small fix to preamble text area (keep using original textarea, not rich-text Quill editor) and run a WGAC pass on the changes using Claude
  • Commit 5 Added comment regarding preservation of GUID, for when 'Archive/Replace' functionality is implemented (risk of breaking the CDV references if guid is not maintained)
  • Commit 6 Added helper/utility function that checks if a Figure/Document is actually being referenced in any permit condition, used to warn users if they try to remove a file from the permit package that it will break the reference - also added unit tests for this new functionality
  • Commit 7 - Bug Fix Fixed bug where copying and pasting condition text introduced a series of errors - related to not having a unique CSS/className attribute on the 'pill' elements
  • Commit 8 - UX Improvement Updated 'this figure/doc is referenced' warning to fire immediately after trying to de-select the 'part of permit package'checkbox, instead of before trying to save
  • Commit 9 Ensured that issued permits correctly resolve Figure/Document references - they appear as the literal index (1.2, 1.3, etc) and title - not in a 'pill'. If a removed reference is included, it gets the literal text of 'Reference unavailable'.
  • Commit 10 Minor patches for es-lint warnings and overall code improvements + cleanup
  • Commit 11 Claude Pass: Refactor @lru_cache to instead determine locked doc value once, and pass through rather than global cache
  • Commit 12 Fix failing unit tests
  • Commit 12 Resolve PR comments: Fix typo, update backend logic to determine the '1.1' locked row to match the frontend logic (and relevant unit tests), move variable substitution to before token extraction to avoid variable naming collisions, turn getPermitPackageFilesByType into an interface for proper typing

@alazar-aot alazar-aot added the 🛑 DO NOT MERGE This pull request will have potentially destructive or risky changes if merged. label Sep 9, 2026
…r/utility function, updated unit tests accordingly and pointed all files that need this functionality to use the new helper. Added 'Permit Package files -> Figures/Docuents' to CDV menu, gated by feature flag. These selections insert 'tokens' for the permit package files into the condtion text - currently rendered as {file:guid}
…-quill editor for the PermitConditionForm's condition filed (this is UI only), which includes a custom Quill embed blot that renders the 'label' (green or red 'pill' of Doc/Fig index and title) for an inserted Figure/Document reference. Small fix to preamble text area (keep using original textarea, not rich-text Quill editor) and run a WGAC pass on the changes using Claude
…ce' functionality is implented (risk of breaking the CDV references if guid is not maintained)
…ually being referenced in any permit condition, used to warn users if they try to remove a file from the permit package that it will break the reference. Added unit tests for this new functionality
…s of errors - related to not having a unique CSS/className attribute on the 'pill' elements
…fter trying to de-select the 'part of permit package'checkbox, instead of before trying to save (UX improvement)
…ces - they appear as the literal index (1.2, 1.3, etc) and title - not in a 'pill'. If a removed reference is included, it gets the literal text of 'Reference unavailable'.
…rences are resolved (rendered) in the issued permit correctly. Minor patches for es-lint warnings and overall code improvements + cleanup:
…e once, and pass through rather than global cache
@alazar-aot alazar-aot added 👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback. 🦕 Chonker This PR is very large and removed 🛑 DO NOT MERGE This pull request will have potentially destructive or risky changes if merged. labels Sep 21, 2026

@matbusby-fw matbusby-fw 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.

Looks great! Just had a few comments/suggestions.

Comment thread services/core-api/app/api/now_applications/now_template_transformer.py Outdated
Comment thread services/core-api/app/api/now_applications/now_template_transformer.py Outdated
Comment thread services/common/src/components/permits/ConditionRichTextEditor.tsx
Comment thread services/common/src/utils/permitPackageDocuments.ts Outdated
…'1.1' locked row to match the frontend logic (and relevant unit tests), move variable substitiution to before token extraction to avoid variable naming collisions, turn getPermitPackageFilesByType into an interface for proper typing
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed for 'bcgov-sonarcloud_mds_minespace-web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed for 'bcgov-sonarcloud_mds_common'

Failed conditions
28.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@matbusby-fw matbusby-fw 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.

Rock on till the end of time!

@alazar-aot
alazar-aot merged commit 89191ac into develop Sep 22, 2026
20 of 21 checks passed
@alazar-aot
alazar-aot deleted the MDS-6987-Add-Figures-and-Documents-to-CDV-menu branch September 22, 2026 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👍 Ready for review Pull request has been double checked by the author and is ready for comments and feedback. 🦕 Chonker This PR is very large

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants