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 tooltips (rdfs:comment or skos:definition) for custom properties #995

Merged
merged 6 commits into from
Jun 12, 2020

Conversation

osma
Copy link
Member

@osma osma commented Jun 12, 2020

The tooltip content is read from rdfs:comment or skos:definition values of the property URI.

Example of Finnish Corporate Names showing RDA property definition as a tooltip:

kuva

Fixes #824

@osma osma added this to the 2.7 milestone Jun 12, 2020
@codecov
Copy link

codecov bot commented Jun 12, 2020

Codecov Report

Merging #995 into master will increase coverage by 0.04%.
The diff coverage is 68.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #995      +/-   ##
============================================
+ Coverage     59.12%   59.16%   +0.04%     
- Complexity     1548     1552       +4     
============================================
  Files            32       32              
  Lines          4335     4386      +51     
============================================
+ Hits           2563     2595      +32     
- Misses         1772     1791      +19     
Impacted Files Coverage Δ Complexity Δ
model/sparql/GenericSparql.php 68.05% <0.00%> (-0.36%) 317.00 <0.00> (ø)
model/Concept.php 78.57% <100.00%> (-1.22%) 189.00 <0.00> (+2.00) ⬇️
model/ConceptProperty.php 96.29% <100.00%> (+0.46%) 19.00 <1.00> (+2.00)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9877c8...c1ab089. Read the comment docs.

@osma osma marked this pull request as ready for review June 12, 2020 12:16
@osma osma requested a review from kouralex June 12, 2020 12:18
Comment on lines 24 to 27
* @param string $prop property type eg. 'rdf:type'.
* @param string $label
*/
public function __construct($prop, $label, $super=null, $sort_by_notation=false)
public function __construct($prop, $label, $tooltip=null, $super=null, $sort_by_notation=false)
Copy link
Contributor

Choose a reason for hiding this comment

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

One could document any new parameter(s) here.
On a side note, it's also a bit risky to add a parameter in the middle of a constructor call parameter list, but in this case it does not cause trouble. It may very well be intended, though, if one thinks it is a more important one to have.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right, the phpdoc declaration for the new parameter is missing.

I added the parameter in the middle because in PHP, only the last parameters can be omitted. Since there is a need to call the constructor both with and without the last two parameters, this was the only clean option. I did check all calls to the constructor.

@@ -47,7 +50,7 @@ public function getLabel()
}

// if not, see if there was a label for the property in the graph
if ($this->label) {
if ($this->label !== null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a side note: I can see why this was done, but does not - nevertheless - change the code behavior a bit. But one can argument for code quality measures, and I agree.

Copy link
Member Author

Choose a reason for hiding this comment

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

I copied and pasted some of the code for the label method into description and noticed this potential problem, so I fixed it in both places. In PHP, a string containing a zero "0" evaluates as false. It's an unlikely label, I know, but still, the behavior does change a little bit here ;)

* @return string
*/
public function getDescription()
{
$helpprop = $this->prop . "_help";

return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext
// see if we have a translation with the help text
$help = gettext($helpprop);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will prefer Skosmos translations, but that will must likely be OK.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, that's the intent (same as for property labels)

@@ -62,7 +62,7 @@
{% if property.getSubPropertyOf != 'skos:hiddenLabel' %}
<div class="row{% if property.type == 'dc:isReplacedBy' %} replaced-by{% endif%}">
<div class="property-label">
<span class="versal{% if property.type == 'rdf:type' %}-bold{% endif %}{% if not (property.type in property.description and '_help' in property.description) %} property-click" title="{{ property.description }}"{% else %}"{% endif %}>{{ property.label|upper }}</span>
<span class="versal{% if property.type == 'rdf:type' %}-bold{% endif %}{% if property.description %} property-click" title="{{ property.description }}"{% else %}"{% endif %}>{{ property.label|upper }}</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

This could only have an if part.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good catch!

Copy link
Contributor

@kouralex kouralex left a comment

Choose a reason for hiding this comment

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

Clean and nice code. Just minor comments.

@sonarcloud
Copy link

sonarcloud bot commented Jun 12, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@kouralex kouralex merged commit a1f214b into master Jun 12, 2020
@osma osma deleted the issue824-custom-property-tooltip branch February 17, 2021 14:09
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.

Support tooltips for custom properties
2 participants