Skip to content

Conversation

yaxit24
Copy link
Contributor

@yaxit24 yaxit24 commented Jun 30, 2025

Fixes: #769

Screen.Recording.2025-06-30.at.12.32.31.PM.mov

Summary by Sourcery

Implement separate Event Info and User Info placeholder dropdowns and adjust editor logic to handle dual dropdowns with "Other" inputs, restricting default placeholders to configured fields.

New Features:

  • Introduce dual dropdown UI for selecting Event Info and User Info placeholders with an "Other" option.
  • Add test_dual_dropdown.html page to demonstrate and verify the dual dropdown functionality.

Bug Fixes:

Enhancements:

  • Refactor editor.js to support separate event and user info sample retrieval, selection, and text updates.
  • Change default placeholder content from 'item' to 'event_name'

Tests:

  • Include test dual dropdown page to manually test placeholder selection logic

Copy link
Contributor

sourcery-ai bot commented Jun 30, 2025

Reviewer's Guide

This PR refactors the PDF ticket editor to replace the single content placeholder with two dedicated dropdowns (event info and user info) featuring optional “other” fields, updates the editor.js methods to sample, load, and apply selections correctly (including a new default of “event_name”), adjusts the template to render and filter the dual dropdowns, and adds a standalone HTML test page for the new interaction.

Sequence diagram for updating text area with dual dropdowns

sequenceDiagram
    actor User
    participant EventInfoDropdown as Event Info Dropdown
    participant UserInfoDropdown as User Info Dropdown
    participant EditorJS as editor.js
    participant Canvas as PDF Canvas
    User->>EventInfoDropdown: Selects an option
    EventInfoDropdown->>EditorJS: Triggers change event
    EditorJS->>UserInfoDropdown: Clears selection
    EditorJS->>Canvas: Updates text area with selected event info
    User->>UserInfoDropdown: Selects an option
    UserInfoDropdown->>EditorJS: Triggers change event
    EditorJS->>EventInfoDropdown: Clears selection
    EditorJS->>Canvas: Updates text area with selected user info
    User->>EventInfoDropdown: Selects 'Other'
    EventInfoDropdown->>EditorJS: Triggers change event
    EditorJS->>Canvas: Shows 'Other' textarea
    User->>Canvas: Enters custom text
    Canvas->>EditorJS: Triggers input event
    EditorJS->>Canvas: Updates text area with custom text
Loading

Class diagram for updated editor.js text area handling

classDiagram
    class Editor {
        +_get_text_sample(key)
        +_load_pdf(dump)
        +_update_toolbox_values()
        +_update_values_from_toolbox()
        +init()
    }
    Editor o-- EventInfoDropdown : uses
    Editor o-- UserInfoDropdown : uses
    class EventInfoDropdown {
        +change()
        +val()
    }
    class UserInfoDropdown {
        +change()
        +val()
    }
    Editor o-- TextAreaOther : manages
    class TextAreaOther {
        +show()
        +hide()
        +val()
    }
Loading

File-Level Changes

Change Details Files
Refactor editor.js to support dual dropdown system
  • Extend _get_text_sample to check #toolbox-event-info and #toolbox-user-info before falling back
  • Hide and toggle #toolbox-event-info-other and #toolbox-user-info-other in load/update routines
  • Replace single-content logic in object modification and save blocks with event/user selection, handling “other” cases and updating o.content/o.text
  • Change default content from 'item' to 'event_name'
  • Register event and input handlers in init() for the two dropdowns and their “other” fields
src/pretix/static/pretixcontrol/js/ui/editor.js
Update PDF editor template to render two categorized placeholder selects
  • Replace #toolbox-content select with #toolbox-event-info and #toolbox-user-info selects and corresponding hidden textareas
  • Filter and group variables into event-related or user-related options
  • Add “other” option and textarea for each dropdown
src/pretix/control/templates/pretixcontrol/pdf/index.html
Add standalone test page for dual dropdown functionality
  • Create test_dual_dropdown.html with dummy event/user selects, ‘other’ textareas, preview section, and JS to simulate and display selection logic
test_dual_dropdown.html

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @yaxit24 - I've reviewed your changes - here's some feedback:

  • There's a lot of duplicated logic around toggling and clearing the two dropdowns; consider extracting that into reusable helper functions to reduce repetition and improve maintainability.
  • The manual test_dual_dropdown.html file lives at the project root but isn't part of the automated suite; consider moving it into a dedicated test directory or converting it into an automated JS test.
  • The init method now contains many event handler attachments; you might want to group those into a separate private method (e.g. _bindDualDropdownEvents) to keep init concise.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- There's a lot of duplicated logic around toggling and clearing the two dropdowns; consider extracting that into reusable helper functions to reduce repetition and improve maintainability.
- The manual `test_dual_dropdown.html` file lives at the project root but isn't part of the automated suite; consider moving it into a dedicated test directory or converting it into an automated JS test.
- The `init` method now contains many event handler attachments; you might want to group those into a separate private method (e.g. `_bindDualDropdownEvents`) to keep `init` concise.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

yaxit24 added 2 commits June 30, 2025 18:35
I have Reduced Duplicated Logic, Organized Event Handler Attachments
@yaxit24
Copy link
Contributor Author

yaxit24 commented Jun 30, 2025

All the changes are made as sugegsted by the Sourcery-ai.

@yaxit24 yaxit24 changed the title Fix: Limit Default Text Placeholders to Organizer-Selected Fields (#769) Fix: Limit Default Text Placeholders to Organizer-Selected Fields Jul 1, 2025
Copy link
Member

@Sak1012 Sak1012 left a comment

Choose a reason for hiding this comment

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

This resolves the issue #769 by categorizing the placeholders into two distinct categories. However, it does not actually limit the placeholders. The original issue #192 aimed to achieve the functionality from eventyay.com, where the placeholders for the badge were determined by the fields selected for the Attendee Form. This ensured that the fields in the badge would always be available and would not end up being empty.

Choosing Attendee Form fields from eventyay.com:
image

Choosing Fields for Badges in eventyay.com:
image

@yaxit24
Copy link
Contributor Author

yaxit24 commented Jul 4, 2025

what i think the issue of the limiting the placeholders can be solved here by simply limiting them here, keeping only those placeholders which are utilised most, or removing those which are irrelevant for badges in events.

@yaxit24 yaxit24 requested a review from Sak1012 July 7, 2025 11:19
@Sak1012
Copy link
Member

Sak1012 commented Jul 7, 2025

No, that may not be the correct approach. Some events may require specific fields, while others may not. It is not advisable to base the editor on the most utilized field, but rather on the information available for the event. For instance, if an event does not have a “Seat Number” field, it is not necessary to include it in the editor. Instead, the editor should be dynamic and display the fields of data available for the event.

@yaxit24
Copy link
Contributor Author

yaxit24 commented Jul 7, 2025

thankyou @Sak1012, @hpdang and @mariobehling what are reviews ?

@mariobehling
Copy link
Member

Please follow the suggestions of Srivatsav. There is no reason to artificially limit the fields. There are many use cases where we need fields that have been filled in. Thanks

@mariobehling mariobehling self-requested a review July 10, 2025 07:41
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.

Limit Default Text Placeholders to Organizer-Selected Fields
5 participants