diff --git a/app/views/search/controller.js b/app/views/search/controller.js index 5e830b2..e899f1d 100644 --- a/app/views/search/controller.js +++ b/app/views/search/controller.js @@ -10,11 +10,7 @@ export class SearchController extends ViewController { searchSource: 'inventaire', searchBy: 'title', done: true, - results: { - humans: [], - series: [], - works: [], - }, + results: [], openModal: null, }); diff --git a/app/views/search/index.js b/app/views/search/index.js index 44b6928..3f05ec8 100644 --- a/app/views/search/index.js +++ b/app/views/search/index.js @@ -131,6 +131,7 @@ export const searchView = (state, emit, i18n) => { `, + // Search Results section html`

${controller.hasQuery && !controller.doneSearching @@ -139,14 +140,14 @@ export const searchView = (state, emit, i18n) => { }

- ${controller.hasQuery && controller.doneSearching && controller.results.works < 1 + ${controller.hasQuery && controller.doneSearching && controller.results < 1 ? [ html`

${__('search.no_results')}

`, html` ${__('search.no_results_suggestion')} ` ] - : controller.results.works.map(result => { + : controller.results.map(result => { return html`

${result.name}

diff --git a/server/controllers/search.js b/server/controllers/search.js index 9b84885..ff30ae0 100644 --- a/server/controllers/search.js +++ b/server/controllers/search.js @@ -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, - } }); } }