diff --git a/controllerSearch.js b/controllerSearch.js new file mode 100644 index 0000000..3788a29 --- /dev/null +++ b/controllerSearch.js @@ -0,0 +1,31 @@ +class Controller { + constructor(view,model){ + this.view = view + this.model = model + + this.loading = false + this.lastSearch = null + this.error = null + this.results = [] + + this.view.setLoading(false) + this.view.bindSearch(this.search.bind(this)) + } + reset() { + this.loading = false + this.error = null + this.results = [] + } + + async search(formation) { + this.model.getFormations(formation).then((response) => { + let table = response["facet groups"][0]["facets"] + this.view.renderList(table) + }).catch((error) => { + this.view.renderMessage(error) + }) + } +} + +export default Controller + diff --git a/index.html b/index.html index b8f2e19..ba33eed 100644 --- a/index.html +++ b/index.html @@ -5,10 +5,18 @@