Fix props cassé

This commit is contained in:
HORVILLE 2023-03-29 22:56:14 +02:00
parent 59e30c88ba
commit 785aaba8b8
8 changed files with 111 additions and 150 deletions

View File

@ -4,7 +4,7 @@
<div class="box p-3 m-2"> <div class="box p-3 m-2">
<img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/> <img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/>
</div> </div>
<search></search> <search partouse={searchListener}></search>
</div> </div>
<div class="column"> <div class="column">
@ -17,7 +17,10 @@
<script> <script>
export default { export default {
//Fonction qui va écouter ce que <search> a à dire.
searchListener(arg) {
console.log("Search il a dit: " + arg)
}
} }
</script> </script>

View File

@ -1,6 +1,8 @@
<school> <school>
<div class="box p-2 m-2"> <div class="box p-2 m-2">
<iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" style="border-radius: 5px;"></iframe> <iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"
src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik"
style="border-radius: 5px;"></iframe>
<br> <br>
<div class="block control has-icons-left is-inline-block is-pulled-right"> <div class="block control has-icons-left is-inline-block is-pulled-right">
<input class="input" type="search" placeholder="Établissement"> <input class="input" type="search" placeholder="Établissement">
@ -8,9 +10,6 @@
<i class="fas fa-search"></i> <i class="fas fa-search"></i>
</span> </span>
</div> </div>
<table class="table is-fullwidth is-hoverable"> <table class="table is-fullwidth is-hoverable">
<thead> <thead>
<tr> <tr>

View File

@ -7,9 +7,9 @@
<div id="list-formations"> <div id="list-formations">
<ul> <ul>
<li class="m-1" each={item in this.state.items}> <li class="m-1" each={item in this.state.items}>
<button class="button is-fullwidth" disabled={state.updating} onclick={()=>cruiseForward(item.name)}> <button class="button is-fullwidth p-2" disabled={state.updating} onclick={()=>cruiseForward(item.name)}>
<span style="font-size: .75em;"><strong>{item.name}</strong></span> <span style="font-size: .75em; max-size: 90%"><strong>{item.name}</strong></span>
<div style="margin-left: auto;"></div> <div style="margin-left: auto;"></div>
<span class="tag is-primary">{item.count}</span> <span class="tag is-primary">{item.count}</span>
</button> </button>
</li> </li>
@ -49,12 +49,24 @@
promise.then((response) => { promise.then((response) => {
this.state.allItems = response this.state.allItems = response
this.filterSearch() this.filterSearch()
this.update({
updating: false
})
}, () => {
if (!this.state.currentStep) {
this.cruiseBack()
}
this.update({ this.update({
updating: false updating: false
}) })
}) })
}, },
clearSearch() {
this.$("input").value = ""
},
filterSearch() { filterSearch() {
let input = this.$("input") let input = this.$("input")
if (!input) return if (!input) return
@ -76,7 +88,6 @@
}, },
cruiseForward(selection) { cruiseForward(selection) {
if (this.state.currentStep >= 2) return
switch (this.state.currentStep) { switch (this.state.currentStep) {
case 0: case 0:
this.state.filiere = selection this.state.filiere = selection
@ -85,11 +96,20 @@
case 1: case 1:
this.state.specialite = selection this.state.specialite = selection
break break
}
case 2:
console.log(this.props)
console.log(this.root)
console.log("end")
return
default:
return
}
this.state.currentStep++ this.state.currentStep++
this.updateList() this.updateList()
this.clearSearch()
this.update({ this.update({
placeholder: PLACEHOLDERS[this.state.currentStep] placeholder: PLACEHOLDERS[this.state.currentStep]
}) })
@ -100,6 +120,7 @@
this.state.currentStep-- this.state.currentStep--
this.updateList() this.updateList()
this.clearSearch()
this.update({ this.update({
placeholder: PLACEHOLDERS[this.state.currentStep] placeholder: PLACEHOLDERS[this.state.currentStep]
}) })
@ -111,104 +132,16 @@
placeholder: PLACEHOLDERS[0], placeholder: PLACEHOLDERS[0],
currentStep: 0, currentStep: 0,
allItems: null, allItems: null,
filter: null,
items: null, items: null,
filiere: null, filiere: null,
specialite: null, specialite: null,
updating: false updating: false,
} }
}, },
onMounted() { onMounted(props, state) {
this.updateList() 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
})
})
}
}
}*/
</script> </script>
</search> </search>

View File

@ -10,9 +10,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/riot/7.1.0/riot+compiler.min.js" integrity="sha512-sSGKGR9MvL0bUx3CScaBb56crXwspwDkL/JnB0IrLFQfw3uvSUlITQtsTtDZctshhv5wdwIt+qZeN8zThRF4Dw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/riot/7.1.0/riot+compiler.min.js" integrity="sha512-sSGKGR9MvL0bUx3CScaBb56crXwspwDkL/JnB0IrLFQfw3uvSUlITQtsTtDZctshhv5wdwIt+qZeN8zThRF4Dw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
</head> </head>
<body> <body class="pr-4">
<main-controller> <main-controller>
</main-controller> </main-controller>
</body> </body>
</html> </html>

View File

@ -1,38 +1,47 @@
var mainController = { var mainController = {
css: null, css: null,
exports: {}, exports: {
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr12="expr12"></search></div><div class="column"><fili-info expr13="expr13"></fili-info><school expr14="expr14"></school></div></div><school-info expr15="expr15"></school-info>', [{ //Fonction qui va écouter ce que <search> a à dire.
searchListener(arg) {
console.log("Search il a dit: " + arg);
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2"><img class="mt-1 ml-5 mr-auto" style="margin: auto;" src="../resources/logo-parcoursup.svg"/></div><search expr932="expr932"></search></div><div class="column"><fili-info expr933="expr933"></fili-info><school expr934="expr934"></school></div></div><school-info expr935="expr935"></school-info>', [{
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'search', evaluate: _scope => 'search',
slots: [], slots: [],
attributes: [], attributes: [{
redundantAttribute: 'expr12', type: expressionTypes.ATTRIBUTE,
selector: '[expr12]' name: 'partouse',
evaluate: _scope => _scope.searchListener
}],
redundantAttribute: 'expr932',
selector: '[expr932]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'fili-info', evaluate: _scope => 'fili-info',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr13', redundantAttribute: 'expr933',
selector: '[expr13]' selector: '[expr933]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'school', evaluate: _scope => 'school',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr14', redundantAttribute: 'expr934',
selector: '[expr14]' selector: '[expr934]'
}, { }, {
type: bindingTypes.TAG, type: bindingTypes.TAG,
getComponent: getComponent, getComponent: getComponent,
evaluate: _scope => 'school-info', evaluate: _scope => 'school-info',
slots: [], slots: [],
attributes: [], attributes: [],
redundantAttribute: 'expr15', redundantAttribute: 'expr935',
selector: '[expr15]' selector: '[expr935]'
}]), }]),
name: 'main-controller' name: 'main-controller'
}; };

View File

@ -68,53 +68,53 @@ var school = {
} }
}; };
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-2 m-2"><iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" style="border-radius: 5px;"></iframe><br/><div class="block control has-icons-left is-inline-block is-pulled-right"><input class="input" type="search" placeholder="Établissement"/><span class="icon is-small is-left"><i class="fas fa-search"></i></span></div><table class="table is-fullwidth is-hoverable"><thead><tr><th><abbr title="name">Nom</abbr></th><th><abbr title="city">Ville</abbr></th><th><abbr title="dept">Dpt</abbr></th><th><abbr title="moyenne">Moyenne</abbr></th><th><abbr title="selectivite">Sélectivité</abbr></th></tr></thead><tbody><tr expr16="expr16"></tr></tbody></table></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-2 m-2"><iframe width="100%" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://www.openstreetmap.org/export/embed.html?bbox=-14.655761718750002%2C40.56389453066509%2C13.601074218750002%2C51.754240074033525&amp;layer=mapnik" style="border-radius: 5px;"></iframe><br/><div class="block control has-icons-left is-inline-block is-pulled-right"><input class="input" type="search" placeholder="Établissement"/><span class="icon is-small is-left"><i class="fas fa-search"></i></span></div><table class="table is-fullwidth is-hoverable"><thead><tr><th><abbr title="name">Nom</abbr></th><th><abbr title="city">Ville</abbr></th><th><abbr title="dept">Dpt</abbr></th><th><abbr title="moyenne">Moyenne</abbr></th><th><abbr title="selectivite">Sélectivité</abbr></th></tr></thead><tbody><tr expr406="expr406"></tr></tbody></table></div>', [{
type: bindingTypes.EACH, type: bindingTypes.EACH,
getKey: null, getKey: null,
condition: null, condition: null,
template: template('<td expr17="expr17"> </td><td expr18="expr18"> </td><td expr19="expr19"> </td><td expr20="expr20"> </td><td expr21="expr21"> </td>', [{ template: template('<td expr407="expr407"> </td><td expr408="expr408"> </td><td expr409="expr409"> </td><td expr410="expr410"> </td><td expr411="expr411"> </td>', [{
redundantAttribute: 'expr17', redundantAttribute: 'expr407',
selector: '[expr17]', selector: '[expr407]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.g_ea_lib_vx evaluate: _scope => _scope.etablissement.fields.g_ea_lib_vx
}] }]
}, { }, {
redundantAttribute: 'expr18', redundantAttribute: 'expr408',
selector: '[expr18]', selector: '[expr408]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.ville_etab evaluate: _scope => _scope.etablissement.fields.ville_etab
}] }]
}, { }, {
redundantAttribute: 'expr19', redundantAttribute: 'expr409',
selector: '[expr19]', selector: '[expr409]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.dep evaluate: _scope => _scope.etablissement.fields.dep
}] }]
}, { }, {
redundantAttribute: 'expr20', redundantAttribute: 'expr410',
selector: '[expr20]', selector: '[expr410]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.moyenne evaluate: _scope => _scope.etablissement.fields.moyenne
}] }]
}, { }, {
redundantAttribute: 'expr21', redundantAttribute: 'expr411',
selector: '[expr21]', selector: '[expr411]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.etablissement.fields.taux_acces_ens evaluate: _scope => _scope.etablissement.fields.taux_acces_ens
}] }]
}]), }]),
redundantAttribute: 'expr16', redundantAttribute: 'expr406',
selector: '[expr16]', selector: '[expr406]',
itemName: 'etablissement', itemName: 'etablissement',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.items evaluate: _scope => _scope.state.items

View File

@ -55,8 +55,18 @@ var search = {
this.update({ this.update({
updating: false updating: false
}); });
}, () => {
if (!this.state.currentStep) {
this.cruiseBack();
}
this.update({
updating: false
});
}); });
}, },
clearSearch() {
this.$("input").value = "";
},
filterSearch() { filterSearch() {
let input = this.$("input"); let input = this.$("input");
if (!input) return; if (!input) return;
@ -75,7 +85,6 @@ var search = {
}); });
}, },
cruiseForward(selection) { cruiseForward(selection) {
if (this.state.currentStep >= 2) return;
switch (this.state.currentStep) { switch (this.state.currentStep) {
case 0: case 0:
this.state.filiere = selection; this.state.filiere = selection;
@ -83,9 +92,17 @@ var search = {
case 1: case 1:
this.state.specialite = selection; this.state.specialite = selection;
break; break;
case 2:
console.log(this.props);
console.log(this.root);
console.log("end");
return;
default:
return;
} }
this.state.currentStep++; this.state.currentStep++;
this.updateList(); this.updateList();
this.clearSearch();
this.update({ this.update({
placeholder: PLACEHOLDERS[this.state.currentStep] placeholder: PLACEHOLDERS[this.state.currentStep]
}); });
@ -94,6 +111,7 @@ var search = {
if (!this.state.currentStep) return; if (!this.state.currentStep) return;
this.state.currentStep--; this.state.currentStep--;
this.updateList(); this.updateList();
this.clearSearch();
this.update({ this.update({
placeholder: PLACEHOLDERS[this.state.currentStep] placeholder: PLACEHOLDERS[this.state.currentStep]
}); });
@ -104,20 +122,19 @@ var search = {
placeholder: PLACEHOLDERS[0], placeholder: PLACEHOLDERS[0],
currentStep: 0, currentStep: 0,
allItems: null, allItems: null,
filter: null,
items: null, items: null,
filiere: null, filiere: null,
specialite: null, specialite: null,
updating: false updating: false
}; };
}, },
onMounted() { onMounted(props, state) {
this.updateList(); this.updateList();
} }
}, },
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr304="expr304" class="input" type="input"/><button expr305="expr305" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr306="expr306" class="m-1"></li></ul></div></div>', [{ template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr966="expr966" class="input" type="input"/><button expr967="expr967" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr968="expr968" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr304', redundantAttribute: 'expr966',
selector: '[expr304]', selector: '[expr966]',
expressions: [{ expressions: [{
type: expressionTypes.EVENT, type: expressionTypes.EVENT,
name: 'onkeyup', name: 'onkeyup',
@ -128,8 +145,8 @@ var search = {
evaluate: _scope => _scope.state.placeholder evaluate: _scope => _scope.state.placeholder
}] }]
}, { }, {
redundantAttribute: 'expr305', redundantAttribute: 'expr967',
selector: '[expr305]', selector: '[expr967]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'disabled', name: 'disabled',
@ -143,9 +160,9 @@ var search = {
type: bindingTypes.EACH, type: bindingTypes.EACH,
getKey: null, getKey: null,
condition: null, condition: null,
template: template('<button expr307="expr307" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr308="expr308"> </strong></span><div style="margin-left: auto;"></div><span expr309="expr309" class="tag is-primary"> </span></button>', [{ template: template('<button expr969="expr969" class="button is-fullwidth p-2"><span style="font-size: .75em; max-size: 90%"><strong expr970="expr970"> </strong></span><div style="margin-left: auto;"></div><span expr971="expr971" class="tag is-primary"> </span></button>', [{
redundantAttribute: 'expr307', redundantAttribute: 'expr969',
selector: '[expr307]', selector: '[expr969]',
expressions: [{ expressions: [{
type: expressionTypes.ATTRIBUTE, type: expressionTypes.ATTRIBUTE,
name: 'disabled', name: 'disabled',
@ -156,24 +173,24 @@ var search = {
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name) evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
}] }]
}, { }, {
redundantAttribute: 'expr308', redundantAttribute: 'expr970',
selector: '[expr308]', selector: '[expr970]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.item.name evaluate: _scope => _scope.item.name
}] }]
}, { }, {
redundantAttribute: 'expr309', redundantAttribute: 'expr971',
selector: '[expr309]', selector: '[expr971]',
expressions: [{ expressions: [{
type: expressionTypes.TEXT, type: expressionTypes.TEXT,
childNodeIndex: 0, childNodeIndex: 0,
evaluate: _scope => _scope.item.count evaluate: _scope => _scope.item.count
}] }]
}]), }]),
redundantAttribute: 'expr306', redundantAttribute: 'expr968',
selector: '[expr306]', selector: '[expr968]',
itemName: 'item', itemName: 'item',
indexName: null, indexName: null,
evaluate: _scope => _scope.state.items evaluate: _scope => _scope.state.items

View File

@ -16,9 +16,10 @@ riot.register("fili-info", FiliInfo)
riot.register("search", Search) riot.register("search", Search)
riot.register("school", School) riot.register("school", School)
riot.mount("main-controller")
riot.mount("school-info")
riot.mount("line-graph") riot.mount("line-graph")
riot.mount("fili-info")
riot.mount("search") riot.mount("search")
riot.mount("school") riot.mount("school-info")
riot.mount("fili-info")
riot.mount("school")
riot.mount("main-controller")