Add UI test page and enhance styles for responsiveness and usability#16
Add UI test page and enhance styles for responsiveness and usability#16
Conversation
…s in exchange, split, and transaction forms; update templates to toggle custom currency fields based on selection.
- Added ValidationError import from wtforms
- Created a custom validate() method in CurrencyExchangeForm that:
- Ensures exactly one amount field is filled (not both, not neither)
- Provides clear error messages when validation fails
2. Frontend UX Improvements (ui/app/templates/exchange/index.jinja2):
- Added JavaScript to automatically disable one amount field when the
other is filled
- When source amount is entered: target amount becomes read-only with gray
background
- When target amount is entered: source amount becomes read-only with gray
background
- Clearing one field re-enables the other
- Visual feedback with placeholder text indicating why the field is
disabled
There was a problem hiding this comment.
Pull Request Overview
This PR adds a comprehensive UI test page and enhances the application's responsive design and usability across multiple components.
- Adds a new standalone UI test page (
test_ui.html) for visual testing of components - Updates currency handling to use dropdown selects with predefined options instead of text fields
- Enhances CSS styles for mobile responsiveness, improved navigation, and better form layouts
Reviewed Changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| ui/app/templates/widgets/pagination.jinja2 | Updates pagination from <p> to <div> with proper styling classes and disabled state handling |
| ui/app/templates/widgets/entity_selector.jinja2 | Restructures entity selector with improved layout and proper labels |
| ui/app/templates/transaction/edit.jinja2 | Adds JavaScript for custom currency field toggle functionality |
| ui/app/templates/transaction/add.jinja2 | Adds JavaScript for custom currency field toggle functionality |
| ui/app/templates/split/edit.jinja2 | Adds JavaScript for custom currency field toggle functionality |
| ui/app/templates/split/add.jinja2 | Adds JavaScript for custom currency field toggle functionality |
| ui/app/templates/exchange/index.jinja2 | Adds complex JavaScript for currency selection and mutual exclusivity of amount fields |
| ui/app/static/style.css | Major CSS overhaul with responsive design, improved typography, and enhanced component styling |
| ui/app/controllers/transaction.py | Updates currency handling from text fields to dropdowns with custom currency support |
| ui/app/controllers/split.py | Updates currency handling from text fields to dropdowns with custom currency support |
| ui/app/controllers/exchange.py | Updates currency handling and adds form validation for mutually exclusive amount fields |
| ui/app/constants.py | New file defining currency constants and configuration |
| test_ui.html | New standalone HTML file for UI component testing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } else { | ||
| customCurrencyRow.style.display = 'none'; | ||
| customCurrencyField.required = false; | ||
| // Don't clear the value on edit page if it's already set |
There was a problem hiding this comment.
This comment indicates missing functionality. The code should handle preserving existing custom currency values when toggling fields on the edit page, but no implementation is present.
| // Don't clear the value on edit page if it's already set | |
| let preservedCustomCurrencyValue = customCurrencyField ? customCurrencyField.value : ''; | |
| function toggleCustomCurrency() { | |
| if (currencySelect && customCurrencyRow) { | |
| if (currencySelect.value === 'other') { | |
| customCurrencyRow.style.display = ''; | |
| customCurrencyField.required = true; | |
| // Restore preserved value if available | |
| if (preservedCustomCurrencyValue !== undefined && preservedCustomCurrencyValue !== null) { | |
| customCurrencyField.value = preservedCustomCurrencyValue; | |
| } | |
| } else { | |
| customCurrencyRow.style.display = 'none'; | |
| customCurrencyField.required = false; | |
| // Preserve the value when hiding | |
| preservedCustomCurrencyValue = customCurrencyField.value; |
| toggleCustomCurrency(); // Initial state | ||
| } | ||
| }); | ||
| </script> |
There was a problem hiding this comment.
The same JavaScript code for currency field toggling is duplicated across multiple template files (transaction/add.jinja2, transaction/edit.jinja2, split/add.jinja2, split/edit.jinja2). This should be extracted to a shared JavaScript file to reduce duplication.
| </script> | |
| <script src="/static/js/currencyToggle.js"></script> |
| </form> | ||
|
|
||
| <script src="/static/js/entitySelector.js"></script> | ||
| <script> |
There was a problem hiding this comment.
The JavaScript code in this template is significantly more complex than the currency toggle scripts in other templates. Consider extracting this to a separate JavaScript file for better maintainability and potential reuse.
| } | ||
|
|
||
| /* Additional mobile improvements */ | ||
| @media (max-width: 768px) { |
There was a problem hiding this comment.
The mobile breakpoint value '768px' is duplicated multiple times throughout the CSS file. Consider defining this as a CSS custom property at the root level to ensure consistency and easier maintenance.
| @media (max-width: 768px) { | |
| @media (max-width: var(--mobile-breakpoint)) { |
| return False | ||
|
|
||
| # Check if both amount fields are filled | ||
| if self.source_amount.data and self.target_amount.data: |
There was a problem hiding this comment.
The validation logic checks for both amount fields being filled, but it should also handle the case where both fields have a value of 0, as 0 is falsy in Python but might be a valid input that should trigger the validation error.
| if self.source_amount.data and self.target_amount.data: | |
| if self.source_amount.data is not None and self.target_amount.data is not None: |
…essary display:none style for better visibility; updated JavaScript to ensure proper toggling of custom currency fields based on selection.
…when search input is empty, implement keyboard navigation for dropdown results, and improve UI to display entity IDs alongside names. Additionally, close dropdowns on outside clicks and escape key press.
|
✨ i've merged:
however, changes are required to merge:
|



BEFOREL
AFTER