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

Datatable Enhancements #197

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

Conversation

mtwente
Copy link
Member

@mtwente mtwente commented Dec 17, 2024

Pull request

Proposed changes

Resolves #183 with a separate table-view for the browse page.

  • update DataTables to to v2.1.8, including a few plugins:
    • Buttons 3.2.0, Column visibility 3.2.0, HTML5 export 3.2.0, FixedHeader 4.0.1, SearchBuilder 1.8.1
  • add SearchBuilder for advanced queries
  • add all metadata fields to the data table
    • by default, only a few are displayed for better appearance. Column visibility can be toggled using the corresponding button.
  • turn hyperlinks into clickable links
    • keep original markdown formatting for xslx/csv exports
  • separate multiple (longer) entries with horizontal line, e.g. sources or other references
    • subject column: tags are separated by comma and lead to the browse page
Bildschirmfoto 2024-12-17 um 11 16 02

Types of changes

  • New feature (non-breaking change which adds functionality).
  • Enhancement (non-breaking change which enhances functionality)
  • Bug Fix (non-breaking change which fixes an issue).
  • Breaking change (fix or feature that would cause existing functionality to change).

Checklist

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced multilingual support with new translations for search functionalities and table views.
    • Added buttons for switching to table view across various layouts.
    • Introduced a new markdown page for table display.
  • Bug Fixes

    • Corrected HTML syntax for GitHub link in data download modal.
  • Style

    • Updated styles for improved layout and visibility of data tables and search functionalities.
    • Enhanced responsiveness and visual consistency across themes.
  • Chores

    • Updated DataTables CSS to the latest version for improved styling and layout.

Copy link

changeset-bot bot commented Dec 17, 2024

⚠️ No Changeset found

Latest commit: f879c52

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

coderabbitai bot commented Dec 17, 2024

Walkthrough

The pull request introduces significant enhancements to the project's multilingual support and data presentation capabilities through the integration of a DataTables.js view. Key updates include the addition of translation keys for search functionalities, layout modifications for navigation to a new table view, and styling improvements for better user interaction. A new /table.html page has been created to facilitate the display of collections in a structured table format, complete with advanced search, export options, and responsive design.

Changes

File Change Summary
_data/translations.yml Added translations for quick_search, advanced_search, table, and view-table in multiple languages; updated source-code-description for HTML syntax correction.
_includes/js/table-js.html Configured DataTables with search, export options, and visibility management for columns; added layout properties for buttons.
_layouts/browse.html, _layouts/cloud.html, _layouts/data.html, _layouts/list.html, _layouts/timeline_edtf.html Added navigation buttons for table view with translations and accessibility features.
_sass/_custom.scss Introduced new styles for DataTables elements and enhanced existing styles for better layout and visibility.
assets/lib/datatables/datatables.min.css Updated to the latest version of DataTables and modified CSS rules for improved styling and responsiveness.
pages/table.md Created new page for table view with metadata, titled "Tabelle".

Assessment against linked issues

Objective Addressed Explanation
Integrate DataTables.js
Column sorting
Searchable fields
Pagination
Export options Supports CSV and Excel
Responsive design Includes mobile-friendly styles

Poem

🐰 Hop, hop, data's on the move,
Tables dancing with a groove!
Filters, searches, exports galore,
DataTables opened a brand new door!
Research made simple, oh what a view! 🔍


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (2)
_includes/js/table-js.html (1)

122-139: Consider refactoring duplicate render functions

The render functions for handling keywords and markdown links have similar logic in lines 122-139 and 143-161. Refactoring the common functionality into a helper function could reduce code duplication and improve maintainability.

Also applies to: 143-161

assets/lib/datatables/datatables.min.css (1)

13-26: Consider adding non-minified CSS files for easier maintenance

Including minified CSS directly in the repository makes it difficult to review and maintain the styles. Consider adding the non-minified versions of these CSS files to the repository and using a build process to minify them as part of your deployment pipeline.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 82de2aa and 47110e7.

⛔ Files ignored due to path filters (7)
  • _data/config-table.csv is excluded by !**/*.csv
  • assets/lib/datatables/DataTables-1.13.5/images/sort_asc.png is excluded by !**/*.png
  • assets/lib/datatables/DataTables-1.13.5/images/sort_asc_disabled.png is excluded by !**/*.png
  • assets/lib/datatables/DataTables-1.13.5/images/sort_both.png is excluded by !**/*.png
  • assets/lib/datatables/DataTables-1.13.5/images/sort_desc.png is excluded by !**/*.png
  • assets/lib/datatables/DataTables-1.13.5/images/sort_desc_disabled.png is excluded by !**/*.png
  • assets/lib/datatables/datatables.min.js is excluded by !**/*.min.js
📒 Files selected for processing (10)
  • _data/translations.yml (3 hunks)
  • _includes/js/table-js.html (3 hunks)
  • _layouts/browse.html (1 hunks)
  • _layouts/cloud.html (1 hunks)
  • _layouts/data.html (1 hunks)
  • _layouts/list.html (1 hunks)
  • _layouts/timeline_edtf.html (1 hunks)
  • _sass/_custom.scss (6 hunks)
  • assets/lib/datatables/datatables.min.css (1 hunks)
  • pages/table.md (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • pages/table.md
🔇 Additional comments (10)
_includes/js/table-js.html (1)

3-8: Variables for translations are correctly assigned

The assignment of translation variables with default values ensures multilingual support and fallback options.

_layouts/data.html (1)

10-68: Navigation buttons are implemented correctly

The addition of the button group enhances user navigation between different views. The use of Bootstrap classes ensures a responsive design, and the inclusion of translation keys maintains multilingual support.

_layouts/cloud.html (1)

47-53: Consistent addition of the "Table" view button

The new "Table" button is consistently added to the view switcher, matching the style and structure of existing buttons. Accessibility considerations, such as aria-label, are appropriately handled.

_layouts/browse.html (1)

46-52: LGTM! The table view button implementation is consistent and accessible.

The new button follows the established patterns for navigation, properly implements accessibility attributes, and maintains consistent styling with other buttons in the group.

_layouts/list.html (1)

65-71: LGTM! Consistent implementation across layouts.

The table view button implementation maintains consistency with the browse layout, following the same patterns for accessibility, translations, and styling.

_sass/_custom.scss (3)

112-121: LGTM! Consistent styling for the search input.

The search input styling maintains consistency with the application's design system, including proper focus states and border colors.


194-196: LGTM! Well-structured table and SearchBuilder styling.

The table header and SearchBuilder component styling improves the visual hierarchy and maintains consistency with the application's design patterns.

Also applies to: 209-226


391-399: LGTM! Responsive layout adjustments.

The media queries appropriately handle layout adjustments for smaller screens, ensuring proper spacing and flexible growth.

_layouts/timeline_edtf.html (1)

68-74: LGTM! Well-implemented table view button.

The implementation follows best practices:

  • Consistent with existing button styling
  • Proper accessibility attributes
  • Leverages translation system
_data/translations.yml (1)

647-650: LGTM! Complete table translations.

The translations for the table label are properly implemented in all supported languages (English, Spanish, and German).

_includes/js/table-js.html Outdated Show resolved Hide resolved
_sass/_custom.scss Show resolved Hide resolved
_data/translations.yml Outdated Show resolved Hide resolved
_data/translations.yml Outdated Show resolved Hide resolved
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
_data/translations.yml (1)

Line range hint 649-668: Add missing Spanish translations for view options

Some view options are missing Spanish translations while having English and German versions.

Add the missing Spanish translations:

 view-objects:
   en: "Show object view"
+  es: "Mostrar vista de objetos"
   de: "Zeige Objektansicht"
 view-timeline:
   en: "Show objects on timeline"
+  es: "Mostrar objetos en línea de tiempo"
   de: "Zeige Objekte auf einer Zeitachse"
 view-subjects:
   en: "Show list of subjects"
+  es: "Mostrar lista de temas"
   de: "Zeige Liste mit Schlagwörtern"
 view-eras:
   en: "Show list of eras"
+  es: "Mostrar lista de épocas"
   de: "Zeige Liste der Epochen"
🧹 Nitpick comments (1)
_includes/js/table-js.html (1)

49-107: Consider adding error handling for export actions

The layout configuration is well-structured, but consider adding error handling for export operations.

Add try-catch blocks around export operations:

 action: function ( e, dt, node, config ) {
+    try {
         $('#dataModal').modal('show');
+    } catch (error) {
+        console.error('Failed to show export modal:', error);
+        // Fallback action or user notification
+    }
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 47110e7 and 785bbc5.

📒 Files selected for processing (2)
  • _data/translations.yml (3 hunks)
  • _includes/js/table-js.html (3 hunks)
🔇 Additional comments (4)
_includes/js/table-js.html (3)

3-8: LGTM: Translation variables properly initialized

The translation variables are correctly initialized with appropriate fallbacks, following i18n best practices.


35-38: LGTM: DataTable configuration is well structured

The DataTable initialization includes proper language handling and essential features like fixed headers and automatic width adjustment.

Also applies to: 45-48


166-171: LGTM: Initialization completion handler is well implemented

The initComplete function properly handles the SearchBuilder container visibility and search bar styling.

_data/translations.yml (1)

445-452: LGTM: Search translations are complete and consistent

The translations for quick and advanced search are properly implemented across all supported languages.

_includes/js/table-js.html Show resolved Hide resolved
@mtwente
Copy link
Member Author

mtwente commented Dec 17, 2024

@maehr @koilebeit Do you have an opinion on which columns to display initially? At the moment, I have set title, date, description, subject, era, source, and rights to be visible initially. However, the description takes up a lot of space and other columns might be more useful.

@mtwente mtwente requested review from maehr and koilebeit December 17, 2024 10:47
Copy link

@koilebeit koilebeit left a comment

Choose a reason for hiding this comment

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

Many thanks for the PR.
I have noticed two small things that I do not yet find optimal:

  1. the filter slot on the object page is now very small. Too small?
  2. If you activate too many columns, the table extends beyond the layout. could we solve this with a horizontal scrollbar like on the item page for a csv?

Copy link

@koilebeit koilebeit left a comment

Choose a reason for hiding this comment

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

Many thanks for the PR.
I have noticed two small things that I do not yet find optimal:

  1. the filter slot on the object page is now very small. Too small?
  2. If you activate too many columns, the table extends beyond the layout. could we solve this with a horizontal scrollbar like on the item page for a csv?

@maehr
Copy link
Member

maehr commented Dec 17, 2024

Not really related but also not nice: The LINK is messed up ;)
Screenshot 2024-12-17 at 16 22 30

Copy link
Member

@maehr maehr left a comment

Choose a reason for hiding this comment

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

Thanks a lot for the PR. It already looks nice, but I could not dive into all features. @koilebeit do you have time to deep dive?

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
_sass/_custom.scss (1)

194-196: Consider scoping the table header styles

While the vertical alignment is correct, consider scoping this style to the specific DataTable class to avoid affecting other tables in the application.

-.table>thead {
+.collection-table>thead {
    vertical-align: middle;
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 785bbc5 and f879c52.

📒 Files selected for processing (3)
  • _includes/js/table-js.html (3 hunks)
  • _layouts/data.html (1 hunks)
  • _sass/_custom.scss (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • _layouts/data.html
  • _includes/js/table-js.html
🔇 Additional comments (4)
_sass/_custom.scss (4)

112-121: LGTM! Search input styling maintains consistency

The styling for #dt-search-0 follows the established pattern for form controls and maintains the project's color scheme.


228-230: Consider accessibility implications of hiding the close button

Hiding the .dtb-popover-close button might affect keyboard accessibility. Consider making it visually hidden but still accessible to screen readers.


209-211: 🛠️ Refactor suggestion

Reconsider hiding the SearchBuilder title

Hiding the title row completely might affect accessibility. Consider making it visually hidden but still accessible to screen readers.

.dtsb-titleRow {
-    display: none;
+    @extend .visually-hidden;
}

Likely invalid or redundant comment.


217-219: Review flex-wrap behavior for small screens

Preventing flex-wrap with !important might cause layout issues on small screens where space is limited.

✅ Verification successful

Overriding flex-wrap is safe in this context

The !important override for flex-wrap: nowrap on .dtsb-logicContainer is actually appropriate here. The DataTables SearchBuilder library already handles responsive behavior appropriately:

  • For small screens (max-width: 550px), the parent criteria container switches to a column layout with flex-direction: column
  • The logic container itself is positioned absolutely and transformed, making the nowrap behavior necessary for the logic buttons
  • The library's CSS ensures proper stacking and spacing of elements on mobile devices
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existing responsive handling of SearchBuilder
rg -l "dtsb-logicContainer.*@media" --type css

Length of output: 89


Script:

#!/bin/bash
# Check the content of the file to understand the responsive behavior
rg "dtsb-logicContainer.*@media" -A 5 -B 5 --type css

Length of output: 7064

Comment on lines +336 to +359
.collection-table {
border: hidden;
}

table.dataTable.fixedHeader-floating,table.dataTable.fixedHeader-locked {
background-color: #ffe880;
}

.dt-scroll {
border: 6.5px solid #ffe880;
border-radius: .25rem;
}

.dt-scroll-head {
background-color: #ffe880;
}

.dt-scroll-body {
border: none !important;
}

thead, tbody, th, td {
border: none !important;
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consolidate table border styles

There are multiple overlapping border-related rules with !important flags. Consider consolidating these styles to reduce specificity conflicts and improve maintainability.

.collection-table {
-    border: hidden;
+    border: none;
+    
+    .dt-scroll {
+        border: 6.5px solid #ffe880;
+        border-radius: .25rem;
+        
+        thead, tbody, th, td {
+            border: none;
+        }
+    }
}

-table.dataTable.fixedHeader-floating,
-table.dataTable.fixedHeader-locked {
+.collection-table.fixedHeader-floating,
+.collection-table.fixedHeader-locked {
    background-color: #ffe880;
}

-.dt-scroll {
-    border: 6.5px solid #ffe880;
-    border-radius: .25rem;
-}

-.dt-scroll-body {
-    border: none !important;
-}

-thead, tbody, th, td {
-    border: none !important;
-}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.collection-table {
border: hidden;
}
table.dataTable.fixedHeader-floating,table.dataTable.fixedHeader-locked {
background-color: #ffe880;
}
.dt-scroll {
border: 6.5px solid #ffe880;
border-radius: .25rem;
}
.dt-scroll-head {
background-color: #ffe880;
}
.dt-scroll-body {
border: none !important;
}
thead, tbody, th, td {
border: none !important;
}
.collection-table {
border: none;
.dt-scroll {
border: 6.5px solid #ffe880;
border-radius: .25rem;
thead, tbody, th, td {
border: none;
}
}
}
.collection-table.fixedHeader-floating,
.collection-table.fixedHeader-locked {
background-color: #ffe880;
}
.dt-scroll-head {
background-color: #ffe880;
}

Comment on lines +418 to +420
.row > :not(:has(.pagination)) {
flex-grow: 1;
}
Copy link

Choose a reason for hiding this comment

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

💡 Codebase verification

Browser compatibility concern confirmed for :has() selector

The :has() selector is only supported in modern browsers since late 2022. Since there are no existing fallback patterns or @supports checks in the codebase, you should:

  • Add a fallback style for browsers that don't support :has():
    /* Fallback for browsers without :has support */
    .row > * {
      flex-grow: 1;
    }
    /* Modern browsers */
    .row > :not(:has(.pagination)) {
      flex-grow: 1;
    }
  • Or use @supports for progressive enhancement:
    /* Base styles */
    .row > * {
      flex-grow: 1;
    }
    /* Enhanced styles for modern browsers */
    @supports selector(:has(*)) {
      .row > :not(:has(.pagination)) {
        flex-grow: 1;
      }
    }
🔗 Analysis chain

Check browser compatibility for :has selector

The :has() selector is relatively new and might not be supported in all browsers. Consider adding a fallback.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for any existing fallback patterns in the codebase
rg ":has\(" --type css

Length of output: 80


Script:

#!/bin/bash
# Check for any @supports usage in CSS files that might indicate existing patterns for progressive enhancement
rg "@supports" --type css -A 2

Length of output: 30

Copy link
Member

@maehr maehr left a comment

Choose a reason for hiding this comment

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

We will be able to review the PR in greater detail after the holidays. I'll give you a carde blanche 🙈😇

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.

Replace Advanced Filtering with DataTables.js View
3 participants