search.riot refactor (presque terminé)
This commit is contained in:
parent
ea62bb9d3f
commit
59e30c88ba
@ -34,7 +34,6 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import PAPI from '../javascript/parcoursup-link.js'
|
import PAPI from '../javascript/parcoursup-link.js'
|
||||||
|
|
||||||
async function fetchEtablissement(state) {
|
async function fetchEtablissement(state) {
|
||||||
@ -65,7 +64,7 @@
|
|||||||
|
|
||||||
// On prend la moyenne des moyennes comprises dans la mention
|
// On prend la moyenne des moyennes comprises dans la mention
|
||||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||||
let moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11g))/100
|
let moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100
|
||||||
|
|
||||||
etablissement.fields.moyenne=moyenne
|
etablissement.fields.moyenne=moyenne
|
||||||
//console.log(etablissement.fields)
|
//console.log(etablissement.fields)
|
||||||
@ -76,6 +75,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
</school>
|
</school>
|
@ -1,13 +1,13 @@
|
|||||||
<search>
|
<search>
|
||||||
<div class="box p-1 m-2">
|
<div class="box p-1 m-2">
|
||||||
<div class="columns m-1">
|
<div class="columns m-1">
|
||||||
<input onkeydown={filterSearch} onfocusout={filterSearch} class="input" type="input" placeholder={state.placeholder}>
|
<input onkeyup={filterSearch} class="input" type="input" placeholder={state.placeholder}>
|
||||||
<button class="button ml-1" disabled={!state.currentStep} onclick={cruiseBack}><</button>
|
<button class="button ml-1" disabled={!state.currentStep || state.updating} onclick={cruiseBack}><</button>
|
||||||
</div>
|
</div>
|
||||||
<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" onclick={()=>cruiseForward(item.name)}>
|
<button class="button is-fullwidth" disabled={state.updating} onclick={()=>cruiseForward(item.name)}>
|
||||||
<span style="font-size: .75em;"><strong>{item.name}</strong></span>
|
<span style="font-size: .75em;"><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>
|
||||||
@ -19,36 +19,108 @@
|
|||||||
<script>
|
<script>
|
||||||
import PAPI from '../javascript/parcoursup-link.js'
|
import PAPI from '../javascript/parcoursup-link.js'
|
||||||
|
|
||||||
function cruiseBack() {
|
const PLACEHOLDERS = [
|
||||||
|
"Formation",
|
||||||
}
|
"Filière",
|
||||||
|
"Spécialité"
|
||||||
function cruiseForward() {
|
]
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function filterSearch() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
||||||
|
updateList() {
|
||||||
|
let promise
|
||||||
|
|
||||||
|
this.update({
|
||||||
|
updating: true
|
||||||
|
})
|
||||||
|
|
||||||
|
switch (this.state.currentStep) {
|
||||||
|
case 0:
|
||||||
|
promise = PAPI.fetchFilieres()
|
||||||
|
break
|
||||||
|
case 1:
|
||||||
|
promise = PAPI.fetchFiliere(this.state.filiere)
|
||||||
|
break
|
||||||
|
case 2:
|
||||||
|
promise = PAPI.fetchSpecialites(this.state.specialite)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
promise.then((response) => {
|
||||||
|
this.state.allItems = response
|
||||||
|
this.filterSearch()
|
||||||
|
this.update({
|
||||||
|
updating: false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
filterSearch() {
|
||||||
|
let input = this.$("input")
|
||||||
|
if (!input) return
|
||||||
|
|
||||||
|
let finalArray = []
|
||||||
|
|
||||||
|
//On évite de trier avant d'avoir plus de 1 lettres.
|
||||||
|
if (input.value.length > 1) {
|
||||||
|
finalArray = this.state.allItems.filter((item) => {
|
||||||
|
return item.name.toLowerCase().includes(input.value.toLowerCase())
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
finalArray = this.state.allItems
|
||||||
|
}
|
||||||
|
|
||||||
|
this.update({
|
||||||
|
items: finalArray
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
cruiseForward(selection) {
|
||||||
|
if (this.state.currentStep >= 2) return
|
||||||
|
switch (this.state.currentStep) {
|
||||||
|
case 0:
|
||||||
|
this.state.filiere = selection
|
||||||
|
break
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
this.state.specialite = selection
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
this.state.currentStep++
|
||||||
|
|
||||||
|
this.updateList()
|
||||||
|
this.update({
|
||||||
|
placeholder: PLACEHOLDERS[this.state.currentStep]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
cruiseBack() {
|
||||||
|
if (!this.state.currentStep) return
|
||||||
|
this.state.currentStep--
|
||||||
|
|
||||||
|
this.updateList()
|
||||||
|
this.update({
|
||||||
|
placeholder: PLACEHOLDERS[this.state.currentStep]
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
onBeforeMount(props, state) {
|
onBeforeMount(props, state) {
|
||||||
//Initial state
|
//Initial state
|
||||||
this.state = {
|
this.state = {
|
||||||
placeholder: "Formation",
|
placeholder: PLACEHOLDERS[0],
|
||||||
currentStep: 0,
|
currentStep: 0,
|
||||||
allItems: null,
|
allItems: null,
|
||||||
filter: null,
|
filter: null,
|
||||||
items: null
|
items: null,
|
||||||
|
filiere: null,
|
||||||
|
specialite: null,
|
||||||
|
updating: false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
PAPI.fetchFilieres().then((response) => {
|
onMounted() {
|
||||||
this.state.allItems = response
|
this.updateList()
|
||||||
|
|
||||||
this.update({
|
|
||||||
items: filterSearch(this.state.allItems)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,30 +1,30 @@
|
|||||||
var filiInfo = {
|
var filiInfo = {
|
||||||
css: null,
|
css: null,
|
||||||
exports: null,
|
exports: null,
|
||||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr4="expr4" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr5="expr5" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr6="expr6" style="height: 6rem;"></line-graph></div></div>', [{
|
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><h1 class="title is-4 m-2"><a>BUT</a> / <a>BUT - Production</a> / <a>Informatique</a></h1><div class="box mt-2" style="background-color: #EAEAEA; margin: auto; width: 60%;"><p>Moyenne des admis<span class="is-pulled-right">19.3</span></p><p>Nombre de formations<span class="is-pulled-right">5</span></p><p>Capacité<span class="is-pulled-right">90</span></p><p>Sélectivité</p></div><div class="m-4"><line-graph expr0="expr0" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr1="expr1" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr2="expr2" style="height: 6rem;"></line-graph></div></div>', [{
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'line-graph',
|
evaluate: _scope => 'line-graph',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr4',
|
redundantAttribute: 'expr0',
|
||||||
selector: '[expr4]'
|
selector: '[expr0]'
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'line-graph',
|
evaluate: _scope => 'line-graph',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr5',
|
redundantAttribute: 'expr1',
|
||||||
selector: '[expr5]'
|
selector: '[expr1]'
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'line-graph',
|
evaluate: _scope => 'line-graph',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr6',
|
redundantAttribute: 'expr2',
|
||||||
selector: '[expr6]'
|
selector: '[expr2]'
|
||||||
}]),
|
}]),
|
||||||
name: 'fili-info'
|
name: 'fili-info'
|
||||||
};
|
};
|
||||||
|
@ -1,38 +1,38 @@
|
|||||||
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 expr0="expr0"></search></div><div class="column"><fili-info expr1="expr1"></fili-info><school expr2="expr2"></school></div></div><school-info expr3="expr3"></school-info>', [{
|
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>', [{
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'search',
|
evaluate: _scope => 'search',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr0',
|
redundantAttribute: 'expr12',
|
||||||
selector: '[expr0]'
|
selector: '[expr12]'
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'fili-info',
|
evaluate: _scope => 'fili-info',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr1',
|
redundantAttribute: 'expr13',
|
||||||
selector: '[expr1]'
|
selector: '[expr13]'
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'school',
|
evaluate: _scope => 'school',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr2',
|
redundantAttribute: 'expr14',
|
||||||
selector: '[expr2]'
|
selector: '[expr14]'
|
||||||
}, {
|
}, {
|
||||||
type: bindingTypes.TAG,
|
type: bindingTypes.TAG,
|
||||||
getComponent: getComponent,
|
getComponent: getComponent,
|
||||||
evaluate: _scope => 'school-info',
|
evaluate: _scope => 'school-info',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr3',
|
redundantAttribute: 'expr15',
|
||||||
selector: '[expr3]'
|
selector: '[expr15]'
|
||||||
}]),
|
}]),
|
||||||
name: 'main-controller'
|
name: 'main-controller'
|
||||||
};
|
};
|
||||||
|
@ -10,14 +10,14 @@ var schoolInfo = {
|
|||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr7="expr7" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
|
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr9="expr9" style="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; background: #000000DD;"></div>', [{
|
||||||
type: bindingTypes.IF,
|
type: bindingTypes.IF,
|
||||||
evaluate: _scope => _scope.state.enabled,
|
evaluate: _scope => _scope.state.enabled,
|
||||||
redundantAttribute: 'expr7',
|
redundantAttribute: 'expr9',
|
||||||
selector: '[expr7]',
|
selector: '[expr9]',
|
||||||
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr8="expr8" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr9="expr9" style="height: 90px; margin: 10px;"></line-graph></div>', [{
|
template: template('<div style="position: absolute; top: 10%; left: 10%; width: 80%; height: 80%; background: #FFFFFF"><button expr10="expr10" class="delete is-medium">X</button><p><h2></h2></p><line-graph expr11="expr11" style="height: 90px; margin: 10px;"></line-graph></div>', [{
|
||||||
redundantAttribute: 'expr8',
|
redundantAttribute: 'expr10',
|
||||||
selector: '[expr8]',
|
selector: '[expr10]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
type: expressionTypes.EVENT,
|
type: expressionTypes.EVENT,
|
||||||
name: 'onclick',
|
name: 'onclick',
|
||||||
@ -29,8 +29,8 @@ var schoolInfo = {
|
|||||||
evaluate: _scope => 'line-graph',
|
evaluate: _scope => 'line-graph',
|
||||||
slots: [],
|
slots: [],
|
||||||
attributes: [],
|
attributes: [],
|
||||||
redundantAttribute: 'expr9',
|
redundantAttribute: 'expr11',
|
||||||
selector: '[expr9]'
|
selector: '[expr11]'
|
||||||
}])
|
}])
|
||||||
}]),
|
}]),
|
||||||
name: 'school-info'
|
name: 'school-info'
|
||||||
|
@ -47,7 +47,7 @@ var school = {
|
|||||||
this.update({
|
this.update({
|
||||||
items: response
|
items: response
|
||||||
});
|
});
|
||||||
console.log(this.state.items);
|
//console.log(this.state.items)
|
||||||
this.state.items.forEach(etablissement => {
|
this.state.items.forEach(etablissement => {
|
||||||
// calcul la moyenne
|
// calcul la moyenne
|
||||||
let pct_sansmention = etablissement.fields.pct_sansmention;
|
let pct_sansmention = etablissement.fields.pct_sansmention;
|
||||||
@ -60,60 +60,61 @@ var school = {
|
|||||||
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
// Exemple : Assez bien est entre 12 et 14 donc 13.
|
||||||
let moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
|
let moyenne = (pct_TBF * 19 + pct_TB * 17 + pct_B * 15 + pct_AB * 13 + pct_sansmention * 11) / 100;
|
||||||
etablissement.fields.moyenne = moyenne;
|
etablissement.fields.moyenne = moyenne;
|
||||||
console.log(etablissement.fields);
|
//console.log(etablissement.fields)
|
||||||
});
|
});
|
||||||
|
|
||||||
this.update();
|
this.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
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&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 expr34="expr34"></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&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>', [{
|
||||||
type: bindingTypes.EACH,
|
type: bindingTypes.EACH,
|
||||||
getKey: null,
|
getKey: null,
|
||||||
condition: null,
|
condition: null,
|
||||||
template: template('<td expr35="expr35"> </td><td expr36="expr36"> </td><td expr37="expr37"> </td><td expr38="expr38"> </td><td expr39="expr39"> </td>', [{
|
template: template('<td expr17="expr17"> </td><td expr18="expr18"> </td><td expr19="expr19"> </td><td expr20="expr20"> </td><td expr21="expr21"> </td>', [{
|
||||||
redundantAttribute: 'expr35',
|
redundantAttribute: 'expr17',
|
||||||
selector: '[expr35]',
|
selector: '[expr17]',
|
||||||
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: 'expr36',
|
redundantAttribute: 'expr18',
|
||||||
selector: '[expr36]',
|
selector: '[expr18]',
|
||||||
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: 'expr37',
|
redundantAttribute: 'expr19',
|
||||||
selector: '[expr37]',
|
selector: '[expr19]',
|
||||||
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: 'expr38',
|
redundantAttribute: 'expr20',
|
||||||
selector: '[expr38]',
|
selector: '[expr20]',
|
||||||
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: 'expr39',
|
redundantAttribute: 'expr21',
|
||||||
selector: '[expr39]',
|
selector: '[expr21]',
|
||||||
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: 'expr34',
|
redundantAttribute: 'expr16',
|
||||||
selector: '[expr34]',
|
selector: '[expr16]',
|
||||||
itemName: 'etablissement',
|
itemName: 'etablissement',
|
||||||
indexName: null,
|
indexName: null,
|
||||||
evaluate: _scope => _scope.state.items
|
evaluate: _scope => _scope.state.items
|
||||||
|
@ -29,37 +29,98 @@ class PAPI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function filterSearch() {}
|
const PLACEHOLDERS = ["Formation", "Filière", "Spécialité"];
|
||||||
var search = {
|
var search = {
|
||||||
css: null,
|
css: null,
|
||||||
exports: {
|
exports: {
|
||||||
|
updateList() {
|
||||||
|
let promise;
|
||||||
|
this.update({
|
||||||
|
updating: true
|
||||||
|
});
|
||||||
|
switch (this.state.currentStep) {
|
||||||
|
case 0:
|
||||||
|
promise = PAPI.fetchFilieres();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
promise = PAPI.fetchFiliere(this.state.filiere);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
promise = PAPI.fetchSpecialites(this.state.specialite);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
promise.then(response => {
|
||||||
|
this.state.allItems = response;
|
||||||
|
this.filterSearch();
|
||||||
|
this.update({
|
||||||
|
updating: false
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
filterSearch() {
|
||||||
|
let input = this.$("input");
|
||||||
|
if (!input) return;
|
||||||
|
let finalArray = [];
|
||||||
|
|
||||||
|
//On évite de trier avant d'avoir plus de 1 lettres.
|
||||||
|
if (input.value.length > 1) {
|
||||||
|
finalArray = this.state.allItems.filter(item => {
|
||||||
|
return item.name.toLowerCase().includes(input.value.toLowerCase());
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
finalArray = this.state.allItems;
|
||||||
|
}
|
||||||
|
this.update({
|
||||||
|
items: finalArray
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cruiseForward(selection) {
|
||||||
|
if (this.state.currentStep >= 2) return;
|
||||||
|
switch (this.state.currentStep) {
|
||||||
|
case 0:
|
||||||
|
this.state.filiere = selection;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
this.state.specialite = selection;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
this.state.currentStep++;
|
||||||
|
this.updateList();
|
||||||
|
this.update({
|
||||||
|
placeholder: PLACEHOLDERS[this.state.currentStep]
|
||||||
|
});
|
||||||
|
},
|
||||||
|
cruiseBack() {
|
||||||
|
if (!this.state.currentStep) return;
|
||||||
|
this.state.currentStep--;
|
||||||
|
this.updateList();
|
||||||
|
this.update({
|
||||||
|
placeholder: PLACEHOLDERS[this.state.currentStep]
|
||||||
|
});
|
||||||
|
},
|
||||||
onBeforeMount(props, state) {
|
onBeforeMount(props, state) {
|
||||||
//Initial state
|
//Initial state
|
||||||
this.state = {
|
this.state = {
|
||||||
placeholder: "Formation",
|
placeholder: PLACEHOLDERS[0],
|
||||||
currentStep: 0,
|
currentStep: 0,
|
||||||
allItems: null,
|
allItems: null,
|
||||||
filter: null,
|
filter: null,
|
||||||
items: null
|
items: null,
|
||||||
|
filiere: null,
|
||||||
|
specialite: null,
|
||||||
|
updating: false
|
||||||
};
|
};
|
||||||
PAPI.fetchFilieres().then(response => {
|
},
|
||||||
this.state.allItems = response;
|
onMounted() {
|
||||||
this.update({
|
this.updateList();
|
||||||
items: filterSearch(this.state.allItems)
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr10="expr10" class="input" type="input"/><button expr11="expr11" class="button ml-1"><</button></div><div id="list-formations"><ul><li expr12="expr12" 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 expr304="expr304" class="input" type="input"/><button expr305="expr305" class="button ml-1"><</button></div><div id="list-formations"><ul><li expr306="expr306" class="m-1"></li></ul></div></div>', [{
|
||||||
redundantAttribute: 'expr10',
|
redundantAttribute: 'expr304',
|
||||||
selector: '[expr10]',
|
selector: '[expr304]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
type: expressionTypes.EVENT,
|
type: expressionTypes.EVENT,
|
||||||
name: 'onkeydown',
|
name: 'onkeyup',
|
||||||
evaluate: _scope => _scope.filterSearch
|
|
||||||
}, {
|
|
||||||
type: expressionTypes.EVENT,
|
|
||||||
name: 'onfocusout',
|
|
||||||
evaluate: _scope => _scope.filterSearch
|
evaluate: _scope => _scope.filterSearch
|
||||||
}, {
|
}, {
|
||||||
type: expressionTypes.ATTRIBUTE,
|
type: expressionTypes.ATTRIBUTE,
|
||||||
@ -67,12 +128,12 @@ var search = {
|
|||||||
evaluate: _scope => _scope.state.placeholder
|
evaluate: _scope => _scope.state.placeholder
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
redundantAttribute: 'expr11',
|
redundantAttribute: 'expr305',
|
||||||
selector: '[expr11]',
|
selector: '[expr305]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
type: expressionTypes.ATTRIBUTE,
|
type: expressionTypes.ATTRIBUTE,
|
||||||
name: 'disabled',
|
name: 'disabled',
|
||||||
evaluate: _scope => !_scope.state.currentStep
|
evaluate: _scope => !_scope.state.currentStep || _scope.state.updating
|
||||||
}, {
|
}, {
|
||||||
type: expressionTypes.EVENT,
|
type: expressionTypes.EVENT,
|
||||||
name: 'onclick',
|
name: 'onclick',
|
||||||
@ -82,33 +143,37 @@ var search = {
|
|||||||
type: bindingTypes.EACH,
|
type: bindingTypes.EACH,
|
||||||
getKey: null,
|
getKey: null,
|
||||||
condition: null,
|
condition: null,
|
||||||
template: template('<button expr13="expr13" class="button is-fullwidth"><span style="font-size: .75em;"><strong expr14="expr14"> </strong></span><div style="margin-left: auto;"></div><span expr15="expr15" class="tag is-primary"> </span></button>', [{
|
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>', [{
|
||||||
redundantAttribute: 'expr13',
|
redundantAttribute: 'expr307',
|
||||||
selector: '[expr13]',
|
selector: '[expr307]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
|
type: expressionTypes.ATTRIBUTE,
|
||||||
|
name: 'disabled',
|
||||||
|
evaluate: _scope => _scope.state.updating
|
||||||
|
}, {
|
||||||
type: expressionTypes.EVENT,
|
type: expressionTypes.EVENT,
|
||||||
name: 'onclick',
|
name: 'onclick',
|
||||||
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
|
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
redundantAttribute: 'expr14',
|
redundantAttribute: 'expr308',
|
||||||
selector: '[expr14]',
|
selector: '[expr308]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
type: expressionTypes.TEXT,
|
type: expressionTypes.TEXT,
|
||||||
childNodeIndex: 0,
|
childNodeIndex: 0,
|
||||||
evaluate: _scope => _scope.item.name
|
evaluate: _scope => _scope.item.name
|
||||||
}]
|
}]
|
||||||
}, {
|
}, {
|
||||||
redundantAttribute: 'expr15',
|
redundantAttribute: 'expr309',
|
||||||
selector: '[expr15]',
|
selector: '[expr309]',
|
||||||
expressions: [{
|
expressions: [{
|
||||||
type: expressionTypes.TEXT,
|
type: expressionTypes.TEXT,
|
||||||
childNodeIndex: 0,
|
childNodeIndex: 0,
|
||||||
evaluate: _scope => _scope.item.count
|
evaluate: _scope => _scope.item.count
|
||||||
}]
|
}]
|
||||||
}]),
|
}]),
|
||||||
redundantAttribute: 'expr12',
|
redundantAttribute: 'expr306',
|
||||||
selector: '[expr12]',
|
selector: '[expr306]',
|
||||||
itemName: 'item',
|
itemName: 'item',
|
||||||
indexName: null,
|
indexName: null,
|
||||||
evaluate: _scope => _scope.state.items
|
evaluate: _scope => _scope.state.items
|
||||||
|
Loading…
Reference in New Issue
Block a user