Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: Edit line list metadata in place (#864)
* feat: ✨ Initial work on editing line list * feat: Add check_editable route to project for enhanced editing capabilities * feat: Enhance sample editing functionality with update_field action and form improvements - Added a new `update_field` action in the SamplesController to handle field updates. - Updated the `check_editable` method to pass the current value to the edit form. - Modified the `_edit_field_form` partial to include hidden fields for original value and format. - Updated routes to include the new `update_field` patch route for samples. - Improved the HTML structure of the edit field form for better integration with Turbo Streams. * feat: Implement editable cell component for enhanced inline editing of sample fields - Added `EditableCell` component to streamline the rendering of editable table cells. - Refactored `table_component.html.erb` to utilize the new `EditableCell` for cleaner code and improved maintainability. - Updated `samples_controller.rb` to render Turbo Stream updates for editable fields. - Introduced `inline_edit_controller.js` to manage focus and submission of inline edit forms. - Enhanced `_edit_field_form.html.erb` to integrate with the new inline editing functionality. - Created `_editable_table_field.html.erb` partial to encapsulate editable cell rendering logic. * feat: Refactor sample metadata update logic in SamplesController - Replaced direct update call with a new service object for handling metadata updates. - Enhanced the update process to better manage field updates and original values. - Improved code readability and maintainability by encapsulating update logic within a dedicated service. * feat: Refactor update_field action in SamplesController for improved error handling and code organization - Introduced private methods to encapsulate logic for setting field variables and updating sample fields. - Enhanced error handling by rendering appropriate responses based on sample validation errors. - Improved code readability and maintainability by organizing the update process into dedicated methods. * feat: Enhance editable cell functionality and refactor update_field action - Updated the styling of the submit button in the EditableCell component for improved visual consistency. - Refactored the update_field action in SamplesController to streamline the update process using a single service call. - Improved the HTML structure of the edit field form to enhance integration with Turbo Streams and maintain a consistent user experience. * feat: Add test for editing sample fields in samples_test.rb - Introduced a new test case to verify the functionality of editing a sample field. - The test navigates to the sample's edit page, interacts with the metadata toggle, and checks for the correct display of the sample's metadata. - Ensures that the edit field button is functional and properly integrated with the existing sample editing features. * feat: Implement inline editing for sample fields with check_editable and update_field actions - Added `check_editable` method in SamplesController to verify field editability and render appropriate forms. - Introduced `update_field` action to handle updates for sample fields, utilizing a dedicated service for processing. - Created `_edit_field_form.html.erb` partial for inline editing, including necessary hidden fields for seamless updates. - Added `_editable_table_field.html.erb` partial to encapsulate editable cell rendering logic. - Updated routes to include new paths for `check_editable` and `update_field` actions. - Enhanced `_table.html.erb` to integrate the new editable functionality, improving user experience with Turbo Streams. * fix: Update sample field test to assert correct button interaction and field visibility - Modified the test in `samples_test.rb` to assert the presence of the sample's metadata value directly. - Changed the interaction from clicking an edit field button to clicking a button that directly represents the sample's value, enhancing the test's accuracy and clarity. - Added an assertion to verify that the field is correctly displayed after the interaction, ensuring the test covers the expected behavior of the inline editing feature. * feat: Enhance inline editing functionality with cancel support and original value handling - Added `original` value support in `inline_edit_controller.js` to store the initial input value. - Implemented `cancel` method to revert changes on Escape key press, improving user experience. - Updated `_edit_field_form.html.erb` and `_edit_field_form.html.erb` to pass original value to the inline edit controller. - Modified input field actions to include cancel functionality, allowing users to easily discard edits. * feat: Add field_editable? method to Sample model for user metadata validation - Introduced `field_editable?` method to determine if a field is editable based on its provenance. - Enhanced the model's capability to manage user-specific metadata, improving the inline editing functionality. * refactor: Update sample field test for inline editing functionality - Renamed test to clarify it checks inline editing of a sample metadata field. - Added assertions to verify the presence of metadata toggle label and correct sample values in the table. - Enhanced test coverage for inline editing interactions, ensuring accurate representation of sample data. * refactor: Simplify editable cell functionality and remove unused actions - Updated `EditableCell` component to remove the `check_editable_url` parameter, streamlining the initialization process. - Refactored `SamplesController` to eliminate `check_editable` and `update_field` actions, consolidating field update logic into the `metadata/fields_controller`. - Introduced new `editable` and `update_value` actions in `fields_controller` to handle inline editing more effectively. - Removed obsolete partials related to inline editing and updated views to reflect the new structure. - Enhanced Turbo Stream responses for editable fields, improving user experience during inline edits. * fix: Update sample field test to assert button presence for inline editing - Modified assertions in `samples_test.rb` to check for button elements instead of table cell text for sample metadata values. - Ensured the test accurately reflects the current inline editing functionality by verifying the presence of buttons for sample values. * refactor: Streamline field update logic and improve rendering methods * refactor: Remove unused hidden field for sample ID in editing field cell * test: Add tests for unchanged field rendering and sample metadata updates * test: Add test for editing a metadata field and update unchanged field response * fix: Update response status for editable field checks and add test for analysis field restriction * test: Add test for building update parameters in FieldsController * test: Update sample table assertions to check input values instead of text * test: Add test for updating metadata value not from an analysis * feat: Enhance metadata field handling and submission logic * test: Refactor sample table interaction and update value submission logic * test: Add check to prevent updating metadata value from an analysis * test: Update metadata value handling in sample tests * test: Update table cell index in sample tests for accurate element selection * feat: Add success flash message upon successful field update in metadata * feat: Add autofocus option to editable cell for improved user experience * feat: Refactor editable cell to use button for submission and improve accessibility * feat: Improve button accessibility by updating aria-label and maintaining autofocus option * refactor: Simplify field rendering logic and improve error handling in fields controller * fix: Update error message to display specific validation error for non-editable fields * feat: Enhance editable field handling by adding non-editable field error message and create metadata field functionality * feat: Add success message for metadata updates and refactor button interactions in sample fields * feat: Implement editable cell component with button interactions and update tests for button selectors * fix: Remove unnecessary class from editable cell and adjust z-index for sticky table headers * test: Refactor sample tests to include setup, actions, and verification sections for clarity * test: Refactor sample tests to include setup, actions, and verification sections for better clarity * test: Add new test to ensure project analysts cannot edit samples, enhancing access control verification * feat: Enhance sample table rendering by conditionally displaying editable cells based on user permissions, improving user experience and access control * refactor: Simplify editable cell initialization and update table rendering logic to enhance user experience by conditionally rendering editable cells based on row actions * test: Test to ensure need permissions to edit metadata * test: Analysts should not be able to edit metadata * test: Remove redundant label click assertion in sample metadata tests to streamline test flow * refactor: Clean up HTML class attributes in table component for improved readability * test: Remove outdated test for metadata update restriction to streamline test suite * fix: Update metadata access methods to use field? for consistency * test: Remove unnecessary assertions in sample metadata tests to streamline test flow * fix: Update sample since the other one went away :( * test: Simplify sample metadata toggle interaction in system tests * test: Add assertion for the number of table headers in sample metadata toggle * refactor: Disable RuboCop class length metric for FieldsController * test: Add assertion for updated table header count in sample metadata toggle * test: Update sample metadata toggle test to use specific project and subgroup * test: Add assertion for the presence of table headers in sample metadata toggle * fix: Use fetch method for safer metadata access in metadata_value * fix: Use fetch method for safer access to sample metadata in editable_cell * fix: Improve updatable_field? method to handle missing metadata provenance * fix: Simplify condition for rendering editable fields in fields_controller * test: Add unit tests for field? and updatable_field? methods in Sample model * test: Update sample tests to assert table header count after metadata toggle * feat: Refactor timestamp handling in sample forms to use a shared partial * fix: Update timestamp handling in fields_controller and timestamp_input partial * fix: Adjust timestamp handling in fields_controller to prevent timing issues * fix: Update timestamp assignment in fields_controller to use sample's updated_at
- Loading branch information