Skip to content

Create a simplified dataset view#2413

Open
luistoptal wants to merge 9 commits into
gigascience:developfrom
luistoptal:new-feature/152-create-a-simplified-dataset-view
Open

Create a simplified dataset view#2413
luistoptal wants to merge 9 commits into
gigascience:developfrom
luistoptal:new-feature/152-create-a-simplified-dataset-view

Conversation

@luistoptal

@luistoptal luistoptal commented Jul 18, 2025

Copy link
Copy Markdown
Collaborator

Pull request for issue: #152

Next actionable: deploy this feature to a preview branch and share it with management for feedback on the appearance before reviewing and merging, as management might want to propose changes to the UI of the for print view, e.g. more compact content, more presence of gigadb brand, etc

Description

This pull request introduces a printer-friendly version of the dataset view page. The goal is to provide a clean, simplified layout optimized for printing by removing unnecessary UI elements like the header, footer, navigation, and other interactive components.

A "Print view" toggle button has been added to allow users to switch between the standard and print-optimized modes without a page reload. This improves usability and ensures the printed output is clean, readable, and focused on the essential dataset information.

the following screenshots summarize how this feature works from a user perspective

Normal view showing the location of the toggle view button:
Screenshot from 2025-07-18 10-56-24

Print view, showing a print=true url query param and a simplified print ready view
Screenshot from 2025-07-18 10-57-55

Button (link) to toggle the full list of results. It is displayed on the condition: $totalNbFiles > 100 || $totalNbSamples > 100
Screenshot from 2025-07-18 11-04-11

after the full list of results is on display. Controlled by URL query param full=true
Screenshot from 2025-07-18 11-05-02

Changes Made

Backend

  • URLsService.php: Added a editUrlQueryParams() method to dynamically manage URL query parameters, used for toggling the complete file/sample list in print view.
  • DatasetPageAssembly.php: Updated to detect the print view via URL parameters and adjust pagination accordingly. It now displays up to 100 items by default in print view, with an option to show all results for larger datasets.
  • dataset/view.php: Modified to include a print view toggle, add data-header attributes for improved table layouts in print, and conditionally render elements specific to the print view.
  • layouts/main.php: Adjusted to add a print class to the <body> tag when the print view is active.

Frontend

  • _printToggle.php: Created a new shared partial that provides the "Print view" / "Web view" toggle button and the associated JavaScript to update the UI and URL.
  • less/:
    • Added layout/print.less and pages/dataset-print.less to define the styles for the printer-friendly layout.
    • Updated index.less to import the new print styles.
    • Scoped existing styles in pages/dataset.less to body:not(.print) to prevent conflicts with the print view.

How to Test

  1. Navigate to any dataset page, e.g. http://gigadb.gigasciencejournal.com/dataset/100035
  2. Click the "Print view" button located at the top right of the main content area.
  3. Verify: The URL should update to include ?print=true. The page layout should change to a simplified format, with the header, footer, and side navigation hidden.
  4. Verify: The content, including metadata, files, and samples, should be restyled for clarity and readability.
  5. Open the browser's print preview (Ctrl+P / Cmd+P).
  6. Verify: The preview should display a clean, well-formatted document. The files and samples tables should be stacked vertically for better print output.
  7. For datasets with more than 100 files or samples, confirm that a "Show all X results" link appears in print view. Clicking it should append &full=true to the URL and display all items.
  8. Click the "Web view" button.
  9. Verify: The page should revert to the standard interactive layout, and the ?print=true parameter should be removed from the URL.
  10. tests should pass: docker-compose run --rm codecept run --no-redirect -g issue-152 acceptance -vv

Changes to tests

Numerous acceptance tests are added that fully cover this feature without being strict about the appearance and layout

docker-compose run --rm codecept run --no-redirect -g issue-152 acceptance -vv

Summary by CodeRabbit

  • New Features

    • Added a print-friendly view for dataset pages, accessible via a toggle button.
    • Users can switch between web and print views without reloading the page.
    • Print view simplifies layout, hides non-essential elements, and restructures tables for improved readability on paper.
    • Option to display all or limited results in print view for large datasets.
  • Style

    • Introduced new stylesheets for print layouts and dataset print views.
    • Updated existing dataset page styles to support print and web view modes.
  • Bug Fixes

    • Improved accessibility and clarity in tables by adding data-header attributes and print-specific labels.

@coderabbitai

coderabbitai Bot commented Jul 18, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

A print-friendly view feature was implemented for dataset pages. This includes new and updated LESS styles for print formatting, logic to adjust pagination for print, a print toggle button with JavaScript, and conditional rendering in views for print mode. Query parameter handling and body class assignment were also introduced to support the print mode.

Changes

File(s) Change Summary
gigadb/app/services/URLsService.php Added editUrlQueryParams static method for manipulating URL query parameters.
less/index.less, less/layout/print.less, less/pages/dataset-print.less Imported new print-specific LESS files and added print-focused styles for layout and dataset pages.
less/pages/dataset.less Scoped existing styles to non-print views; added print button container and responsive adjustments.
protected/components/DatasetPageAssembly.php Adjusted pagination size logic for print mode based on query parameters.
protected/views/dataset/view.php Added print toggle UI, print-specific labels, data-header attributes, and conditional pagination links.
protected/views/layouts/main.php Modified <body> tag to set "print" class based on query parameter.
protected/views/shared/_printToggle.php Introduced a partial for toggling print/web view with a button and JavaScript.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser
    participant View
    participant URLsService
    participant DatasetPageAssembly

    User->>Browser: Clicks Print Toggle Button
    Browser->>View: Toggle print mode (update URL/query param)
    View->>URLsService: editUrlQueryParams(add/remove 'print')
    View->>DatasetPageAssembly: setDatasetFiles/Samples(pageSize, print params)
    DatasetPageAssembly-->>View: Return data with adjusted pageSize
    View->>Browser: Render print-friendly layout/styles
Loading

Suggested labels

pr:has-ui


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

@luistoptal

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 18, 2025

Copy link
Copy Markdown
✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
protected/components/DatasetPageAssembly.php (1)

379-386: Apply the same refactoring here as in setDatasetFiles.

This method contains the same duplicated logic. Use the helper method suggested above.

🧹 Nitpick comments (4)
protected/views/shared/_printToggle.php (3)

20-22: Improve button accessibility and semantic structure.

The button could benefit from better accessibility attributes and semantic structure for screen readers.

-<button class="btn btn-link print-view-link" aria-label="Switch to print view">
+<button class="btn btn-link print-view-link" 
+        aria-label="Switch to print view" 
+        aria-pressed="false"
+        role="switch">
     <span class="label-text">Print view</span>
+    <span class="sr-only" aria-live="polite"></span>
 </button>

29-32: Add aria-pressed state management for accessibility.

The toggle button should update its aria-pressed state to properly communicate its current state to screen readers.

const update = (toPrint) => {
    $('body').toggleClass('print', toPrint);
    $label.text(toPrint ? 'Web view' : 'Print view');
+   $btn.attr('aria-pressed', toPrint.toString());
+   $btn.find('.sr-only').text(toPrint ? 'Currently in print view' : 'Currently in web view');
};

37-46: Add error handling for URL manipulation.

The URL manipulation could fail in some edge cases. Consider adding error handling to prevent JavaScript errors.

$btn.on('click', () => {
+   try {
        isPrint = !isPrint;
        if (isPrint) {
            url.searchParams.set('print', 'true');
        } else {
            url.searchParams.delete('print');
        }
        history.replaceState(null, '', url);
        update(isPrint);
+   } catch (error) {
+       console.error('Error updating print view state:', error);
+       // Fallback: just toggle the class without URL update
+       isPrint = !isPrint;
+       update(isPrint);
+   }
});
less/layout/print.less (1)

4-4: Excessive use of !important declarations

Multiple !important declarations throughout the file suggest potential specificity conflicts. Consider restructuring selectors to achieve proper cascade without forcing importance.

Also applies to: 11-11, 15-15, 35-35

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 39ed976 and eddb32c.

📒 Files selected for processing (9)
  • gigadb/app/services/URLsService.php (1 hunks)
  • less/index.less (1 hunks)
  • less/layout/print.less (1 hunks)
  • less/pages/dataset-print.less (1 hunks)
  • less/pages/dataset.less (1 hunks)
  • protected/components/DatasetPageAssembly.php (2 hunks)
  • protected/views/dataset/view.php (12 hunks)
  • protected/views/layouts/main.php (1 hunks)
  • protected/views/shared/_printToggle.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

**/*.php

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

**/*.less

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🔇 Additional comments (12)
protected/views/layouts/main.php (1)

41-41: LGTM - Clean conditional class implementation.

The conditional class assignment correctly implements the print view toggle functionality. The string comparison with 'true' is safe and appropriate for this use case.

less/index.less (1)

78-79: LGTM - Proper import placement for print styles.

The print-specific stylesheets are correctly imported at the end of the file, ensuring they can override other styles as needed. The naming convention follows the established pattern.

less/layout/print.less (1)

34-36: Verify custom element selector in print.less

The hypothesis-sidebar rule in less/layout/print.less hides a custom element that’s injected at runtime by the Hypothes.is embed. Since we don’t see any static <hypothesis-sidebar> in your templates, please:

• Confirm that the Hypothesis embed actually mounts a <hypothesis-sidebar> element in the print DOM (e.g. via browser print preview).
• If the library uses a different wrapper, class or data-attribute, update the selector to target that instead (for example, a .hypothesis-sidebar class or [data-hypothesis-sidebar]).

This will ensure the rule takes effect in all browsers and print contexts.

less/pages/dataset.less (1)

2-192: Well-structured scoping for print vs screen styles

The approach of wrapping existing styles in body:not(.print) effectively separates print and screen styles. The responsive design for the print button container is properly implemented with appropriate breakpoints.

less/pages/dataset-print.less (3)

109-115: Proper handling of numeric ID selectors

The escaped selectors #\33 dmodels and #\33 dsketchfab correctly handle IDs that start with numbers, which is good CSS practice.


24-32: Excellent UX enhancement for print links

The implementation of appending URLs to links in print view while excluding internal anchors and JavaScript links is a thoughtful user experience improvement.


123-195: Comprehensive table restructuring for print

The table transformation from tabular to linear layout using data-header attributes is well-implemented and will provide a much better print experience.

protected/views/dataset/view.php (5)

30-32: Print toggle integration looks good

The print toggle button is properly integrated using a partial view, which maintains good separation of concerns.


332-358: Well-implemented conditional print pagination

The logic for showing/hiding pagination controls in print mode is properly implemented with appropriate URL manipulation and user-friendly messaging.


388-394: Consistent data-header attribute implementation

The systematic addition of data-header attributes to table cells provides proper labeling for the print stylesheet transformation.

Also applies to: 465-479, 536-540, 604-606


467-467: Verify print-hidden class usage

The print-hidden class is applied to a table cell that appears to have performance-related TODO comments. Ensure this is intentional and not masking an underlying issue.


1-3: Please verify URLsService sanitization and error handling
Ensure that any query-parameter edits are properly validated, escaped, and that the service gracefully handles invalid or missing inputs.

• Confirm the implementation of editUrlQueryParams (or equivalent) sanitizes all incoming values.
• Check for appropriate error catching or fallbacks when URL parameters are malformed.
• Add unit tests or input validation logic if missing to prevent XSS or injection risks.

Comment thread gigadb/app/services/URLsService.php
Comment thread protected/components/DatasetPageAssembly.php
@luistoptal
luistoptal marked this pull request as ready for review July 18, 2025 06:02
@rija rija moved this from Draft to Ready For Review in Backlog: Pull Requests Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Ready For Review

Development

Successfully merging this pull request may close these issues.

2 participants