import html from 'choo/html'; import { SearchController } from './controller'; // The controller for this view, where processing should happen. import { resultDetails } from './resultDetails'; import { modal } from '../partials/modal'; // This is the view function that is exported and used in the view manager. export const searchView = (state, emit, i18n) => { const controller = new SearchController(state, emit, i18n); const { __ } = controller.i18n; if (controller.hasQuery && controller.queryIsNew) { controller.search(); } else if (controller.state.lastSearch !== '') { controller.appState.query.for = controller.state.lastSearch; } // Returning an array in a view allows non-shared parent HTML elements. return [ html`

${__('search.header')}

`, html`
`, // Search Options Section html`
${/*
${modal('searchSourceInfo', controller, [ html`

${__('search.search_source.help.text')}

`, html``, ], { buttonText: __('search.search_source.help.button'), buttonClasses: 'small marginless pseudo button pull-right', headerText: __('search.search_source.help.header'), })}
*/'' // Temporarily comment out the source chooser so I can focus on just Inventaire }
${__('search.search_by.label')}
`, // Search Results section html`

${controller.hasQuery && !controller.doneSearching ? html`${__('search.loading')} ` : null }

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

${__('search.no_results')}

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

${result.name}

${result.description ? html`

${result.description}

` : null}
`; }) }
`, ]; }