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

[VUFIND-1614] Modernize PubDateVisAjax recommendation module #4275

Open
wants to merge 18 commits into
base: dev
Choose a base branch
from

Conversation

ThoWagen
Copy link
Contributor

@ThoWagen ThoWagen commented Feb 28, 2025

In this PR a combination of charts.js and the date range slider from #4238 is used to replace PubDateVisAjax solution using the jQuery Flot library. The aim was also to increase accessibility and general user experience by using a slider and input fields instead of manipulating the chart with the mouse.

  • Resolve VUFIND-1614 when merging
  • Update changelog when merging

@demiankatz demiankatz requested a review from sturkel89 February 28, 2025 18:46
@demiankatz demiankatz added this to the 11.0 milestone Feb 28, 2025
@demiankatz demiankatz added accessibility architecture pull requests that involve significant refactoring / architectural changes labels Feb 28, 2025
Copy link
Contributor

@sturkel89 sturkel89 left a comment

Choose a reason for hiding this comment

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

I think this interface is a nice improvement over the existing tool. When it's activated, the user can be very specific about the date range they want to see via the sliders or the text entry boxes.

In the existing tool, the user can only drag to select, it's not clear how to do that, and the selection is very imprecise. Also, if the user wants to change their selection, they can't adjust on one end only; they need to redraw the entire selection.

In any case, the new tool improves functionality! But I have a couple of critiques and questions.

NB: the universe of publication dates in the test data goes from 1783 through 2016.

Test:
image

Dev:
image


True/False setting is not functional

In searches.ini, this is how Demian suggested I set up this tool:

default_top_recommend[] = "PubDateVisAjax:true:publishDate"

With the option set to 'true,' when the user selects a date range the timeline zooms in and only shows the specified dates plus a buffer of five years outside those boundaries:

Test
image

Dev
image

If the option is changed to 'false' on test, the zooming in doesn't happen. The user selects a date range, and the graphic shows the shaded area for the date range of interest in the context of the full date range for the entire universe of materials.

This 'false' setting is functional in the dev branch, but not in the new tool on the test branch.

Test (display is the same with setting at true or false)
image

Dev
image


Visibility of text entry boxes and Set and Clear buttons

I don't like that the controls (text entry boxes and set and clear buttons) are only visible after you begin interacting with the slider, and also disappear after you clear your selections.

I understand that it saves vertical space to hide those controls when the user is not interested in interacting with the slider, so I'm not sure what the best solution is here. Could there be an option in searches.ini that would allow the library to specify whether the controls are always visible vs. only visible during use?

Or maybe the default should be that the actual years covering the collection are selected with the shading and data entry boxes, and all of the parts of the tool are visible at all times? The current default seems colorless when you compare it with the tool when it's "in action."


Year-specific publications

It's a nice touch that the user can mouse over a specific bar in the graph to see how many items were published in that particular year. However, it's frustrating that the bar and/or pop-up are not clickable to limit the results to ONLY the nine items published in 1992.

image


General aesthetics

  1. I prefer the shorter height of the date range display on dev.

  2. I would prefer a more attractive color for the shading, or the option to specify the color. The brown is unappealing to my eye.

  3. I like the faint vertical lines that appear at 50 year intervals on the dev version. The blank field behind the timeline on test is a little too vast.

  4. Would it be possible to emulate dev in displaying the year range in "round" numbers? It would be nice to always have these more standardized years displayed on the graphic. You can see the examples in the screenshots above; here's a textual description of the differences between test and dev:

    • The labels on dev before limits are applied show 1800, 1850, 1900, 1950, and 2000. The labels on test show 1778, 1803, 1828, 1853, .... 1953, 1978, 2003.

    • After limits are applied, dev still displays the graph with labels at every five years (1970 1975 1980 ... 2010 2015 2020) while test now uses a different set of non-round numbers (1970 1976 1982 1988 1994 2000 2006 2012 2018)

@ThoWagen
Copy link
Contributor Author

ThoWagen commented Mar 4, 2025

Thanks @sturkel89, those are some good points!

True/False setting is not functional
The zoom setting is now fixed.

Visibility of text entry boxes and Set and Clear buttons
I also added the option to always display the controls as you suggested. You can control this by setting "true" or "false" after the zoom setting, i.e.

Always show controls
default_top_recommend[] = PubDateVisAjax:true:false:publish_year

Hide controls initially
default_top_recommend[] = PubDateVisAjax:true:true:publish_year

Year-specific publications
If you click in the chart, the selection will be reduced to the respective year.

General aesthetics

  1. The height of the chart is now reduced. This can also be customized in own themes.
  2. I changed the default color to blue. Do you like this more? This is also easily customizable in custom themes.
  3. The grid is now being displayed.
  4. We need to write some own logic for that but now the labels should be nicely distributed.

@demiankatz demiankatz requested a review from sturkel89 March 4, 2025 16:46
Copy link
Contributor

@sturkel89 sturkel89 left a comment

Choose a reason for hiding this comment

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

Thanks, @ThoWagen ! I think this is looking better and better. It is almost perfect!

I like the new more vertically compact layout, the "round" years, and the presence of tick marks. I also see that zooming works well.

Here are a couple of screenshots:

Bootstrap5:

image

Sandal5:

image


Tick marks

My critique of the tick marks is that I'd prefer if they lined up with the years instead of being between years. I am inclined to create my custom date range by dragging from tick mark to tick mark, but then I end up with "odd" years selected. This is the selection I made that resulted in the outcome above:

image

Could the tick marks be aligned with the year labels, as they are on dev?


Colors

I like the blue much better than the brown! I think the color looks great in bootstrap5.

I think the color seems a little bit intense in sandal5 since there are other strong colors there in the header -- however, it's not terrible. It might look better if it repeated one of the lighter colors that's already in use on the page -- from the breadcrumbs bar, or background of the Reset Filters button, or the background of the sidebar.


Settings confusion

You showed this example of the settings line with controls always displayed:

default_top_recommend[] = PubDateVisAjax:true:false:publish_year

I have been using this setting, based on Demian's suggestion to me when I first checked the PR:

default_top_recommend[] = PubDateVisAjax:true:publishDate

I'm finding that if I change the last bit to publish_year, I don't see the slider at all. Only publishDate works for me. Is this expected?

(I see that the true:true setting hides the text entry and set/clear buttons initially, and the true:false setting shows them all the time, so that improvement works!)

@ThoWagen
Copy link
Contributor Author

ThoWagen commented Mar 5, 2025

The grid is now aligned with the labels and I adjusted the color in sandal5. What do you think @sturkel89?

And we use a different facet name locally so I accidentally used that in the example. With the standard VuFind index you should use default_top_recommend[] = PubDateVisAjax:true:false:publishDate and default_top_recommend[] = PubDateVisAjax:true:false:publishDate instead as you probably have already done. Sorry for the confusion.

@ThoWagen ThoWagen requested a review from sturkel89 March 5, 2025 12:35
Copy link
Contributor

@sturkel89 sturkel89 left a comment

Choose a reason for hiding this comment

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

Thanks for making these adjustments, @ThoWagen! The tick marks now align with the "round" years, and it's easy to use the sliders to select those round years. The gray color in Sandal5 looks better to me than the more intense blue.

image

You've done so much, so I hesitate to ask for any other changes. I'll report my TINY new thought/question: could the bars in the graph be solid instead of outlined? I think the feature looks a bit busy the way it is, and would be easier on the eyes if the bars were filled in with the same solid color as the outline.

I'll submit this as a comment and will be happy to change to 'approve' after hearing back from you. Thanks!

@ThoWagen
Copy link
Contributor Author

ThoWagen commented Mar 5, 2025

@sturkel89 I agree that solid bars looks better. I only changed it for sandal5 for now, since I was not sure if you only meant that.

And please feel always free to always suggest improvements! I'm happy to invest the work if there is room for improvement :)

@ThoWagen ThoWagen requested a review from sturkel89 March 5, 2025 15:21
Copy link
Contributor

@sturkel89 sturkel89 left a comment

Choose a reason for hiding this comment

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

That looks great!!

image

I would suggest making the same change to bootstrap5 as well. It would surely be an improvement.

image

I'm not sure what you were planning to do, but in my opinion the default setting should be:

default_top_recommend[] = PubDateVisAjax:true:false:publishDate

I think this feature will be completely ready to merge once the bars are filled in in the second theme. Thanks so much!

@ThoWagen
Copy link
Contributor Author

ThoWagen commented Mar 5, 2025

@sturkel89 Now the bars are also filled in the bootstrap5 theme.

The default for zooming has already been "false" and I don't think we should change that now. But the controls are always visible by default.

@ThoWagen ThoWagen requested a review from sturkel89 March 5, 2025 17:04
Copy link
Contributor

@sturkel89 sturkel89 left a comment

Choose a reason for hiding this comment

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

Looks great!

image

I understand your preference to not change the default. I hope the libraries that adopt this tool will consider the options and make the best decision. In any case, as far as I'm concerned, this is ready to merge!

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @ThoWagen, for all the improvements, and @sturkel89 for the thorough testing and feedback!

See below for a few minor suggestions from a review of the code.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @ThoWagen -- nearly done, but I think there might be just one case of using the wrong kind of escaping in the wrong context.

<?=$this->results->getUrlQuery()->asHiddenFields(['page' => '/./', 'filter' => "/^{$facetField}:.*/"])?>
<input type="hidden" name="daterange[]" value="<?=$this->escapeHtmlAttr($facetField)?>">
<form class="datevis-form facet-range-form hidden" name="datevis<?=$facetFieldEsc?>xForm" id="datevis<?=$facetFieldEsc?>xForm" data-name="<?=$facetFieldEsc?>" data-filter-field="daterange[]">
<?=$this->results->getUrlQuery()->asHiddenFields(['page' => '/./', 'filter' => "/^{$facetFieldEsc}:.*/"])?>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to use $facetFieldEsc here, since this is a regex rather than HTML.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, don't know how I overlooked that. Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, should we use preg_quote since that is a regex?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I think preg_quote would be appropriate in this context. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, I added it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility architecture pull requests that involve significant refactoring / architectural changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants