diff --git a/components/main-controller.riot b/components/main-controller.riot index d071877..7b7eeb8 100644 --- a/components/main-controller.riot +++ b/components/main-controller.riot @@ -4,7 +4,7 @@
- +
@@ -17,7 +17,10 @@ diff --git a/components/school.riot b/components/school.riot index 52ad7a2..af59d6b 100644 --- a/components/school.riot +++ b/components/school.riot @@ -1,6 +1,8 @@
- +
@@ -8,9 +10,6 @@
- - - diff --git a/components/search.riot b/components/search.riot index 81adec0..bd3b557 100644 --- a/components/search.riot +++ b/components/search.riot @@ -7,9 +7,9 @@
  • -
  • @@ -49,12 +49,24 @@ promise.then((response) => { this.state.allItems = response this.filterSearch() + this.update({ + updating: false + }) + }, () => { + if (!this.state.currentStep) { + this.cruiseBack() + } + this.update({ updating: false }) }) }, + clearSearch() { + this.$("input").value = "" + }, + filterSearch() { let input = this.$("input") if (!input) return @@ -76,7 +88,6 @@ }, cruiseForward(selection) { - if (this.state.currentStep >= 2) return switch (this.state.currentStep) { case 0: this.state.filiere = selection @@ -85,11 +96,20 @@ case 1: this.state.specialite = selection break - } + case 2: + console.log(this.props) + console.log(this.root) + console.log("end") + return + + default: + return + } this.state.currentStep++ this.updateList() + this.clearSearch() this.update({ placeholder: PLACEHOLDERS[this.state.currentStep] }) @@ -100,6 +120,7 @@ this.state.currentStep-- this.updateList() + this.clearSearch() this.update({ placeholder: PLACEHOLDERS[this.state.currentStep] }) @@ -111,104 +132,16 @@ placeholder: PLACEHOLDERS[0], currentStep: 0, allItems: null, - filter: null, items: null, filiere: null, specialite: null, - updating: false + updating: false, } }, - onMounted() { + onMounted(props, state) { this.updateList() } } - - - /*const searchURL = `https://data.enseignementsup-recherche.gouv.fr/api/records/1.0/search/?dataset=fr-esr-parcoursup&timezone=Europe%2FBerlin` - - async function fetchFiliere(state) { - if (state.sousfili){ - return PAPI.fetchSpecialites(state.sousfili) - } else if (state.fili && !state.sousfili){ - return PAPI.fetchFiliere(state.fili) - } else if (!state.fili && !state.sousfili){ - return PAPI.fetchFilieres() - } - } - - - export default function search(){ - return { - onBeforeMount(props, state) { - // initial state - this.state = { - placeholder: "Formation", - items: null, - allitems: null, - fili: null, - sousfili: null - } - fetchFiliere(this.state).then((response) => { - this.update({ - items: response, - allitems: response - }) - }) - }, - searchF(e){ - let responseFiltered=[] - this.state.allitems.forEach(formation => { - if (formation.name.toUpperCase().includes(e.target.value.toUpperCase())) { - responseFiltered.push(formation) - } - }); - this.update({ - items: responseFiltered - }) - }, - filter(fili){ - console.log("filter! "+fili) - if (this.state.placeholder==="Filière de formation"){ - this.update({ - placeholder: "Filière de formation détaillée", - sousfili: fili, - }) - } else if (this.state.placeholder="Formation"){ - this.update({ - placeholder: "Filière de formation", - fili: fili - }) - } - fetchFiliere(this.state).then((response) => { - this.update({ - allitems: response, - items: response - }) - console.log(this.state.items) - }) - }, - back(){ - console.log("back") - if (this.state.placeholder==="Filière de formation"){ - this.update({ - placeholder: "Formation", - fili: null, - }) - } else if (this.state.placeholder="Filière de formation détaillée"){ - this.update({ - placeholder: "Filière de formation", - sousfili: null - }) - } - fetchFiliere(this.state).then((response) => { - this.update({ - allitems: response, - items: response - }) - }) - } - } - }*/ \ No newline at end of file diff --git a/index.html b/index.html index 8733e35..de67921 100644 --- a/index.html +++ b/index.html @@ -10,9 +10,8 @@ - - - + + diff --git a/javascript/main-controller.js b/javascript/main-controller.js index 38ac6db..e187b2a 100644 --- a/javascript/main-controller.js +++ b/javascript/main-controller.js @@ -1,38 +1,47 @@ var mainController = { css: null, - exports: {}, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
    ', [{ + exports: { + //Fonction qui va écouter ce que a à dire. + searchListener(arg) { + console.log("Search il a dit: " + arg); + } + }, + template: (template, expressionTypes, bindingTypes, getComponent) => template('
    ', [{ type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'search', slots: [], - attributes: [], - redundantAttribute: 'expr12', - selector: '[expr12]' + attributes: [{ + type: expressionTypes.ATTRIBUTE, + name: 'partouse', + evaluate: _scope => _scope.searchListener + }], + redundantAttribute: 'expr932', + selector: '[expr932]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'fili-info', slots: [], attributes: [], - redundantAttribute: 'expr13', - selector: '[expr13]' + redundantAttribute: 'expr933', + selector: '[expr933]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school', slots: [], attributes: [], - redundantAttribute: 'expr14', - selector: '[expr14]' + redundantAttribute: 'expr934', + selector: '[expr934]' }, { type: bindingTypes.TAG, getComponent: getComponent, evaluate: _scope => 'school-info', slots: [], attributes: [], - redundantAttribute: 'expr15', - selector: '[expr15]' + redundantAttribute: 'expr935', + selector: '[expr935]' }]), name: 'main-controller' }; diff --git a/javascript/school.js b/javascript/school.js index d928a47..0a00265 100644 --- a/javascript/school.js +++ b/javascript/school.js @@ -68,53 +68,53 @@ var school = { } }; }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('

NomVilleDptMoyenneSélectivité
', [{ + template: (template, expressionTypes, bindingTypes, getComponent) => template('

NomVilleDptMoyenneSélectivité
', [{ type: bindingTypes.EACH, getKey: null, condition: null, - template: template(' ', [{ - redundantAttribute: 'expr17', - selector: '[expr17]', + template: template(' ', [{ + redundantAttribute: 'expr407', + selector: '[expr407]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.etablissement.fields.g_ea_lib_vx }] }, { - redundantAttribute: 'expr18', - selector: '[expr18]', + redundantAttribute: 'expr408', + selector: '[expr408]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.etablissement.fields.ville_etab }] }, { - redundantAttribute: 'expr19', - selector: '[expr19]', + redundantAttribute: 'expr409', + selector: '[expr409]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.etablissement.fields.dep }] }, { - redundantAttribute: 'expr20', - selector: '[expr20]', + redundantAttribute: 'expr410', + selector: '[expr410]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.etablissement.fields.moyenne }] }, { - redundantAttribute: 'expr21', - selector: '[expr21]', + redundantAttribute: 'expr411', + selector: '[expr411]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.etablissement.fields.taux_acces_ens }] }]), - redundantAttribute: 'expr16', - selector: '[expr16]', + redundantAttribute: 'expr406', + selector: '[expr406]', itemName: 'etablissement', indexName: null, evaluate: _scope => _scope.state.items diff --git a/javascript/search.js b/javascript/search.js index f37250a..c98b9b9 100644 --- a/javascript/search.js +++ b/javascript/search.js @@ -55,8 +55,18 @@ var search = { this.update({ updating: false }); + }, () => { + if (!this.state.currentStep) { + this.cruiseBack(); + } + this.update({ + updating: false + }); }); }, + clearSearch() { + this.$("input").value = ""; + }, filterSearch() { let input = this.$("input"); if (!input) return; @@ -75,7 +85,6 @@ var search = { }); }, cruiseForward(selection) { - if (this.state.currentStep >= 2) return; switch (this.state.currentStep) { case 0: this.state.filiere = selection; @@ -83,9 +92,17 @@ var search = { case 1: this.state.specialite = selection; break; + case 2: + console.log(this.props); + console.log(this.root); + console.log("end"); + return; + default: + return; } this.state.currentStep++; this.updateList(); + this.clearSearch(); this.update({ placeholder: PLACEHOLDERS[this.state.currentStep] }); @@ -94,6 +111,7 @@ var search = { if (!this.state.currentStep) return; this.state.currentStep--; this.updateList(); + this.clearSearch(); this.update({ placeholder: PLACEHOLDERS[this.state.currentStep] }); @@ -104,20 +122,19 @@ var search = { placeholder: PLACEHOLDERS[0], currentStep: 0, allItems: null, - filter: null, items: null, filiere: null, specialite: null, updating: false }; }, - onMounted() { + onMounted(props, state) { this.updateList(); } }, - template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ - redundantAttribute: 'expr304', - selector: '[expr304]', + template: (template, expressionTypes, bindingTypes, getComponent) => template('
', [{ + redundantAttribute: 'expr966', + selector: '[expr966]', expressions: [{ type: expressionTypes.EVENT, name: 'onkeyup', @@ -128,8 +145,8 @@ var search = { evaluate: _scope => _scope.state.placeholder }] }, { - redundantAttribute: 'expr305', - selector: '[expr305]', + redundantAttribute: 'expr967', + selector: '[expr967]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'disabled', @@ -143,9 +160,9 @@ var search = { type: bindingTypes.EACH, getKey: null, condition: null, - template: template('', [{ - redundantAttribute: 'expr307', - selector: '[expr307]', + template: template('', [{ + redundantAttribute: 'expr969', + selector: '[expr969]', expressions: [{ type: expressionTypes.ATTRIBUTE, name: 'disabled', @@ -156,24 +173,24 @@ var search = { evaluate: _scope => () => _scope.cruiseForward(_scope.item.name) }] }, { - redundantAttribute: 'expr308', - selector: '[expr308]', + redundantAttribute: 'expr970', + selector: '[expr970]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.name }] }, { - redundantAttribute: 'expr309', - selector: '[expr309]', + redundantAttribute: 'expr971', + selector: '[expr971]', expressions: [{ type: expressionTypes.TEXT, childNodeIndex: 0, evaluate: _scope => _scope.item.count }] }]), - redundantAttribute: 'expr306', - selector: '[expr306]', + redundantAttribute: 'expr968', + selector: '[expr968]', itemName: 'item', indexName: null, evaluate: _scope => _scope.state.items diff --git a/loader.js b/loader.js index c9ccae5..7e5f4d7 100644 --- a/loader.js +++ b/loader.js @@ -16,9 +16,10 @@ riot.register("fili-info", FiliInfo) riot.register("search", Search) riot.register("school", School) -riot.mount("main-controller") -riot.mount("school-info") + riot.mount("line-graph") -riot.mount("fili-info") riot.mount("search") -riot.mount("school") \ No newline at end of file +riot.mount("school-info") +riot.mount("fili-info") +riot.mount("school") +riot.mount("main-controller") \ No newline at end of file