Simplify search results to only use Works from inventaire

This commit is contained in:
Robbie Antenesse 2019-09-26 10:51:52 -06:00
parent 691f0c350b
commit abc1e10b3f
3 changed files with 6 additions and 87 deletions

View File

@ -10,11 +10,7 @@ export class SearchController extends ViewController {
searchSource: 'inventaire',
searchBy: 'title',
done: true,
results: {
humans: [],
series: [],
works: [],
},
results: [],
openModal: null,
});

View File

@ -131,6 +131,7 @@ export const searchView = (state, emit, i18n) => {
</footer>
</section>`,
// Search Results section
html`<section>
<h2>
${controller.hasQuery && !controller.doneSearching
@ -139,14 +140,14 @@ export const searchView = (state, emit, i18n) => {
}
</h2>
${controller.hasQuery && controller.doneSearching && controller.results.works < 1
${controller.hasQuery && controller.doneSearching && controller.results < 1
? [
html`<h3>${__('search.no_results')}</h3>`,
html`<a class="button" href="https://wiki.inventaire.io/wiki/How-to-contribute" target="_blank">
${__('search.no_results_suggestion')}
</a>`
]
: controller.results.works.map(result => {
: controller.results.map(result => {
return html`<article class="flex search-result">
<header class="two-third-800 half-500">
<h3 class="title">${result.name}</h3>

View File

@ -32,7 +32,7 @@ class SearchController {
}
});
return json.then(responseJSON => {
const works = responseJSON.results.map(work => {
return responseJSON.results.map(work => {
const booksController = new BooksController(this.inventaire, work.uri, this.lang);
const bookData = booksController.handleQuickInventaireEntity(work);
const communityData = booksController.getCommunityData(5);
@ -42,12 +42,6 @@ class SearchController {
...communityData,
}
});
return {
humans: [],
series: [],
works,
}
});
}
}
@ -71,73 +65,7 @@ class SearchController {
}
});
return json.then(responseJSON => {
const humans = responseJSON.humans.map(human => {
const hasLabels = typeof human.labels !== 'undefined';
const hasDescriptions = typeof human.descriptions !== 'undefined';
const hasImage = typeof human.image !== 'undefined';
return {
name: (
hasLabels && typeof human.labels[this.lang] !== 'undefined'
? human.labels[this.lang]
: (
hasLabels && Object.keys(human.labels).length > 0
? human.labels[Object.keys(human.labels)[0]]
: null
)
),
description: (
hasDescriptions && typeof human.descriptions[this.lang] !== 'undefined'
? human.descriptions[this.lang]
: (
hasDescriptions && Object.keys(human.descriptions).length > 0
? human.descriptions[Object.keys(human.descriptions)[0]]
: null
)
),
link: (
typeof human.uri !== 'undefined'
? `${this.inventaire}/entity/${human.uri}`
: null
),
image: (
hasImage && typeof human.image.url !== 'undefined'
? human.image
: null
),
};
});
const series = responseJSON.series.map(serie => {
const hasLabels = typeof serie.labels !== 'undefined';
const hasDescriptions = typeof serie.descriptions !== 'undefined';
return {
name: (
hasLabels && typeof serie.labels[this.lang] !== 'undefined'
? serie.labels[this.lang]
: (
hasLabels && Object.keys(serie.labels).length > 0
? serie.labels[Object.keys(serie.labels)[0]]
: null
)
),
description: (
hasDescriptions && typeof serie.descriptions[this.lang] !== 'undefined'
? serie.descriptions[this.lang]
: (
hasDescriptions && Object.keys(serie.descriptions).length > 0
? serie.descriptions[Object.keys(serie.descriptions)[0]]
: null
)
),
link: (
typeof serie.uri !== 'undefined'
? `${this.inventaire}/entity/${serie.uri}`
: null
),
};
});
const works = responseJSON.works.map(work => {
return responseJSON.works.map(work => {
const booksController = new BooksController(this.inventaire, work.uri, this.lang);
const bookData = booksController.handleInventaireEntity(work);
const communityData = booksController.getCommunityData(5);
@ -147,12 +75,6 @@ class SearchController {
...communityData,
}
});
return {
humans,
series,
works,
}
});
}
}