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

Release 0.14.0 #518

Merged
merged 26 commits into from
Mar 2, 2022
Merged

Release 0.14.0 #518

merged 26 commits into from
Mar 2, 2022

Conversation

jgonggrijp
Copy link
Member

As previously discussed with @BeritJanssen and @JeltevanBoheemen, I prepared a release branch in which I swept up a substantial amount of bugs, both documented and undocumented. I also made a few minor enhancements. This is now finally ready for review. This release branch is currently deployed on the acceptance server, so it is easy to preview.

Summarizing the changes:

  • Addressed the issue where the annotation list panel and the highlights might disappear when refreshing a source (Upon reloading of a source, annotation highlights disappear #401), by including the /annotations prefix in the source panel's self-reported URL when applicable.
  • Tackled the [object Object] in the source metadata ( Source metadata creator always display "object Object" #511).
  • Stopped the source metadata edit button from falling out of its floating panel (undocumented).
  • Fixed a couple of undocumented oversights that caused the annotation metadata table in the annotation panel to stay empty.
  • Fixed an undocumented bug that sometimes still prevented annotation list and search result panels from scrolling to the correct position on deep link.
  • Replaced the "Adjust filter" title text of the filter button by "Filter". This is a slight overlap with Feature/interface clarifications #513.
  • Implemented the reformatted item summary block discussed in User interface clarifications #447. This includes a change that prevents item summary blocks from becoming extremely tall when a user decides to highlight a whole page.
  • Made the focus/blur behavior entirely consistent accross all types of list panels: the item or search result in focus has a border while all other items have reduced opacity, and clicking on an item that already has focus deselects it. Before the current branch, only the search result list panel completely followed that convention. In the annotation list panel, clicking on a focused annotation would remove its border and reduce its opacity, but the corresponding detail panel would remain open. In the related items panel, it was total chaos; multiple items could appear to be selected at the same time. The latter panel was also the hardest to fix due to the grouping of the relations by predicate. Fixing all of this comprised nearly half of the commits on this branch:
    • I had to introduce a new collection adapter, MappedCollection, which does what the name suggests and is analogous to FilteredCollection.
    • I had to take extra care in the related items panel to ensure that all items were part of a single FlatItemCollection shared between the predicate groups. This was necessary to maintain the invariant that at most one item receives focus at any given time. Two layers of mapping and one layer of filtering ensure that each subview gets its own subset of flat items from this common collection.
    • I had to change the related items panel and the annotation list panel to rely on focus/blur events from the collection instead of on click events from the subviews. This is a good reminder that state-dependent transitions in the view layer should generally follow state changes in the model layer, rather than reacting directly to other events in the view layer.
    • A small style change.
  • Besides the above, I made several minor code quality enhancements, including writing new unittests for some pre-existing code units.

While I'm sure this is a major usability improvement overall, the code churn is substantial, so I think a critical code review is advisable.

This table has been appearing empty for a while, but this was not
documented yet in an issue. Two mistakes in the code contributed to
this:

1. Handlers for model.whenever in AnnotationPanel were reading
   arguments from the wrong position with incorrectly annotated type.
2. ItemMetadataView actually expects a Node, not a FlatItem.

I fixed the issue by rectifying both of the above mistakes.
The lack of self-updating prevented the item metadata table from
populating in a deep-linked annotation panel.
This was preventing focus on annotation deep link.
59d5713 fixed annotation focus on deep link, but broke focus on
clickthrough to a different source (e.g. from a related items panel).
By adding back an unconditional delay, both scenarios should work.
Besides the fact that this code needed serious cleanup, this also
fixes the toggling behavior of the panel.
This enables a single related item to be focused at any given time,
despite the related items being distributed over multiple groups.
Copy link
Contributor

@JeltevanBoheemen JeltevanBoheemen left a comment

Choose a reason for hiding this comment

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

Excellent work @jgonggrijp. I have left a few remarks/questions.

The changed code makes sense. I have confirmed the bugs that are reported as fixed no longer occur.
The addition of MappedCollection goes beyond my understanding of the frontend, and maybe of TypeScript in general. I have read through the code but quickly got lost. I understand how and why such a collection would be used though, which is more important.

<p class="title is-5">{{#if label}}{{label}}{{else}}{{text}}{{/if}}</p>
<p class="subtitle is-6">({{classLabel}})</p>
{{#text}}
<p class="title is-5">{{.}}</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

What does the {{.}} here signify? I presume it is rendered with some variable from the view?

Copy link
Member Author

Choose a reason for hiding this comment

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

In Handlebars and Mustache, {{.}} stands for the current context as a whole. For example, these data:

{
    "text": "abcdef"
}

with this template:

{{#text}}{{.}}{{/text}}

will give this output:

abcdef

@@ -44,39 +44,36 @@ export default class AnnotationView extends CompositeView<FlatItem> {
this.render().listenTo(model, 'change', this.render);
}

processAnnotation(annotation: FlatItem): void {
processAnnotation(model: FlatItem, annotation: Node): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

model parameter does not appear to be used

Copy link
Member Author

Choose a reason for hiding this comment

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

This method is an event handler. The event includes the model as the first payload argument. So while the method does not actually use the model, we still have to include it in the parameter list.

click: this.onSummaryBlockClicked,
hover: this.onSummaryBlockHovered,
}, this);
this.listenTo(this.collection, 'focus blur', this.trigger);
Copy link
Contributor

Choose a reason for hiding this comment

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

What is triggered here? I'm familiar with trigger('someEvent')

Copy link
Member Author

Choose a reason for hiding this comment

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

This is basically a forwarding construction. When this.collection triggers focus or blur, the view re-emits this same event with the same payload.

// prevent this behavior here because the mapping is noninjective. This
// is a bit of a stop-gap solution, but it should pose no problem in
// this case.
this.relatedItems.stopListening(this.relations, 'remove');
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea providing comment to explain this. Has the potential to cause unexpected behaviour.


function announce() {
if (this.toolbarModel.get('annotations')) {
announceAnno.call(this);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice

@jgonggrijp
Copy link
Member Author

The addition of MappedCollection goes beyond my understanding of the frontend, and maybe of TypeScript in general. I have read through the code but quickly got lost. I understand how and why such a collection would be used though, which is more important.

Where did you first get lost? That might be a location for some additional documentation.

@JeltevanBoheemen JeltevanBoheemen merged commit 443a145 into develop Mar 2, 2022
@jgonggrijp jgonggrijp deleted the release/0.14.0 branch March 3, 2022 10:28
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.

2 participants