Skip to content

Commit d8ea9ae

Browse files
committed
fix(list): fix claims references changed some time ago
1 parent 2676610 commit d8ea9ae

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

src/components/main/list/list.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
ng-if="$ctrl.place"
2121
ng-show="$ctrl.mobile.fullHeader">
2222
<div class="header__primary" layout="row" layout-align="center start">
23-
<div flex>
23+
<div layout="row" layout-align="start end" flex>
2424
<h2 class="header__title md-display-1"
2525
ng-if="!$ctrl.place.labels[$ctrl.lang.code]">
2626
<em>missing label in {{ ::$ctrl.lang.name }}</em>
2727
</h2>
2828
<h2 class="header__title md-display-1"
2929
ng-if="$ctrl.place.labels[$ctrl.lang.code]">
30-
{{ ::$ctrl.place.labels[$ctrl.lang.code] }}
30+
{{ ::$ctrl.place.labels[$ctrl.lang.code].value }}
3131
</h2>
3232
<h4 class="header__subtitle md-headline muted"><mo-native-name monument="$ctrl.place"></mo-native-name></h4>
3333
</div>

src/components/main/list/list.js

+14-12
Original file line numberDiff line numberDiff line change
@@ -128,19 +128,20 @@ function controller($location, $q, $scope, $state, $stateParams, $timeout, $wind
128128

129129
function getPlace() {
130130
return wikidata.getById(id).then((data) => {
131-
const first = Object.keys(data)[0];
132-
vm.place = data[first];
131+
vm.place = data;
133132

134-
const claims = vm.place.claims;
135-
if (vm.place.claims.P41) {
136-
claims.P41.values.forEach(image => getImage(image.value));
137-
} else if (vm.place.claims.P94) {
138-
claims.P94.values.forEach(image => getImage(image.value));
133+
if (vm.place.claims.P31 && vm.place.claims.P31.some(claim => claim.mainsnak.datavalue.value.id === 'Q5107')) {
134+
vm.isContinent = true;
135+
return false;
136+
} else if (id === 'Q2') {
137+
vm.isContinent = true;
138+
return false;
139139
}
140-
if (vm.place.claims.P17) {
141-
const country = claims.P17.values[0];
142-
const countryLanguages = langService.getNativeLanguages(country.value_id);
143140

141+
const claims = vm.place.claims;
142+
if (vm.place.claims.P17) {
143+
const country = claims.P17[0];
144+
const countryLanguages = langService.getNativeLanguages(country.mainsnak.datavalue.value.id);
144145
if (!countryLanguages) { return false; }
145146
langs = langs.concat(countryLanguages.map(lang => ({ code: lang })));
146147
}
@@ -149,6 +150,7 @@ function controller($location, $q, $scope, $state, $stateParams, $timeout, $wind
149150
}
150151

151152
function filterMap() {
153+
if (!vm.map) { return; }
152154
$state.transitionTo('main.list', vm.filter, { notify: false });
153155
vm.loading = 'map';
154156
getList()
@@ -169,7 +171,7 @@ function controller($location, $q, $scope, $state, $stateParams, $timeout, $wind
169171
.then(() => {
170172
let center = { lat: 49.4967, lng: 12.4805, zoom: 4 };
171173
if (vm.place.claims.P625) {
172-
const coords = vm.place.claims.P625.values[0].value;
174+
const coords = vm.place.claims.P625[0].mainsnak.datavalue.value;
173175
center = { lat: coords.latitude, lng: coords.longitude, zoom: 7 };
174176
}
175177
return $timeout(() => {
@@ -287,7 +289,7 @@ function controller($location, $q, $scope, $state, $stateParams, $timeout, $wind
287289
}
288290

289291
function setTitle() {
290-
const title = vm.place.labels[vm.lang.code] || vm.place.labels.en || vm.place.id;
292+
const title = vm.place.labels[vm.lang.code].value || vm.place.labels.en.value || vm.place.id;
291293
$window.document.title = `${title} – Monumental`;
292294
}
293295

0 commit comments

Comments
 (0)