WEB-714: Add submit button to user settings#3142
WEB-714: Add submit button to user settings#3142DeathGun44 wants to merge 1 commit intoopenMF:devfrom
Conversation
Signed-off-by: DeathGun44 <krishnamewara841@gmail.com>
|
Note
|
| Cohort / File(s) | Summary |
|---|---|
Settings Component UI & Logic src/app/settings/settings.component.html, src/app/settings/settings.component.scss, src/app/settings/settings.component.ts |
Adds Submit button to form with conditional enable/disable based on hasChanges flag; implements change tracking by merging valueChanges from form controls; persists settings through SettingsService methods; integrates AlertService for success feedback; manages component lifecycle with OnDestroy and destroy$ Subject pattern. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
- steinwinde
🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Merge Conflict Detection | ❌ Merge conflicts detected (24 files): ⚔️ src/app/clients/create-client/create-client.component.ts (content)⚔️ src/app/core/utils/datatables.ts (content)⚔️ src/app/organization/bulk-loan-reassignmnet/bulk-loan-reassignmnet.component.ts (content)⚔️ src/app/organization/fund-mapping/fund-mapping.component.ts (content)⚔️ src/app/products/loan-products/loan-product-stepper/loan-product-accounting-step/advanced-accounting-mapping-rule/advanced-accounting-mapping-rule.component.ts (content)⚔️ src/app/products/manage-delinquency-buckets/delinquency-range/create-range/create-range.component.ts (content)⚔️ src/app/settings/settings.component.html (content)⚔️ src/app/settings/settings.component.scss (content)⚔️ src/app/settings/settings.component.ts (content)⚔️ src/app/system/manage-jobs/workflow-jobs/workflow-jobs.component.html (content)⚔️ src/app/tasks/checker-inbox-and-tasks-tabs/loan-disbursal/loan-disbursal.component.ts (content)⚔️ src/assets/translations/cs-CS.json (content)⚔️ src/assets/translations/de-DE.json (content)⚔️ src/assets/translations/en-US.json (content)⚔️ src/assets/translations/es-CL.json (content)⚔️ src/assets/translations/es-MX.json (content)⚔️ src/assets/translations/fr-FR.json (content)⚔️ src/assets/translations/it-IT.json (content)⚔️ src/assets/translations/ko-KO.json (content)⚔️ src/assets/translations/lt-LT.json (content)⚔️ src/assets/translations/lv-LV.json (content)⚔️ src/assets/translations/ne-NE.json (content)⚔️ src/assets/translations/pt-PT.json (content)⚔️ src/assets/translations/sw-SW.json (content)These conflicts must be resolved before merging into dev. |
Resolve conflicts locally and push changes to this branch. |
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main change: adding a submit button to user settings instead of auto-save behavior. |
| Docstring Coverage | ✅ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
⚔️ Resolve merge conflicts (beta)
- Auto-commit resolved conflicts to branch
WEB-714/enable-submit-to-user-settings - Post resolved changes as copyable diffs in a comment
No actionable comments were generated in the recent review. 🎉
🧹 Recent nitpick comments
src/app/settings/settings.component.html (1)
25-25: Use a stable identifier fortrackon object collections.
track languagetracks by object reference, which won't help Angular optimize re-renders if thelanguagesarray is ever re-created. Use the uniquecodeproperty instead.- `@for` (language of languages; track language) { + `@for` (language of languages; track language.code) {As per coding guidelines: "verify … trackBy on *ngFor" — the
@fortrack expression should use a stable identity key for object collections.src/app/settings/settings.component.ts (2)
93-106:hasChangesdoesn't reset when the user reverts to the original values.If a user changes a dropdown and then changes it back to the initial value, the Submit button remains enabled. For a simple settings form this is low-impact, but you could compare against the initial snapshot to get true dirty detection.
💡 Optional: track initial values for accurate dirty state
+ private initialLanguage: any; + private initialDateFormat: string; + private initialDecimals: string; + ngOnInit() { this.language.patchValue(this.settingsService.language, { emitEvent: false }); this.dateFormat.patchValue(this.settingsService.dateFormat, { emitEvent: false }); this.decimalsToDisplay.patchValue(this.settingsService.decimals, { emitEvent: false }); + this.initialLanguage = this.language.value; + this.initialDateFormat = this.dateFormat.value; + this.initialDecimals = this.decimalsToDisplay.value; this.trackChanges(); } trackChanges(): void { merge(this.language.valueChanges, this.dateFormat.valueChanges, this.decimalsToDisplay.valueChanges) .pipe(takeUntil(this.destroy$)) .subscribe(() => { - this.hasChanges = true; + this.hasChanges = + this.language.value?.code !== this.initialLanguage?.code || + this.dateFormat.value !== this.initialDateFormat || + this.decimalsToDisplay.value !== this.initialDecimals; }); }
108-117: Submit assumes all service calls succeed; consider updating initial snapshot on save.
settingsService.setLanguage/setDateFormat/setDecimalToDisplayappear synchronous (localStorage), so error handling isn't critical. However, ifsubmit()is considered a "save point," the initial values (if you adopt the suggestion above) should be updated here to keep dirty tracking accurate after a save.Also, the success alert message is hardcoded in English. Since other strings use the translate pipe, consider using
TranslateServicefor this message as well for i18n consistency.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
| this.hasChanges = false; | ||
| this.alertService.alert({ | ||
| type: 'Settings Update', | ||
| message: 'Settings saved successfully.' |
There was a problem hiding this comment.
Is there a way to translate this message?
Description
Replaced the silent auto-save behavior in User Settings with an explicit Submit button. Previously, the Main Configuration fields (Language, Date Format, Decimals to Display) were auto-saved on every dropdown change via
valueChangessubscriptions with no user feedback. This change adds:AlertService("Settings saved successfully.")takeUntilto prevent memory leaksThe submit button covers all previously working fields: Language, Date Format, and Decimals to Display.
Screenshots
Checklist
web-app/.github/CONTRIBUTING.md.Summary by CodeRabbit
Release Notes