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

Searchlinks in Additional metadata and more consistent Info panel UI #3871

Merged
merged 22 commits into from
Oct 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
dd961a7
Link Title
paperboyo Sep 27, 2022
df4f288
Italicise Multiple descriptions
paperboyo Sep 27, 2022
86e6d22
Italicise multiple dateTakens
paperboyo Sep 27, 2022
40ae597
Italicise Multiple descriptions again, but better
paperboyo Sep 27, 2022
a7bc637
Make Photoshoots look like the rest
paperboyo Sep 27, 2022
491e1f0
Add search links to Additional metadata keys
paperboyo Sep 28, 2022
d7c1fee
Make fieldAlias.elasticsearchPath available to Additional metadata fo…
paperboyo Sep 28, 2022
e6203ab
Fix title logic
paperboyo Sep 28, 2022
fd56dfc
Update kahuna/public/js/components/gr-image-metadata/gr-image-metadat…
paperboyo Sep 28, 2022
2b1db98
Show Unknown for empty Credit when user can’t edit
paperboyo Sep 29, 2022
7b802c2
When empty and user can’t edit, hide Taken, Location, Filename and Pe…
paperboyo Sep 29, 2022
b7b3cf8
fix clientside queryparser emulation to accept chip names containing …
andrew-nowak Sep 30, 2022
2505fe3
Go back to b68b1b7 for Andrew’s regex fix
paperboyo Oct 3, 2022
92ca2c2
Use alias instead of elsticsearchPath
paperboyo Oct 3, 2022
9622fa5
Make longer chips not break in ugly ways
paperboyo Oct 3, 2022
6542932
Add bylineTitle to QuerySyntax…
paperboyo Oct 3, 2022
bc2ef26
Revert "Make longer chips not break in ugly ways"
paperboyo Oct 5, 2022
57b8b7e
Revert any regex changes
paperboyo Oct 5, 2022
b4422d6
Empty Date Taken to always show as Unknown
paperboyo Oct 7, 2022
3f3e133
Fix Location hiding logic…
paperboyo Oct 10, 2022
3e0ce41
Fix People for unpermissioned users
paperboyo Oct 11, 2022
be5bfa8
Modify spaceWords so that it gives us Title Case
paperboyo Oct 14, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,40 @@
'image-info__editor--saving': titleEditForm.$waiting,
'text-input': true}">

<div ng-if="ctrl.userCanEdit">
<dd class="image-info__title" ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
<div ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata.title) && ctrl.userCanEdit">
<dd class="image-info__title">
Multiple titles (click ✎ to edit <strong>all</strong>)
</dd>
</div>

<div ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata.title) && !ctrl.userCanEdit">
<dd class="image-info__title">
Multiple titles
</dd>
</div>

<div ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.title) && !ctrl.metadata.title" class="editable-empty"">
<dd ng-if="ctrl.userCanEdit">
Unknown (click ✎ to add)
</dd>
<dd ng-if="!ctrl.userCanEdit">
Unknown
</dd>
</div>

<div ng-if="ctrl.userCanEdit">
<dd class="image-info__title"
ng-class="{'editable-empty': !ctrl.metadata.title}"
ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
{{ctrl.metadata.title || "Unknown (click ✎ to add)"}}
<a ui-sref="search.results({query: (ctrl.metadata.title | queryFilter:'title'), nonFree: ctrl.srefNonfree()})"
aria-label="Search images by {{ctrl.metadata.title}} title">{{ctrl.metadata.title}}</a>
</dd>
</div>

<div ng-if="!ctrl.userCanEdit">
<dd class="image-info__title" ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
Multiple titles
</dd>

<dd class="image-info__title"
ng-class="{'editable-empty': !ctrl.metadata.title}"
ng-if="!ctrl.hasMultipleValues(ctrl.rawMetadata.title)">
{{ctrl.metadata.title || "Unknown"}}
<a ui-sref="search.results({query: (ctrl.metadata.title | queryFilter:'title'), nonFree: ctrl.srefNonfree()})"
aria-label="Search images by {{ctrl.metadata.title}} title">{{ctrl.metadata.title}}</a>
</dd>
</div>
</div>
Expand All @@ -100,7 +113,7 @@
ng-hide="descriptionEditForm.$visible">✎</button>
<dt class="metadata-line metadata-line__key">Description</dt>
<form editable-form name="descriptionEditForm" onaftersave="ctrl.updateDescriptionField('description', $data)">
<div ng-hide="descriptionEditForm.$visible">
<div ng-hide="descriptionEditForm.$visible" ng-class="{'image-info--multiple': ctrl.hasMultipleValues(ctrl.rawMetadata.description)}">
<div ng-if="ctrl.userCanEdit">
<dd class="image-info__description"
ng-if="ctrl.hasMultipleValues(ctrl.rawMetadata.description)"
Expand Down Expand Up @@ -129,7 +142,6 @@
</div>
<div
class="metadata-line__info"
ng-class="{'image-info--multiple': ctrl.hasMultipleValues(ctrl.rawMetadata.description)}"
editable-textarea="ctrl.metadata.description"
ng-hide="descriptionEditForm.$visible"
e:msd-elastic
Expand Down Expand Up @@ -220,6 +232,7 @@
>✎</button>

<span editable-datetime-local="ctrl.metadata.dateTaken"
ng-class="{'image-info--multiple': ctrl.hasMultipleValues(ctrl.rawMetadata.dateTaken)}"
ng-hide="takenEditForm.$visible"
onbeforesave="ctrl.updateMetadataField('dateTaken', $data)"
e:form="takenEditForm"
Expand All @@ -241,6 +254,7 @@
</span>

<span class="editable-empty" ng-if="!ctrl.metadata.dateTaken && ctrl.userCanEdit">Unknown (click ✎ to add)</span>
<span class="editable-empty" ng-if="!ctrl.metadata.dateTaken && !ctrl.userCanEdit">Unknown</span>
</span>
</span>
</dd>
Expand Down Expand Up @@ -333,14 +347,21 @@
</span>

<span class="editable-empty" ng-if="!ctrl.metadata.credit && ctrl.userCanEdit">Unknown (click ✎ to add)</span>
<span class="editable-empty" ng-if="!ctrl.metadata.credit && !ctrl.userCanEdit">Unknown</span>
</span>
</span>
</span>

</dd>

<dt ng-hide="locationEditForm.$visible" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">Location</dt>
<dd class="image-info__wrap metadata-line metadata-line__info image-info__group--dl__value--panel">
<dt ng-if="(ctrl.hasLocationInformation() || ctrl.hasMultipleValues(ctrl.rawMetadata.subLocation) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.city) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.state) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.country)) || ctrl.userCanEdit" ng-hide="locationEditForm.$visible" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">Location</dt>
<dd ng-if="(ctrl.hasLocationInformation() || ctrl.hasMultipleValues(ctrl.rawMetadata.subLocation) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.city) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.state) ||
ctrl.hasMultipleValues(ctrl.rawMetadata.country)) || ctrl.userCanEdit" class="image-info__wrap metadata-line metadata-line__info image-info__group--dl__value--panel">
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm probably missing something - what is the reason for checking ctrl.hasMultipleValues on the city, state, and country separately to hasLocationInformation()? Is the location information returned on rawMetadata different from metadata?

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, but the honest answer is: I don’t know. This was kindly suggested by @andrew-nowak after it wasn’t working correctly before. All fault mine, obviously…

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries, I thought I'd check since I understood ctrl.hasMultipleValues was being used elsewhere to display Multiple something in the field but didn't seem like that's what we want for the location fields

Copy link
Member

Choose a reason for hiding this comment

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

thanks! the difference (I think) is that previously the location field was always shown, whereas we now want to not show the location field if there's no data and the user cannot edit. In an ideal world the hasLocationInformation would reliably tell us if there's location info or not, but currently it only works on single image selection. We could update it to understand multiple image selection, but it is also used elsewhere and we don't want/have time to untangle right now.

(The highlighted code is similar to the existing

ng-if="!ctrl.hasLocationInformation() &&
ctrl.userCanEdit &&
(!ctrl.hasMultipleValues(ctrl.rawMetadata.subLocation) &&
!ctrl.hasMultipleValues(ctrl.rawMetadata.city) &&
!ctrl.hasMultipleValues(ctrl.rawMetadata.state) &&
!ctrl.hasMultipleValues(ctrl.rawMetadata.country))">Unknown (click ✎ to add)</span>
)

<button data-cy="it-edit-loc-button"
class="image-info__edit"
ng-if="ctrl.userCanEdit && ctrl.metadataUpdatedByTemplate.length == 0"
Expand Down Expand Up @@ -523,8 +544,8 @@
</span>
</dd>

<dt ng-if="!ctrl.hasMultipleValues(ctrl.extraInfo.filename)" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">Filename</dt>
<dd ng-if="!ctrl.hasMultipleValues(ctrl.extraInfo.filename)" class="metadata-line metadata-line__info image-info__group--dl__value image-info__group--dl__value--panel">
<dt ng-if="!ctrl.hasMultipleValues(ctrl.extraInfo.filename) && ctrl.extraInfo.filename" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">Filename</dt>
<dd ng-if="!ctrl.hasMultipleValues(ctrl.extraInfo.filename) && ctrl.extraInfo.filename" class="metadata-line metadata-line__info image-info__group--dl__value image-info__group--dl__value--panel">
<span
class="metadata-line__info select-all-wrap"
title="{{ctrl.extraInfo.filename}}">{{ctrl.extraInfo.filename}}</span>
Expand All @@ -546,8 +567,8 @@
</span>
</dd>

<dt ng-if="(ctrl.rawMetadata.peopleInImage || ctrl.userCanEdit)" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">People</dt>
<dd ng-if="(ctrl.rawMetadata.peopleInImage || ctrl.userCanEdit)" class="image-info__people image-info__wrap metadata-line metadata-line__info image-info__group--dl__value--panel">
<dt ng-if="ctrl.rawMetadata.peopleInImage.length > 0 || ctrl.userCanEdit" class="image-info__wrap metadata-line metadata-line__key image-info__group--dl__key--panel">People</dt>
<dd ng-if="ctrl.rawMetadata.peopleInImage.length > 0 || ctrl.userCanEdit" class="image-info__people image-info__wrap metadata-line metadata-line__info image-info__group--dl__value--panel">
<button data-cy="it-edit-people-button"
class="metadata-people__button"
ng-class="{'small': ctrl.grSmall}"
Expand Down Expand Up @@ -597,12 +618,18 @@
<div ng-if="!ctrl.isMetadataSectionHidden('additionalMetadata')" class="metadata metadata-line image-info__group--dl">
<dl ng-repeat="(key, value) in ctrl.metadata" ng-if="ctrl.isUsefulMetadata(key)" class="metadata__body image-info__group--dl">
<dt class="metadata-line__key image-info__group--dl__key--full-metadata">{{key | spaceWords}}</dt>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">{{value}}</dd>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">
<a ui-sref="search.results({query: (value | queryFilter:'{{key}}'), nonFree: ctrl.srefNonfree()})"
aria-label="Search images with {{key}} '{{value}}'">{{value}}</a>
</dd>
</dl>

<dl ng-repeat="(key, value) in ctrl.additionalMetadata" class="metadata__body image-info__group--dl">
<dl ng-repeat="(key, metadata) in ctrl.additionalMetadata" class="metadata__body image-info__group--dl">
<dt class="metadata-line__key image-info__group--dl__key--full-metadata">{{key}}</dt>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">{{value}}</dd>
<dd class="metadata-line__info image-info__group--dl__value--full-metadata">
<a ui-sref="search.results({query: (metadata.value | queryFilter:'{{metadata.alias}}'), nonFree: ctrl.srefNonfree()})"
aria-label="Search images with {{key}} '{{metadata.value}}'">{{metadata.value}}</a>
</dd>
</dl>

<dl ng-repeat="(key, value) in ctrl.identifiers" class="metadata__body image-info__group--dl">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,10 @@ module.controller('grImageMetadataCtrl', [

ctrl.additionalMetadata = Object.fromEntries(
Object.entries(ctrl.singleImage.data.aliases)
.map(([key, val]) => {
.map(([key, value]) => {
let fieldAlias = ctrl.fieldAliases.find(_ => _.alias === key);
if (fieldAlias && fieldAlias.displayInAdditionalMetadata === true) {
return [fieldAlias.label, val];
return [fieldAlias.label, { value, alias: fieldAlias.alias}];
}
})
.filter(_ => _ !== undefined));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</button>

<span editable-text="ctrl.photoshootData.title"
class="metadata-line__info"
ng-hide="photoshootEditForm.$visible"
e:form="photoshootEditForm"
e:uib-:typeahead="photoshoot for photoshoot in ctrl.search($viewValue) | limitTo:8"
Expand All @@ -26,7 +27,7 @@
</a>
</span>

<span ng-if="!ctrl.hasSinglePhotoshoot">
<span ng-if="!ctrl.hasSinglePhotoshoot" class="image-info--multiple metadata-line__info">
Multiple photoshoots (click ✎ to edit <strong>all</strong>)
</span>
</span>
Expand Down
3 changes: 1 addition & 2 deletions kahuna/public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,9 @@ kahuna.filter('getInitials', function() {
});

kahuna.filter('spaceWords', function() {
return str => str.replace( /([A-Z]+)/g, $1 => ' ' + $1.toLowerCase() );
return str => str.charAt(0).toUpperCase() + str.replace( /([A-Z]+)/g, " $1").slice(1)
});


kahuna.directive('uiDragData', function() {
return {
restrict: 'A',
Expand Down
1 change: 1 addition & 0 deletions media-api/app/lib/querysyntax/QuerySyntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class QuerySyntax(val input: ParserInput) extends Parser with ImageFields {
"illustrator" |
"uploader" |
"location" | "city" | "state" | "country" | "in" |
"bylineTitle" |
"byline" | "by" | "photographer" |
"description" |
"credit" |
Expand Down