Skip to content

feat: enable save button only when form is modified#5927

Merged
yuda110 merged 1 commit intomasterfrom
hotfix-save-button
Jun 4, 2025
Merged

feat: enable save button only when form is modified#5927
yuda110 merged 1 commit intomasterfrom
hotfix-save-button

Conversation

@yuda110
Copy link
Copy Markdown
Member

@yuda110 yuda110 commented Jun 4, 2025

Skip Review (optional)

  • Minor changes that don't affect the functionality (e.g. style, chore, ci, test, docs)
  • Previously reviewed in feature branch, further review is not mandatory
  • Self-merge allowed for solo developers or urgent changes

Description (optional)

Things to Talk About (optional)

Signed-off-by: yuda <yuda@megazone.com>
@yuda110 yuda110 requested a review from Copilot June 4, 2025 08:15
@vercel
Copy link
Copy Markdown

vercel bot commented Jun 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cost-report ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 4, 2025 8:18am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
console ⬜️ Ignored (Inspect) Visit Preview Jun 4, 2025 8:18am
web-storybook ⬜️ Ignored (Inspect) Jun 4, 2025 8:18am

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 4, 2025

✅ There are no commits in this PR that require review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jun 4, 2025

🎉 @skdud4659 has been randomly selected as the reviewer! Please review. 🙏

@github-actions github-actions bot requested a review from skdud4659 June 4, 2025 08:16
@yuda110 yuda110 removed the request for review from skdud4659 June 4, 2025 08:16
Copy link
Copy Markdown

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 ensures the Save button is only enabled when form values differ from the loaded configuration.

  • Adds a new isFormChanged computed property that deep-compares form state against the initial config
  • Updates the Save button’s disabled binding to include !isFormChanged
  • Imports isEqual from lodash for comparison
Comments suppressed due to low confidence (2)

apps/web/src/services/cost-explorer/components/AdvancedSettingsCostReportConfiguration.vue:67

  • [nitpick] The name isFormChanged is a bit generic; consider renaming to isFormModified or hasUnsavedChanges for clearer intent.
const isFormChanged = computed<boolean>(() => !isEqual(state.selectedLanguage, costReportConfig.value?.language)

apps/web/src/services/cost-explorer/components/AdvancedSettingsCostReportConfiguration.vue:289

  • There's no existing test to verify the Save button toggles based on form modifications; adding a unit or integration test for this behavior would help prevent regressions.
:disabled="isSaveDisabled || !isFormChanged"

Comment on lines +67 to 73
const isFormChanged = computed<boolean>(() => !isEqual(state.selectedLanguage, costReportConfig.value?.language)
|| !isEqual(state.selectedCurrency, costReportConfig.value?.currency)
|| !isEqual(Number(issueDate.value), Number(costReportConfig.value?.issue_day))
|| !isEqual(state.lastDayOfMonth, !!costReportConfig.value?.is_last_day)
|| !isEqual(state.enableAdjustments, !!costReportConfig.value?.adjustment_options?.enabled)
|| !isEqual(Number(manualAdjustablePeriod.value), Number(costReportConfig.value?.adjustment_options?.period)));

Copy link

Copilot AI Jun 4, 2025

Choose a reason for hiding this comment

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

Manually comparing each field can become hard to maintain as new settings are added; consider capturing the form state as an object and doing a single deep compare against a snapshot of the initial values.

Suggested change
const isFormChanged = computed<boolean>(() => !isEqual(state.selectedLanguage, costReportConfig.value?.language)
|| !isEqual(state.selectedCurrency, costReportConfig.value?.currency)
|| !isEqual(Number(issueDate.value), Number(costReportConfig.value?.issue_day))
|| !isEqual(state.lastDayOfMonth, !!costReportConfig.value?.is_last_day)
|| !isEqual(state.enableAdjustments, !!costReportConfig.value?.adjustment_options?.enabled)
|| !isEqual(Number(manualAdjustablePeriod.value), Number(costReportConfig.value?.adjustment_options?.period)));
const initialFormState = computed(() => ({
selectedLanguage: costReportConfig.value?.language,
selectedCurrency: costReportConfig.value?.currency,
issueDate: Number(costReportConfig.value?.issue_day),
lastDayOfMonth: !!costReportConfig.value?.is_last_day,
enableAdjustments: !!costReportConfig.value?.adjustment_options?.enabled,
manualAdjustablePeriod: Number(costReportConfig.value?.adjustment_options?.period),
}));
const isFormChanged = computed<boolean>(() => !isEqual(state, initialFormState.value));

Copilot uses AI. Check for mistakes.
@yuda110 yuda110 merged commit fac680d into master Jun 4, 2025
14 checks passed
@yuda110 yuda110 deleted the hotfix-save-button branch June 4, 2025 08:20
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