Skip to content

Commit f928ac8

Browse files
committed
Merge branch 'fix-570'
2 parents 4267fc9 + 723b221 commit f928ac8

File tree

10 files changed

+125
-23
lines changed

10 files changed

+125
-23
lines changed

features/item_consult.feature

+20
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,23 @@ Scénario:
1111
Et une des rubriques de l'item est "Sacrifice d'Abraham"
1212
Et une des rubriques de l'item est "Isaac"
1313
Et une des rubriques de l'item est "1er quart XVIe"
14+
15+
Scénario: l’utilisateur sélectionne un item sur un point de vue sur mobile
16+
17+
Soit "SJ 000" l'item affiché
18+
Et l'utilisateur est sur mobile
19+
Alors le titre de l'item affiché est "SJ 000"
20+
Et la valeur de l'attribut "spatial" est "Église Saint-Jean-au-Marché, Troyes"
21+
Et l'attribut "creator" est absent
22+
Et l'attribut "created" est absent
23+
Et la légende de l’image est "© Aurélien Bénel, 2016"
24+
25+
Scénario: l’utilisateur sélectionne une photo en noir et blanc sur un point de vue sur mobile
26+
27+
Soit "AXN 009 B&W" l'item affiché
28+
Et l'utilisateur est sur mobile
29+
Alors le titre de l'item affiché est "AXN 009"
30+
Et la valeur de l'attribut "spatial" est "Église Saint-Loup, Auxon"
31+
Et l'attribut "creator" est absent
32+
Et l'attribut "created" est absent
33+
Et la légende de l’image est "1907/1914"

features/step_definitions/context.rb

+4
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,7 @@
8181
expect(page).to have_content "Modification du point de vue"
8282
end
8383

84+
Soit("l'utilisateur est sur mobile") do
85+
page.current_window.resize_to(320, 480)
86+
end
87+

features/step_definitions/outcome.rb

+9
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,12 @@
6060
Alors('le point de vue {string} ne fait plus partie du portfolio') do |viewpoint|
6161
expect(page).not_to have_content viewpoint
6262
end
63+
64+
Alors("la légende de l’image est {string}") do |legend|
65+
expect(find(".Copyright")).to have_content legend
66+
end
67+
68+
Alors("l'attribut {string} est absent") do |attribute|
69+
expect(find(".Attributes")).not_to have_content attribute
70+
end
71+

features/support/env.rb

+4
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ def getURI(name)
2727
uri = "/item/Vitraux%20-%20Bénel/493f2a3702be0e9a67a6fd29700fd4dff8f6986a"
2828
when "SJ 001"
2929
uri = "/item/Vitraux%20-%20Bénel/8d27115e20f9439b627ac511ade9a05bbe509130"
30+
when "SJ 000"
31+
uri = "/item/Vitraux%20-%20Bénel/358d1c9f168311a9fe7bd7e2737c181514652e9d"
32+
when "AXN 009 B&W"
33+
uri = "/item/Vitraux - Recensement/d4dd4b9af975a07ecd0331307db8ca24daad7535"
3034
end
3135
return uri
3236
end

src/components/itemPage/Attribute.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Attribute extends React.Component {
4141

4242
render() {
4343
return (
44-
<div className="Attribute">
44+
<div className={`Attribute ${this.props.className}`}>
4545
<div className="Key">
4646
{this.props.name}
4747
</div>

src/components/itemPage/Copyright.jsx

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Trans } from '@lingui/macro';
2+
3+
/**
4+
* A simple copyright notice.
5+
*/
6+
const Copyright = ({ creator, created }) => {
7+
let copyrightText;
8+
// Black and white pictures have a different date format and no author,
9+
// which means we must handle them separately.
10+
if (!creator) {
11+
copyrightText = created;
12+
} else {
13+
let yearOrDate;
14+
// If created is not a valid date
15+
// (pictures with a creator may have a weird created field too).
16+
if (isNaN(Date.parse(created))) {
17+
yearOrDate = created;
18+
} else {
19+
yearOrDate = new Date(created).getFullYear().toString();
20+
}
21+
copyrightText = <Trans>© {creator}, {yearOrDate}</Trans>;
22+
}
23+
return (
24+
<p className="Copyright pb-3">
25+
{copyrightText}
26+
</p>
27+
);
28+
};
29+
30+
export default Copyright;

src/components/itemPage/Item.jsx

+25-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,22 @@ import Hypertopic from 'hypertopic';
44
import groupBy from 'json-groupby';
55
import { Helmet } from 'react-helmet';
66
import conf from '../../config.js';
7-
import { Items } from '../../model.js';
7+
import { HIDDEN_ON_MOBILE, Items } from '../../model.js';
88
import Viewpoint from './Viewpoint.jsx';
99
import Attribute from './Attribute.jsx';
1010
import Resource from './Resource.jsx';
1111
import Header from '../Header.jsx';
1212
import SameNameBlock from './SameNameBlock.jsx';
1313
import { DiscussionEmbed } from 'disqus-react';
1414
import { t, Trans } from '@lingui/macro';
15+
import Copyright from './Copyright.jsx';
1516

17+
/**
18+
* Gets a string representation of an object. If the object is an array,
19+
* joins the representations of its elements with commas.
20+
* @param {any} obj object to convert
21+
* @returns {string} the string representation
22+
*/
1623
function getString(obj) {
1724
if (Array.isArray(obj)) {
1825
return obj.map(val => getString(val)).join(', ');
@@ -40,6 +47,7 @@ class Item extends Component {
4047
render() {
4148
let name = getString(this.state.item.name);
4249
let attributes = this._getAttributes();
50+
const { creator, created } = this.state.item;
4351
let viewpoints = this._getViewpoints();
4452
let sameNameBlock = this._getSameNameBlock();
4553
const { visitMap } = this.state;
@@ -98,6 +106,9 @@ class Item extends Component {
98106
<div className="Subject">
99107
<h2 className="h4 font-weight-bold text-center">{name}</h2>
100108
<Resource href={this.state.item.resource} />
109+
<div className="d-block d-sm-none">
110+
<Copyright creator={creator} created={created} />
111+
</div>
101112
</div>
102113
<Comments appId={this.state.disqus} item={this.state.item} />
103114
</div>
@@ -109,10 +120,19 @@ class Item extends Component {
109120

110121
_getAttributes() {
111122
return new Items([this.state.item]).getAttributes()
112-
.map(x => (
113-
<Attribute key={x[0]} name={x[0]} value={x[1]}
114-
setAttribute={this._setAttribute} deleteAttribute={this._deleteAttribute}/>
115-
));
123+
.map(attribute => {
124+
const className = HIDDEN_ON_MOBILE.includes(attribute[0]) ? 'd-none d-sm-table-row' : '';
125+
return (
126+
<Attribute
127+
className={className}
128+
key={attribute[0]}
129+
name={attribute[0]}
130+
value={attribute[1]}
131+
setAttribute={this._setAttribute}
132+
deleteAttribute={this._deleteAttribute}
133+
/>
134+
);
135+
});
116136
}
117137

118138
_getViewpoints() {

src/locales/en/messages.po

+12-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ msgstr ""
2525
msgid "Ajouter"
2626
msgstr "Add"
2727

28-
#: src/components/itemPage/Item.jsx:261
28+
#: src/components/itemPage/Item.jsx:279
2929
msgid "Ajouter un attribut et une valeur..."
3030
msgstr "Add an attribute and a value..."
3131

@@ -37,7 +37,7 @@ msgstr "Add a topic..."
3737
msgid "Attention : Le point de vue sera définitivement supprimé."
3838
msgstr "Warning: The viewpoint will be permanently deleted."
3939

40-
#: src/components/itemPage/Item.jsx:85
40+
#: src/components/itemPage/Item.jsx:92
4141
msgid "Attributs du document"
4242
msgstr "Document attributes"
4343

@@ -57,7 +57,7 @@ msgstr "Create a viewpoint"
5757
msgid "Créer"
5858
msgstr ""
5959

60-
#: src/components/itemPage/Item.jsx:82
60+
#: src/components/itemPage/Item.jsx:89
6161
msgid "Description"
6262
msgstr "Description"
6363

@@ -115,16 +115,16 @@ msgstr "Viewpoints"
115115
msgid "Pseudonyme"
116116
msgstr "Pseudonym"
117117

118-
#: src/components/portfolioPage/SearchBar.jsx:47
118+
#: src/components/portfolioPage/SearchBar.jsx:55
119119
msgid "Rechercher..."
120120
msgstr "Search..."
121121

122-
#: src/components/itemPage/Item.jsx:75
122+
#: src/components/itemPage/Item.jsx:82
123123
#: src/components/viewpointPage/Outliner.jsx:37
124124
msgid "Retour à l'accueil"
125125
msgstr "Go back to home page"
126126

127-
#: src/components/itemPage/Item.jsx:75
127+
#: src/components/itemPage/Item.jsx:82
128128
msgid "Retour à la visite"
129129
msgstr ""
130130

@@ -156,11 +156,11 @@ msgstr "Delete"
156156
msgid "Tous les items"
157157
msgstr "All items"
158158

159-
#: src/components/itemPage/Item.jsx:352
159+
#: src/components/itemPage/Item.jsx:370
160160
msgid "Voulez-vous réellement que l'item affiché ne soit plus décrit à l'aide de cette rubrique ?"
161161
msgstr "Remove this topic for this item?"
162162

163-
#: src/components/itemPage/Item.jsx:263
163+
#: src/components/itemPage/Item.jsx:281
164164
msgid "attribut : valeur"
165165
msgstr "attribute: value"
166166

@@ -179,3 +179,7 @@ msgstr "value"
179179
#: src/components/viewpointPage/Outliner.jsx:48
180180
msgid "Êtes-vous sûr de vouloir supprimer le point de vue ?"
181181
msgstr "Are you sure you want to delete the viewpoint?"
182+
183+
#: src/components/itemPage/Copyright.jsx:21
184+
msgid "© {creator}, {yearOrDate}"
185+
msgstr "© {creator}, {yearOrDate}"

src/locales/fr/messages.po

+12-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ msgstr "Adresse email"
2525
msgid "Ajouter"
2626
msgstr "Ajouter"
2727

28-
#: src/components/itemPage/Item.jsx:261
28+
#: src/components/itemPage/Item.jsx:279
2929
msgid "Ajouter un attribut et une valeur..."
3030
msgstr "Ajouter un attribut et une valeur..."
3131

@@ -37,7 +37,7 @@ msgstr "Ajouter une rubrique..."
3737
msgid "Attention : Le point de vue sera définitivement supprimé."
3838
msgstr "Attention : Le point de vue sera définitivement supprimé."
3939

40-
#: src/components/itemPage/Item.jsx:85
40+
#: src/components/itemPage/Item.jsx:92
4141
msgid "Attributs du document"
4242
msgstr "Attributs du document"
4343

@@ -57,7 +57,7 @@ msgstr "Création du point de vue"
5757
msgid "Créer"
5858
msgstr "Créer"
5959

60-
#: src/components/itemPage/Item.jsx:82
60+
#: src/components/itemPage/Item.jsx:89
6161
msgid "Description"
6262
msgstr "Description"
6363

@@ -115,16 +115,16 @@ msgstr "Points de vue"
115115
msgid "Pseudonyme"
116116
msgstr "Pseudonyme"
117117

118-
#: src/components/portfolioPage/SearchBar.jsx:47
118+
#: src/components/portfolioPage/SearchBar.jsx:55
119119
msgid "Rechercher..."
120120
msgstr "Rechercher..."
121121

122-
#: src/components/itemPage/Item.jsx:75
122+
#: src/components/itemPage/Item.jsx:82
123123
#: src/components/viewpointPage/Outliner.jsx:37
124124
msgid "Retour à l'accueil"
125125
msgstr "Retour à l'accueil"
126126

127-
#: src/components/itemPage/Item.jsx:75
127+
#: src/components/itemPage/Item.jsx:82
128128
msgid "Retour à la visite"
129129
msgstr "Retour à la visite"
130130

@@ -156,11 +156,11 @@ msgstr "Supprimer"
156156
msgid "Tous les items"
157157
msgstr "Tous les items"
158158

159-
#: src/components/itemPage/Item.jsx:352
159+
#: src/components/itemPage/Item.jsx:370
160160
msgid "Voulez-vous réellement que l'item affiché ne soit plus décrit à l'aide de cette rubrique ?"
161161
msgstr "Voulez-vous réellement que l'item affiché ne soit plus décrit à l'aide de cette rubrique ?"
162162

163-
#: src/components/itemPage/Item.jsx:263
163+
#: src/components/itemPage/Item.jsx:281
164164
msgid "attribut : valeur"
165165
msgstr "attribut : valeur"
166166

@@ -179,3 +179,7 @@ msgstr "valeur"
179179
#: src/components/viewpointPage/Outliner.jsx:48
180180
msgid "Êtes-vous sûr de vouloir supprimer le point de vue ?"
181181
msgstr "Êtes-vous sûr de vouloir supprimer le point de vue ?"
182+
183+
#: src/components/itemPage/Copyright.jsx:21
184+
msgid "© {creator}, {yearOrDate}"
185+
msgstr "© {creator}, {yearOrDate}"

src/model.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ class Topics {
2323

2424
}
2525

26+
/**
27+
* When on mobile,
28+
* the attributes in this list shouldn't be displayed in the left sidebar,
29+
* because they are already displayed elsewhere in the page.
30+
*/
31+
const HIDDEN_ON_MOBILE = ['creator', 'created'];
32+
2633
class Items {
2734

2835
constructor(items) {
@@ -51,4 +58,4 @@ class Items {
5158
.map(([_, value]) => value);
5259
}
5360

54-
export {Topics, Items};
61+
export {Topics, Items, HIDDEN_ON_MOBILE};

0 commit comments

Comments
 (0)