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

Show compound patterns in the dropdown for citation key patterns #12580

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

priyanshu16095
Copy link
Contributor

@priyanshu16095 priyanshu16095 commented Feb 27, 2025

Follow-up for #12516

This PR enhances the citation key dropdown feature by adding a submenu for compound patterns.

Mandatory checks

  • I own the copyright of the code submitted and I licence it under the MIT license
  • Change in CHANGELOG.md described in a way that is understandable for the average user (if change is visible to the user)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked developer's documentation: Is the information available and up to date? If not, I outlined it in this pull request.
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.
Recording.2025-02-28.mp4

}

public List<String> generateCompoundPatterns(String enteredText) {
List<String> patterns = List.of("auth", "edtr", "year", "title", "date");
Copy link
Contributor Author

@priyanshu16095 priyanshu16095 Feb 27, 2025

Choose a reason for hiding this comment

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

@subhramit I used this list as I don’t have much knowledge about the fields and can you explain more about compound patterns?

Copy link
Member

Choose a reason for hiding this comment

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

Please use the constants of org.jabref.model.entry.field.StandardField here.

The fields can be read about at BibLaTeX documentation at https://ctan.org/pkg/biblatex.

Copy link
Member

Choose a reason for hiding this comment

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

I think, the list should be manually crafted instead of just combinding all fields

The description at #12502 (comment) talks about auto completion

That would be nice.

If this is not possible, some pre-selected combinations should be doable.

I think, it needs to be a separate pop up then - even if multiple modals are not a good style ^^

Grammar: [{pattern}](_[{pattern}])*

  1. A user can select a pattern.
  2. Then, the user can select "+"
  3. Then, JabRef adds "_" and offers another dropdown to select (the one selected before is NOT offered)

Reason: A user wants to use AuthEtAl together with year typically.

@priyanshu16095 Think of this as autogenerated (!) human-readable-primary-key in databases. MAybe this helps. -- Another thing: Either data of a BibEntry can be used directly or some processing of JabRef can be used. The former is ensured by CAPITAL LETTERS (first paragraph at https://docs.jabref.org/setup/citationkeypatterns#citation-key-patterns). The latter is described in the other text.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Feb 28, 2025

Recording.2025-02-28.mp4

@koppor Thanks for your insights! I’ve come up with a different solution that addresses the concerns and removes the overhead of an algorithm, maintaining it, and making it more efficient.
Instead, I used a UI-based solution (similar to your modal solution) that provides a much better approach, as the user doesn't have to type different keywords to find a pattern.
The UX is perfect, for a two-click process—it takes only two clicks.

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Feb 28, 2025

Another improvement in the code:
For better UX, the position of the sub-menu items under 'All patterns' and 'Create compound pattern' has been fixed, as it was not fixed before.

Before:

before

After:

after

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output.
You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section Final build system checks in our setup guide.

@priyanshu16095 priyanshu16095 marked this pull request as ready for review March 3, 2025 10:24
@subhramit
Copy link
Member

subhramit commented Mar 3, 2025

Sorry, I am a little low on time to test this - What does the menu "Create compound pattern" do? Why is it needed if we can create compound patterns by taking patterns from the "All patterns" list? As far as I understand, only thing it does is add underscores in between patterns - the choice of that separator can be arbitrary for a user. @koppor do we wish to make underscore a default for this? Or is it a wider convention? This user, for example, was using colons (:) as a separator.

Also:
image

@priyanshu16095 Can you move the black arrows of the first menu (first two items having sublists) to the extreme right of the cell (like in the sublist menu)?

(Updated)

@priyanshu16095
Copy link
Contributor Author

Just like a dropdown that shows generated compound patterns, it allows the user to create any pattern on their own.
Regarding your concern about symbols, it could have a submenu displaying symbols that can be added or, by default - can be used.

@priyanshu16095
Copy link
Contributor Author

Screenshot (188)

The width of the menu cannot be set in JavaFX, as it is managed by the system. However, I can change the width of the labels instead.

@subhramit
Copy link
Member

Sorry, I am a little low on time to test this - What does the menu "Create compound pattern" do? Why is it needed if we can create compound patterns by taking patterns from the "All patterns" list? As far as I understand, only thing it does is add underscores in between patterns - the choice of that separator can be arbitrary for a user. @koppor do we wish to make underscore a default for this? Or is it a wider convention? This user, for example, was using colons (:) as a separator.

@koppor ping

@koppor
Copy link
Member

koppor commented Mar 7, 2025

Just like a dropdown that shows generated compound patterns, it allows the user to create any pattern on their own. Regarding your concern about symbols, it could have a submenu displaying symbols that can be added or, by default - can be used.

Good idea! _ can be the default.

@ryan-carpenter
Copy link

ryan-carpenter commented Mar 13, 2025

Just like a dropdown that shows generated compound patterns, it allows the user to create any pattern on their own. Regarding your concern about symbols, it could have a submenu displaying symbols that can be added or, by default - can be used.

The functionality is unclear because of the wording. The options need to be "parallel", like this:

Example 1

Choose pattern ⏵
Build pattern ⏵

Example 2

Basic pattern ⏵
Advanced pattern ⏵

Example 3

Simple pattern ⏵
Complex pattern ⏵

What about modifiers? These could be available after the first field or field marker has been selected, maybe like this.

Example 4

[title]
Add to pattern ⏵ ...
Add modifier ⏵ :abbr
               :lower
               :upper
               :titlecase

Another possibility for modifiers and even more detail would be to include an "expert" option linking to documentation or just add View documentation 🔗 to the list. I don't think JabRef already has a convention for context-sensitive help on menus, but I could be wrong.

@priyanshu16095
Copy link
Contributor Author

priyanshu16095 commented Mar 14, 2025

@ryan-carpenter I was unable to convey this properly. What I mean to say is that, without writing much additional code and by simply adding a few lines in the UI, it significantly improves the user experience. This is because there's no need to read any documentation or manually reopen the dropdown.
I will improve this based on the review.

@priyanshu16095 priyanshu16095 marked this pull request as draft March 20, 2025 01:52
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.

4 participants