Skip to content
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

Enhancement: Metadata edit confirmation dialog #898

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

joshsadam
Copy link
Contributor

@joshsadam joshsadam commented Jan 16, 2025

What does this PR do and why?

Describe in detail what your merge request does and why.

On the samples page, a confirmation dialogue will open when a metadata field is being edited and the user clicks away from a changed value. The user is presented with 2 options:

  1. Save: Save the updated value and revert the cell to the un-editing state, displaying the new value.
  2. Discard: Discard the updated value and revert the cell to the original value and render the unediting state.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other pull requests.

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Login as a user with privileges on a project (e.g. user5)
  2. Go to a project the user owns, and then to the project samples page.
  3. Toggle on metadata fields
  4. Click on a field and edit, then click away, the confirmation dialog should appear.
  5. Try to discard, and then save the new value.

PR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

This comment has been minimized.

- Added a confirmation dialog for metadata field edits in the samples table.
- Updated inline_edit_controller to log click events.
- Refactored HTML structure for the confirmation dialog with improved content and button actions.
- Adjusted tests to verify the presence and functionality of the confirmation dialog during metadata edits.
- Added a class to the content span in the viral button component to disable pointer events.
- Refactored the conditional rendering of icons in the viral button component for better readability.
- Changed the trimmed content rendering in the pathogen button component to use a span for consistency in structure.
- Removed automatic selection of input field in inline_edit_controller.js to streamline user experience.
- Updated confirmation dialog in _editing_field_cell.html.erb to include dynamic content and improved button labels for clarity.
- Refined translations in en.yml for consistency and clarity across various UI elements.
- Enhanced tests in samples_test.rb to verify the presence and functionality of the confirmation dialog during metadata edits.
…ed localization

- Added a new target 'newValue' in inline_edit_controller.js to facilitate dynamic updates in the confirmation dialog.
- Updated the confirmation dialog description in en.yml to use the new target for better clarity and maintainability.
- Improved user experience by ensuring the new value is displayed correctly during inline edits.
- Extracted the logic for updating the new value target into a private method #updateNewValueTarget for better readability and maintainability.
- Ensured that the new value is updated correctly during inline edits, enhancing the overall user experience.
…g button labels and value display

- Modified assertions in samples_test.rb to use updated button labels for the confirmation dialog, enhancing localization.
- Changed the selector for verifying the new value display to ensure it accurately reflects the updated UI structure.
…ts and improved structure

- Added a new test to verify the confirmation dialog can be cancelled, ensuring the original value is retained.
- Improved the organization of existing tests by clearly marking setup, actions, and verification sections for better readability.
- Updated assertions to reflect the latest UI changes, ensuring accurate verification of button labels and value displays.
@joshsadam joshsadam force-pushed the metadata-edit-confirm branch from 4a0833d to 8388a6c Compare January 16, 2025 19:49
- Standardized quotation marks in English and French locale files for better consistency.
- Added confirmation dialog metadata editing fields in both English and French locale files to enhance user experience.
- Ensured all relevant error messages and descriptions are properly localized for improved clarity.
@joshsadam joshsadam self-assigned this Jan 17, 2025

This comment has been minimized.

- Updated handleBlurEvent to reset input value to original if no changes are detected.
- Enhanced #hasValueChanged method to ensure it only returns true for non-empty, modified values, improving validation logic.
@joshsadam joshsadam requested a review from ericenns January 17, 2025 13:50
- Adjusted indentation in action sections of tests to ensure consistent formatting.
- Simplified event handling in inline_edit_controller.js by consolidating methods for keyboard and blur events.
- Replaced the previous handleBlurEvent and inputKeydown methods with more concise keydown and blur methods.
- Enhanced the reset and submit logic to improve clarity and maintainability.
- Updated the corresponding action attributes in _editing_field_cell.html.erb to reflect the new method names.

This comment has been minimized.

Copy link

Code Metrics Report

Coverage Test Execution Time
92.9% 9m54s

Code coverage of files in pull request scope (100.0%)

Files Coverage
app/components/viral/button_component.html.erb 100.0%
app/views/shared/samples/metadata/fields/_editing_field_cell.html.erb 100.0%

Reported by octocov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant