Skip to content

Initial SaveButtonComponent implementation #3261

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

Open
wants to merge 25 commits into
base: feature/ng19-forms
Choose a base branch
from

Conversation

shilob
Copy link
Member

@shilob shilob commented Aug 18, 2025

This pull request introduces a new SaveButtonComponent to the Angular form system and refactors the form handling logic to use Angular signals for better reactivity and maintainability. The changes include the implementation of the save button, updates to the form component to support signal-based parameters and save logic, and the integration of the new component into the form's module and static dictionary. Additionally, comprehensive unit tests for the SaveButtonComponent are added.

New Save Button Feature:

  • Implemented SaveButtonComponent:

    • Adds a save button that interacts with the parent form, triggers save logic, and disables itself when the form is unchanged or invalid.
    • Integrated into the form module, static component dictionary, and test helpers for full support. [1] [2] [3] [4] [5] [6]
  • Added unit tests for SaveButtonComponent:

    • Tests creation, save action, and disabled state when the form is unchanged.

Form Component Refactoring and Enhancements:

  • Refactored FormComponent to use Angular signals:

    • Replaced @Input properties with signals for oid, recordType, formName, editMode, and downloadAndCreateOnInit.
    • Added logic to handle changes to these parameters, including reinitializing the form when the OID changes. [1] [2] [3] [4] [5] [6]
    • Updated all usages of these properties to use the new signal-based approach. [1] [2]
  • Implemented form save logic:

    • Added saveForm method to handle form submission, including validation, pristine/dirty checks, and status updates.
    • Integrated with a RecordService for create/update actions and error handling.
    • Exposed dataStatus for use by child components (e.g., SaveButtonComponent).

Minor Cleanup:

  • Removed unused getter from TabContentComponent.
  • Minor import cleanup in base form field component.

These changes collectively improve the form system's usability, testability, and maintainability, and introduce a reusable save button component.

shilob added 17 commits July 22, 2025 15:45
* feature/ng19-forms:
  Extract typescript types used by server and client (#3153)

# Conflicts:
#	angular/projects/researchdatabox/form/src/app/form.service.ts
#	angular/projects/researchdatabox/form/src/app/static-comp-field.dictionary.ts
… Moved the FormComponent's FormGroup creation until after all the components have been intialised.
…tab initialization, enhance test coverage, and ensure proper CSS class application.
…ieval

- Implemented a test for tab switching in TabComponent.
- Enhanced TabComponent to correctly apply active classes and aria attributes.
- Added a convenience method in FormComponent to find component definitions by name.
* feature/ng19-forms:
  Update server-side processing to create form config for client-side (#3179)
  try to include more of the details in the logging
  Bugfix trigger service regex not working (#3152)
  Bugfix: deselect children when parent node is deselected as default behaviour (#3120)
  Build(deps): Bump wkt-parser-helper from 4.2.0 to 5.0.0 (#3062)
  Build(deps): Bump bootstrap from 5.3.6 to 5.3.7 (#3072)
  Build(deps): Bump postcss from 8.5.5 to 8.5.6 (#3068)
  Build(deps): Bump axios from 1.9.0 to 1.10.0 (#3067)
  Build(deps): Bump @researchdatabox/sails-ng-common from 0.1.0 to 0.2.1 (#3064)
  Build(deps): Bump i18next from 24.2.3 to 25.2.1 (#3063)

# Conflicts:
#	typescript/form-config/default-1.0-draft.ts
* feature/ng19-forms: (35 commits)
  add npm run script to build raido package
  Feature ng19 forms config baseline migration script implementation (#3232)
  Update config.yml
  Build(deps): Bump sails from 1.5.14 to 1.5.15 (#3231)
  Build(deps): Bump luxon from 3.6.1 to 3.7.1 (#3226)
  Build(deps): Bump mongodb from 6.17.0 to 6.18.0 (#3230)
  Build(deps): Bump express-session from 1.18.1 to 1.18.2 (#3229)
  Build(deps): Bump less from 4.3.0 to 4.4.0 (#3228)
  Build(deps): Bump pino from 9.7.0 to 9.8.0 (#3227)
  Build(deps-dev): Bump chai from 5.2.0 to 5.2.1 (#3225)
  Build(deps): Bump mini-css-extract-plugin from 2.9.2 to 2.9.3 (#3224)
  Build(deps-dev): Bump typescript from 5.8.3 to 5.9.2 in /core (#3211)
  Merge branch 'develop' into feature/ng19-forms_server-api-round-4
  Server-side record merge, compare, and validation (#3197)
  TabComponent initial implementation (#3209)
  Build(deps): Bump dotenv from 16.5.0 to 17.2.1 (#3193)
  Build(deps-dev): Bump supertest from 7.1.1 to 7.1.4 (#3180)
  Build(deps-dev): Bump form-data from 2.5.1 to 2.5.5 in /support/raido (#3177)
  Build(deps): Bump core-js from 3.43.0 to 3.45.0 (#3213)
  Build(deps): Bump webpack from 5.99.9 to 5.101.0 (#3198)
  ...

# Conflicts:
#	angular/projects/researchdatabox/form/src/app/component/tab.component.ts
#	angular/projects/researchdatabox/form/src/app/form.component.ts
#	angular/projects/researchdatabox/form/src/app/static-comp-field.dictionary.ts
#	packages/sails-ng-common/src/config/component/index.ts
#	typescript/form-config/default-1.0-draft.ts
…e utility service with trimStringSignal method. Added validation when accessing FormComponent's string parameters. Added support to reload the form when the OID is changed.
…option for improved form submission handling.
…alidation'. Added tests. Added providers param when preparing the TestBed.
@shilob shilob self-assigned this Aug 18, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new SaveButtonComponent for Angular forms and refactors the FormComponent to use signals for better reactivity. The main purpose is to add a save button that can interact with the parent form, trigger save logic, and disable itself when the form is unchanged or invalid.

  • Implementation of a new SaveButtonComponent with configuration options for save behavior
  • Refactoring of FormComponent to use Angular signals instead of @Input properties for better reactivity
  • Addition of form save logic with create/update operations via RecordService

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
typescript/form-config/default-1.0-draft.ts Adds save button configuration and minor formatting updates
packages/sails-ng-common/src/config/component/save-button.model.ts Defines TypeScript model interfaces for the SaveButtonComponent
packages/sails-ng-common/src/config/component/index.ts Exports the new save button model types
angular/projects/researchdatabox/portal-ng-common/src/lib/utility.service.ts Adds utility method for handling string signals
angular/projects/researchdatabox/portal-ng-common/src/lib/record.service.ts Implements create/update methods and result type for record operations
angular/projects/researchdatabox/portal-ng-common/src/lib/form/form-field-base.component.ts Minor cleanup of import and access modifier
angular/projects/researchdatabox/form/src/app/static-comp-field.dictionary.ts Registers SaveButtonComponent in the component dictionary
angular/projects/researchdatabox/form/src/app/helpers.spec.ts Updates test helpers to support new signal-based FormComponent API
angular/projects/researchdatabox/form/src/app/form.module.ts Declares SaveButtonComponent in the module
angular/projects/researchdatabox/form/src/app/form.component.ts Major refactoring to use signals and adds save functionality
angular/projects/researchdatabox/form/src/app/component/tab.component.ts Removes unused getter method
angular/projects/researchdatabox/form/src/app/component/save-button.component.ts Implements the new SaveButtonComponent
angular/projects/researchdatabox/form/src/app/component/save-button.component.spec.ts Adds comprehensive unit tests for SaveButtonComponent
Comments suppressed due to low confidence (1)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

shilob and others added 4 commits August 18, 2025 16:29
* feature/ng19-forms:
  populate client form from server data (#3233)
  Build(deps): Bump fs-extra from 11.3.0 to 11.3.1 (#3237)
  Build(deps): Bump mini-css-extract-plugin from 2.9.3 to 2.9.4 (#3236)
  Build(deps): Bump csv-stringify from 6.5.2 to 6.6.0 (#3235)
  Feature: Upgrade to rxjs7 (#3246)
  Build(deps): Bump pino from 9.8.0 to 9.9.0 (#3245)
  Build(deps): Bump copy-webpack-plugin from 13.0.0 to 13.0.1 (#3243)
  Build(deps): Bump webpack from 5.101.0 to 5.101.1 (#3242)
  Build(deps): Bump i18next from 25.3.2 to 25.3.4 (#3239)
  Build(deps): Bump sass from 1.89.2 to 1.90.0 (#3238)
  Feature: Remove MomentJS (#3244)
  Add init flag to redbox portal as a replacement for dumb-init. (#3241)
  Build(deps): Migrate to Font Awesome 6 and update package references

# Conflicts:
#	angular/projects/researchdatabox/form/src/app/form.module.ts
…and fixed SaveButtonComponent import in FormModule.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.97%. Comparing base (709cf65) to head (4a1d733).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           feature/ng19-forms    #3261      +/-   ##
======================================================
+ Coverage               49.93%   49.97%   +0.04%     
======================================================
  Files                     199      200       +1     
  Lines                   12147    12213      +66     
  Branches                 1984     2008      +24     
======================================================
+ Hits                     6065     6103      +38     
- Misses                   5821     5849      +28     
  Partials                  261      261              
Flag Coverage Δ
backend-bruno 38.66% <ø> (ø)
backend-mocha 45.20% <ø> (ø)
frontend-app-config 97.87% <ø> (ø)
frontend-core-lib 51.75% <ø> (-0.41%) ⬇️
frontend-dashboard 74.53% <ø> (ø)
frontend-deleted-records 86.59% <ø> (ø)
frontend-export 100.00% <ø> (ø)
frontend-form 62.74% <ø> (-0.10%) ⬇️
frontend-local-auth 100.00% <ø> (ø)
frontend-manage-roles 63.33% <ø> (ø)
frontend-manage-users 59.81% <ø> (ø)
frontend-report 95.06% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cofiem
Copy link
Contributor

cofiem commented Aug 18, 2025

What's the motivation for using model signals? I think it makes sense, but I want to know what prompted the change?

@shilob
Copy link
Member Author

shilob commented Aug 19, 2025

What's the motivation for using model signals? I think it makes sense, but I want to know what prompted the change?

To enable two-way integration if another NG component is creating and is interested in the Form app's OID and other parameters.

@shilob shilob closed this Aug 19, 2025
@shilob shilob reopened this Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants