forked from dotCMS/core
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit 2b0a382
authored
Display Bug in Template Dropdown: Missing Templates and Console Error (dotCMS#32241)
- Introduced a configuration object for better management of constants.
- Added utility functions for logging, validation, and DOM manipulation.
- Enhanced pagination handling with loading animations and improved UI
feedback.
- Implemented a template manager for better template selection and image
fetching.
- Updated the TemplateReadStore to improve error handling and response
validation.
- Refactored existing functions for clarity and modularity, ensuring
better separation of concerns.
### Proposed Changes
This pull request introduces significant enhancements and refactoring to
the `TemplateReadStore` class in
`dotCMS/src/main/webapp/html/js/dotcms/dojo/data/TemplateReadStore.js`.
The changes focus on improving code maintainability, adding new utility
methods, handling edge cases, and enhancing error handling and logging.
### New Features and Enhancements:
* Introduced constants (`MAX_ITEMS_SAFETY_LIMIT`, `DEFAULT_PER_PAGE`,
etc.) and utility methods (`_log`, `_error`, `_warn`,
`_validateResponse`, etc.) to improve readability and debugging.
[[1]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22R8-R15)
[[2]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22L16-R207)
* Added pagination handling in the `fetch` method, including server-side
page calculations and query normalization.
* Enhanced `ALL_SITE_TEMPLATE` with additional fields like `hostName`,
`type`, and `modDate` to provide more comprehensive template details.
### Error Handling and Validation:
* Added validation for required parameters in constructors and methods
(`options` in the constructor, `keywordArgs` in `fetch`, etc.).
[[1]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22L16-R207)
[[2]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22R220-R394)
* Improved error handling in API calls and callbacks, including detailed
error logging and fallback mechanisms.
[[1]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22R220-R394)
[[2]](diffhunk://#diff-5453f9a344625845fd35818fe8b7853f0b5ef2428b53b0e775a6f5cd13bf7c22L211-L221)
### Refactoring and Simplification:
* Refactored methods like `getValue`, `getAttributes`, and `isItem` to
improve clarity and handle edge cases (e.g., null or undefined inputs).
* Simplified the `fetchTemplatesCallback` method by introducing
`_processTemplatesArray` for safer and more modular template processing.
### Deprecation and Legacy Support:
* Marked the `fetchCallback` method as deprecated and redirected its
functionality to `fetchTemplatesCallback`.
### Bug Fixes:
* Fixed a typo in a comment ("Behavion" -> "Behavior").
* Resolved potential issues with string concatenation and undefined
properties in methods like `getLabel` and `getIdentity`.
### Checklist
- [ ] Tests
- [ ] Translations
- [ ] Security Implications Contemplated (add notes if applicable)
### Additional Info
** any additional useful context or info **
### Screenshots
https://github.com/user-attachments/assets/d28250a6-d4a2-4898-a666-0ef98a5eaf471 parent 893649b commit 2b0a382Copy full SHA for 2b0a382
File tree
Expand file treeCollapse file tree
2 files changed
+818
-303
lines changedOpen diff view settings
Filter options
- dotCMS/src/main/webapp
- WEB-INF/velocity/static/htmlpage_assets
- html/js/dotcms/dojo/data
Expand file treeCollapse file tree
2 files changed
+818
-303
lines changedOpen diff view settings
0 commit comments