Skip to content

Commit

Permalink
fix: presentation-object-root-fixes (#426)
Browse files Browse the repository at this point in the history
* fix: replaced term values with links

* fix: added translations for units

* fix: changed copy url from page url to image url

* test: fixed tests

Co-authored-by: Arne Vandoorslaer <arne@digita.ai>
  • Loading branch information
lem-onade and Arne Vandoorslaer committed Aug 17, 2021
1 parent dd88337 commit d693fb5
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ describe('ObjectRootComponent', () => {
window.document.body.appendChild(component);
await component.updateComplete;

const collectionAnchor = window.document.body.getElementsByTagName('nde-object-root')[0].shadowRoot.querySelector<HTMLAnchorElement>('#identification-card div a');
const collectionAnchor = window.document.body.getElementsByTagName('nde-object-root')[0].shadowRoot.querySelector<HTMLAnchorElement>('#collection-link');

collectionAnchor.click();

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,6 @@ export class ObjectRootComponent extends RxLitElement {
<a target="_blank" href="${this.object.uri}">
${this.translator.translate('nde.features.object.options.view-rdf')}
</a>
<a @click="${ () => navigator.clipboard.writeText(window.location.href)
.then(() => this.actor.parent.send(new AddAlertEvent({ type: 'success', message: this.translator.translate('nde.common.copied-url') })))}">
${this.translator.translate('nde.features.object.options.share')}
</a>
</div>
</nde-popup>
</div>
Expand Down Expand Up @@ -186,8 +182,13 @@ export class ObjectRootComponent extends RxLitElement {
<div> <a target="_blank" href="${this.object.license}">${ this.translator.translate(`nde.features.object.card.image.field.license.${this.object.license}`) }</a> </div>
</div>
<div class="object-property">
<div> ${ this.translator.translate('nde.features.object.card.field.download') } </div>
<div> <a target="_blank" href="${this.object.image}" download> ${ unsafeSVG(Download) } </a> </div>
<div> ${ this.translator.translate('nde.features.object.card.field.image-source') } </div>
<div>
<a target="_blank" @click="${ () => navigator.clipboard.writeText(this.object?.image)
.then(() => this.actor.parent.send(new AddAlertEvent({ type: 'success', message: this.translator.translate('nde.common.copied-image-url') })))}">
${ this.translator.translate('nde.features.object.options.share') }
</a>
</div>
</div>
<nde-popup dark id="image-popup">
<div slot="content">
Expand Down Expand Up @@ -215,7 +216,7 @@ export class ObjectRootComponent extends RxLitElement {
</div>
<div class="object-property" ?hidden="${ !this.object.additionalType || this.object.additionalType?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.additionalType') } </div>
<div> ${ this.object.additionalType?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.additionalType?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.name || this.object.name?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.name') } </div>
Expand All @@ -227,7 +228,7 @@ export class ObjectRootComponent extends RxLitElement {
</div>
<div class="object-property" ?hidden="${ !this.object.collection || this.object.collection?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.collection') } </div>
<div> <a @click="${ () => this.actor.parent.send(new SelectedCollectionEvent(collection)) }">${ collection?.name }</a> </div>
<div> <a id="collection-link" @click="${ () => this.actor.parent.send(new SelectedCollectionEvent(collection)) }">${ collection?.name }</a> </div>
</div>
</div>
</nde-large-card>
Expand All @@ -244,15 +245,15 @@ export class ObjectRootComponent extends RxLitElement {
<div slot="content">
<div class="object-property" ?hidden="${ !this.object.creator || this.object.creator?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.creator') } </div>
<div> ${ this.object.creator?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.creator?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.locationCreated || this.object.locationCreated?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.locationCreated') } </div>
<div> ${ this.object.locationCreated?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.locationCreated?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.material || this.object.material?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.material') } </div>
<div> ${ this.object.material?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.material?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.dateCreated || this.object.dateCreated?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.dateCreated') } </div>
Expand All @@ -273,23 +274,23 @@ export class ObjectRootComponent extends RxLitElement {
<div slot="content">
<div class="object-property" ?hidden="${ !this.object.subject || this.object.subject?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.subject') } </div>
<div> ${ this.object.subject?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.subject?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.location || this.object.location?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.location') } </div>
<div> ${ this.object.location?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.location?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.person || this.object.person?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.person') } </div>
<div> ${ this.object.person?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.person?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.organization || this.object.organization?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.organization') } </div>
<div> ${ this.object.organization?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.organization?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.event || this.object.event?.length < 1 }">
<div> ${ this.translator.translate('nde.features.object.card.field.event') } </div>
<div> ${ this.object.event?.map((term) => html`<div>${term.name}</div>`) } </div>
<div> ${ this.object.event?.map((term) => html`<a target="_blank" href="${term.uri}">${term.name}</a>`) } </div>
</div>
</div>
</nde-large-card>
Expand All @@ -306,19 +307,19 @@ export class ObjectRootComponent extends RxLitElement {
<div slot="content">
<div class="object-property" ?hidden="${ !this.object.height }">
<div> ${ this.translator.translate('nde.features.object.card.field.height') } </div>
<div> ${ this.object.height } ${ this.object.heightUnit } </div>
<div> ${ this.object.height } ${ this.translator.translate(`nde.common.unit.${this.object.heightUnit}`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.width }">
<div> ${ this.translator.translate('nde.features.object.card.field.width') } </div>
<div> ${ this.object.width } ${ this.object.widthUnit } </div>
<div> ${ this.object.width } ${ this.translator.translate(`nde.common.unit.${this.object.widthUnit}`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.depth }">
<div> ${ this.translator.translate('nde.features.object.card.field.depth') } </div>
<div> ${ this.object.depth } ${ this.object.depthUnit } </div>
<div> ${ this.object.depth } ${ this.translator.translate(`nde.common.unit.${this.object.depthUnit}`) } </div>
</div>
<div class="object-property" ?hidden="${ !this.object.weight }">
<div> ${ this.translator.translate('nde.features.object.card.field.weight') } </div>
<div> ${ this.object.weight } ${ this.object.weightUnit } </div>
<div> ${ this.object.weight } ${ this.translator.translate(`nde.common.unit.${this.object.weightUnit}`) } </div>
</div>
</div>
</nde-large-card>
Expand Down
36 changes: 31 additions & 5 deletions packages/solid-crs-presentation/lib/i8n/nl-NL.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@
"value": "Licentie"
},
{
"key": "nde.features.object.card.field.download",
"key": "nde.features.object.card.field.image-source",
"locale": "nl-NL",
"value": "Download"
"value": "Afbeeldingslocatie"
},
{
"key": "nde.features.object.card.image.field.license.http://rightsstatements.org/vocab/InC/1.0/",
Expand Down Expand Up @@ -427,7 +427,7 @@
{
"key": "nde.features.object.options.share",
"locale": "nl-NL",
"value": "URL kopieren"
"value": "URL kopiëren"
},
{
"key": "nde.features.about.header.title",
Expand Down Expand Up @@ -505,8 +505,34 @@
"value": "jaar geleden"
},
{
"key": "nde.common.copied-url",
"key": "nde.common.unit.MMT",
"locale": "nl-NL",
"value": "URL van deze pagina werd gekopieerd"
"value": "mm"
},
{
"key": "nde.common.unit.CMT",
"locale": "nl-NL",
"value": "cm"
},
{
"key": "nde.common.unit.MTR",
"locale": "nl-NL",
"value": "m"
},
{
"key": "nde.common.unit.GRM",
"locale": "nl-NL",
"value": "g"
},
{
"key": "nde.common.unit.KGM",
"locale": "nl-NL",
"value": "kg"
},
{
"key": "nde.common.copied-image-url",
"locale": "nl-NL",
"value": "De URL van de afbeelding werd gekopieerd."
}

]
8 changes: 4 additions & 4 deletions packages/solid-crs-presentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
],
"coverageThreshold": {
"global": {
"statements": 89.3,
"statements": 89.07,
"branches": 86.72,
"lines": 89.96,
"functions": 75.66
"lines": 89.72,
"functions": 74.91
}
},
"automock": false,
Expand All @@ -109,4 +109,4 @@
}
}
}
}
}

0 comments on commit d693fb5

Please sign in to comment.