-
Notifications
You must be signed in to change notification settings - Fork 433
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
Move away from @ng-dynamic-forms
#2216
Comments
related issue: #3226 |
Regarding this topic I'd propose to integrate specific parts of the ng-dynamic-forms library into the DSpace base code. Specifically, we should port the core and ui-ng-bootstrap modules. While @artlowel recently suggested migrating to ngx-formly, it’s important to note that ngx-formly is still based on Angular 13. In contrast, the current version of ng-dynamic-forms is built on Angular 16 and utilizes standalone components, which is advantageous for bundle size. Although ng-dynamic-forms requires updates to the latest versions of Angular and Bootstrap/ng-bootstrap, we (4science) have already initiated this process with a pull request. By incorporating the necessary parts of ng-dynamic-forms into the base code, we can minimize the workload associated with migrating to a different library. This approach will also simplify code maintenance and version management. This work could be done in two different phases: Phase 1: Initial Integration, in order to move the necessary parts of ng-dynamic-forms into the DSpace base code.
Estimated Time: 2 days Phase 2: Refactor the DSpace code that currently uses a custom extension of ui-ng-bootstrap https://github.com/DSpace/dspace-angular/tree/main/src/app/shared/form/builder/ds-dynamic-form-ui.
Estimated Time: 4 days. |
The minimal required version of angular is version 13, but it is compatible with angular 17, as you can tell from my proof of concept. It builds without peer dependency warnings. It is likely also compatible with 18, but I haven't verified that myself yet. Its dependencies were last updated last week, so I'm sure if there were breaking changes they'd make a dedicated version for angular 18
There are very few DSpace developers that understand how to even use the ng-dynamic-forms library well enough to make meaningful changes to the submission. If we were to include it into our codebase they'd have to learn to maintain the lib itself too. That's just not something that is likely to happen. It would also be a big PR that we couldn't really review properly, but would just have to merge and hope for the best. We should take this opportunity to move away from that lib, and rewrite the submission into something that is easier to understand, modify and maintain. It doesn't have to be formly, as discussed, I'm also working on a PoC using Angular 18 forms, but I'm convinced sticking with ng-dynamic-forms is a bad idea |
However, it’s not just about compatibility. It still relies on the old modules approach, which isn’t optimized for the standalone approach (see ngx-formly/ngx-formly#3721 (comment))
In my opinion, replacing it with another library would present the same challenge. The main difference with my proposal is the workload. Both replacing the library and starting from scratch would require a significant amount of time, around 100-150 hours, or even more if we consider fixing bugs and addressing accessibility issues we’ve already resolved. By including the library in our codebase, we would have a working solution that could serve as a solid foundation for improvements, especially considering the new features available in Angular 18, such as the unified control state change events combined with Signals. |
But we could design it to be much easier to understand and much easier to maintain. It currently isn't, and bringing in that entire lib is only going to exacerbate that problem. Of course it would be less work right now. But we'd be pushing the problem of the refactor we've known has been necessary for years down the road yet again, taking on a bunch of extra code to maintain in the process. By going for the quick fix now, the submission will remain hard to modify, debug and maintain, which will end up costing us a lot more effort in the long run.
This lib is only going to get support for angular 18 and things like "unified control state change events combined with signals" if we add it ourselves. So we might as well do that without that lib in the first place, or get it in the next version of formly |
Issue / context
During the Angular 15 upgrade, @Atmire-Kristof noticed conflicts between the newer versions of the following libraries:
ng-bootstrap
@ng-dynamic-forms
@ng-dynamic-forms/ui-ng-bootstrap
still requiresng-bootstrap
v11 as a peer dependency, which itself doesn't support Angular 15ng-bootstrap
versions, so this is not a viable workaroundRather than do a half-upgrade we opted to leave both of these libraries as-is for now. This leads to peer dependency mismatch warnings, but everything remains functional.
Solution
It looks like development of
@ng-dynamic-forms
has slowed down as of late, and this version mismatch is a bit of a red flag. Therefore, we should consider moving away from this library and use the default Angular forms instead for more stability.This would involve a significant refactor of DSpace Angular submission.
References
Add references/links to any related issues or PRs. These may include:
Related to [Submission Refactor] Refactor Entity Relationships to be modified via WorkspaceItem #858
Left out of Angular 15 upgrade #2204
The text was updated successfully, but these errors were encountered: