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

Only display CollectionList if record is a collection #4170

Merged
merged 3 commits into from
Dec 19, 2024

Conversation

LuomaJuha
Copy link
Contributor

@LuomaJuha LuomaJuha commented Dec 18, 2024

Adds an isActive function for CollectionList.php tab. Uses getHierarchyTrees to check if should be active. Tried with isCollection, but isCollection might be too limited for this case.

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.

@LuomaJuha, could you tell me a little more about the motivation behind this change? Collections and hierarchy trees are independently configurable settings, and while they are most commonly used together, I think there could be some situations where collections are turned on while hierarchies are turned off, and this change might cause problems. Normally, the CollectionList tab is only turned on for the collection view, so it's sort of implicitly appropriate.

(It's been literally years since I have reviewed all of this logic, so I may be misremembering what is possible... I just know there's a lot of flexibility, and I want to be careful about making the wrong assumption).

In any case, I assume there's an underlying problem that this is meant to solve, I just want to be sure this is the most appropriate solution!

@LuomaJuha
Copy link
Contributor Author

LuomaJuha commented Dec 18, 2024

@demiankatz sure! The description was pretty narrow but:

in situations where collectionlist is assigned to be shown for a record which has or has not any association with a hierarchy, the tab is always shown. If user then clicks the recordtab collectionlist, it will throw an error indicating that collectionField is not set for records without any assigned hierarchy fields. Idea was to create the function to check that if the record is really a part of a hierarchy.

Edit:
HierarchyTrees might not be the best for testing this but there is other functions like: getHierarchyTopID

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.

On further reflection, what do you think of this?

*/
public function isActive()
{
return parent::isActive() && $this->getRecordDriver()->tryMethod('getHierarchyTrees');
Copy link
Member

Choose a reason for hiding this comment

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

Seems like isCollection might be the safest bet of all:

Suggested change
return parent::isActive() && $this->getRecordDriver()->tryMethod('getHierarchyTrees');
return parent::isActive() && $this->getRecordDriver()->tryMethod('isCollection');

Is there any reason not to do it this way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CollectionList can be active on subrecords and seems like not all of them implements is_hierarchy_id which is used in isCollection function check. That is why i was thinking about if using getHierarchyTopID would be better for this occasion 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Is it possible this is just a configuration issue? The hierarchy configuration controls which records are considered to be collections and which are not, based on the Solr index. If you have records that act like collections but do not have is_hierarchy_id set, that sounds like something non-standard, and I wonder if it would make more sense to customize record drivers than to introduce non-standard behavior to the record tab.

Bottom line: my feeling is that, at least for the core code, this tab is meant to operate on collections, so the best check we can apply is confirming that the record under consideration is a collection. Anything else feels like introducing different rules here than everywhere else, which doesn't make sense to me. But as I say, it's been a while since I've reviewed all this, so maybe I'm overlooking something -- my feeling, though, is that if something is wrong, the problem runs deeper than just this tab, and maybe needs to be addressed somewhere else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, actually this comment clears up my thoughts. I think the isCollection check makes alot more sense now in this context 🤔

Copy link
Member

Choose a reason for hiding this comment

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

Great, thanks! I do think adding that check is an improvement, so if it works for you, I'll be happy to approve and merge this once the change is in place.

@LuomaJuha LuomaJuha changed the title Display CollectionList tab only if record has hierarchy trees Display CollectionList if record is a collection Dec 19, 2024
@LuomaJuha LuomaJuha requested a review from demiankatz December 19, 2024 12:04
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, @LuomaJuha!

@demiankatz demiankatz changed the title Display CollectionList if record is a collection Only display CollectionList if record is a collection Dec 19, 2024
@demiankatz demiankatz added this to the 11.0 milestone Dec 19, 2024
@demiankatz demiankatz merged commit 8aaa8a4 into vufind-org:dev Dec 19, 2024
6 checks passed
@LuomaJuha LuomaJuha deleted the add-check-for-collectionlist-tab branch December 19, 2024 12:27
EreMaijala pushed a commit to NatLibFi/NDL-VuFind2 that referenced this pull request Dec 20, 2024
LuomaJuha added a commit to NatLibFi/NDL-VuFind2 that referenced this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants