Fix Map (rip commit final)

This commit is contained in:
The17thDoctor 2023-03-31 22:27:45 +02:00
parent c91b652b16
commit e6719b57dd
7 changed files with 144 additions and 1540 deletions

View File

@ -56,6 +56,7 @@
finalArray = this.state.schoolList
}
this.updateMap()
this.update({
filteredSchoolList: finalArray
})
@ -93,28 +94,10 @@
this.update()
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList]
state.filteredSchoolList = [...state.schoolList]
if (this.$("input")) this.$("input").value = ""
}
},
onUpdated(props, state) {
if (!state.map && props.shouldShowInfos) {
state.map = L.map("map").setView([47, 2.5], 5)
state.markers = L.markerClusterGroup()
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(state.map)
} else if (props.shouldShowInfos) {
state.markers.clearLayers()
for (let school of state.filteredSchoolList) {
updateMap() {
if (this.state.map && this.props.shouldShowInfos) {
this.state.markers.clearLayers()
for (let school of this.state.filteredSchoolList) {
let fields = school.fields
let pos = fields.g_olocalisation_des_formations
@ -134,9 +117,31 @@
let marker = L.marker(pos)
marker.bindPopup(popupHTML)
state.markers.addLayer(marker)
this.state.markers.addLayer(marker)
}
state.map.addLayer(state.markers)
this.state.map.addLayer(this.state.markers)
}
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList]
state.filteredSchoolList = [...state.schoolList]
if (this.$("input")) this.$("input").value = ""
this.updateMap()
}
},
onUpdated(props, state) {
if (!state.map && props.shouldShowInfos) {
state.map = L.map("map").setView([47, 2.5], 5)
state.markers = L.markerClusterGroup()
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(state.map)
}
},

View File

@ -109,7 +109,7 @@ var mainController = {
});
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2" style="display: flex"><img class="m-auto" src="./resources/logo-parcoursup.svg"/></div><search expr40="expr40"></search><button expr41="expr41" class="button is-danger ml-2 is-outlined">Vider le cache</button></div><div class="column pl-0"><fili-info expr42="expr42"></fili-info><school expr43="expr43"></school></div></div><school-info expr44="expr44"></school-info>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="columns"><div class="column is-one-third"><div class="box p-3 m-2" style="display: flex"><img class="m-auto" src="./resources/logo-parcoursup.svg"/></div><search expr27="expr27"></search><button expr28="expr28" class="button is-danger ml-2 is-outlined">Vider le cache</button></div><div class="column pl-0"><fili-info expr29="expr29"></fili-info><school expr30="expr30"></school></div></div><school-info expr31="expr31"></school-info>', [{
type: bindingTypes.TAG,
getComponent: getComponent,
evaluate: _scope => 'search',
@ -119,11 +119,11 @@ var mainController = {
name: 'updateCourse',
evaluate: _scope => _scope.updateCourse
}],
redundantAttribute: 'expr40',
selector: '[expr40]'
redundantAttribute: 'expr27',
selector: '[expr27]'
}, {
redundantAttribute: 'expr41',
selector: '[expr41]',
redundantAttribute: 'expr28',
selector: '[expr28]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',
@ -147,8 +147,8 @@ var mainController = {
name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos
}],
redundantAttribute: 'expr42',
selector: '[expr42]'
redundantAttribute: 'expr29',
selector: '[expr29]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
@ -175,8 +175,8 @@ var mainController = {
name: 'shouldShowInfos',
evaluate: _scope => _scope.state.shouldShowInfos
}],
redundantAttribute: 'expr43',
selector: '[expr43]'
redundantAttribute: 'expr30',
selector: '[expr30]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
@ -195,8 +195,8 @@ var mainController = {
name: 'school',
evaluate: _scope => _scope.state.school
}],
redundantAttribute: 'expr44',
selector: '[expr44]'
redundantAttribute: 'expr31',
selector: '[expr31]'
}]),
name: 'main-controller'
};

View File

@ -64,62 +64,62 @@ var schoolInfo = {
}];
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr77="expr77" style="z-index: 10000" class="modal is-active"></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr11="expr11" style="z-index: 10000" class="modal is-active"></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.props.popupEnabled,
redundantAttribute: 'expr77',
selector: '[expr77]',
template: template('<div class="modal-background"></div><div class="modal-content"><div class="box p-2"><p><h1 expr78="expr78" class="title is-4 m-2" style="color: #485FC7;"> </h1></p><div class="columns m-2"><div class="column"><p expr79="expr79"> </p><p expr80="expr80"> </p><p expr81="expr81"> </p><p expr82="expr82"> </p><p expr83="expr83"> </p><p expr84="expr84"> </p><p>Rang dernier appelé : </p><ul><li expr85="expr85"></li><li expr86="expr86"></li><li expr87="expr87"></li></ul><p expr88="expr88"> </p></div></div><div class="m-4"><line-graph expr89="expr89" title="Répartition par genre" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr90="expr90" title="Répartition par bac" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr91="expr91" title="Répartition par mention au bac" style="height: 6rem;"></line-graph></div></div></div><button expr92="expr92" class="modal-close is-medium"></button>', [{
redundantAttribute: 'expr78',
selector: '[expr78]',
redundantAttribute: 'expr11',
selector: '[expr11]',
template: template('<div class="modal-background"></div><div class="modal-content"><div class="box p-2"><p><h1 expr12="expr12" class="title is-4 m-2" style="color: #485FC7;"> </h1></p><div class="columns m-2"><div class="column"><p expr13="expr13"> </p><p expr14="expr14"> </p><p expr15="expr15"> </p><p expr16="expr16"> </p><p expr17="expr17"> </p><p expr18="expr18"> </p><p>Rang dernier appelé : </p><ul><li expr19="expr19"></li><li expr20="expr20"></li><li expr21="expr21"></li></ul><p expr22="expr22"> </p></div></div><div class="m-4"><line-graph expr23="expr23" title="Répartition par genre" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr24="expr24" title="Répartition par bac" style="height: 6rem;"></line-graph></div><div class="m-4"><line-graph expr25="expr25" title="Répartition par mention au bac" style="height: 6rem;"></line-graph></div></div></div><button expr26="expr26" class="modal-close is-medium"></button>', [{
redundantAttribute: 'expr12',
selector: '[expr12]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.props.school.fields.g_ea_lib_vx
}]
}, {
redundantAttribute: 'expr79',
selector: '[expr79]',
redundantAttribute: 'expr13',
selector: '[expr13]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => ['Ville : ', _scope.props.school.fields.ville_etab].join('')
}]
}, {
redundantAttribute: 'expr80',
selector: '[expr80]',
redundantAttribute: 'expr14',
selector: '[expr14]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => ['Département : ', _scope.props.school.fields.dep, ' ', _scope.props.school.fields.dep_lib].join('')
}]
}, {
redundantAttribute: 'expr81',
selector: '[expr81]',
redundantAttribute: 'expr15',
selector: '[expr15]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => ['Académie : ', _scope.props.school.fields.acad_mies].join('')
}]
}, {
redundantAttribute: 'expr82',
selector: '[expr82]',
redundantAttribute: 'expr16',
selector: '[expr16]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.props.school.fields.contrat_etab
}]
}, {
redundantAttribute: 'expr83',
selector: '[expr83]',
redundantAttribute: 'expr17',
selector: '[expr17]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => ['Capacité : ', _scope.props.school.fields.capa_fin].join('')
}]
}, {
redundantAttribute: 'expr84',
selector: '[expr84]',
redundantAttribute: 'expr18',
selector: '[expr18]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
@ -128,8 +128,8 @@ var schoolInfo = {
}, {
type: bindingTypes.IF,
evaluate: _scope => _scope.props.school.fields.lib_grp1,
redundantAttribute: 'expr85',
selector: '[expr85]',
redundantAttribute: 'expr19',
selector: '[expr19]',
template: template(' ', [{
expressions: [{
type: expressionTypes.TEXT,
@ -140,8 +140,8 @@ var schoolInfo = {
}, {
type: bindingTypes.IF,
evaluate: _scope => _scope.props.school.fields.lib_grp2,
redundantAttribute: 'expr86',
selector: '[expr86]',
redundantAttribute: 'expr20',
selector: '[expr20]',
template: template(' ', [{
expressions: [{
type: expressionTypes.TEXT,
@ -152,8 +152,8 @@ var schoolInfo = {
}, {
type: bindingTypes.IF,
evaluate: _scope => _scope.props.school.fields.lib_grp3,
redundantAttribute: 'expr87',
selector: '[expr87]',
redundantAttribute: 'expr21',
selector: '[expr21]',
template: template(' ', [{
expressions: [{
type: expressionTypes.TEXT,
@ -162,8 +162,8 @@ var schoolInfo = {
}]
}])
}, {
redundantAttribute: 'expr88',
selector: '[expr88]',
redundantAttribute: 'expr22',
selector: '[expr22]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
@ -179,8 +179,8 @@ var schoolInfo = {
name: 'data',
evaluate: _scope => _scope.state.genreStats
}],
redundantAttribute: 'expr89',
selector: '[expr89]'
redundantAttribute: 'expr23',
selector: '[expr23]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
@ -191,8 +191,8 @@ var schoolInfo = {
name: 'data',
evaluate: _scope => _scope.state.bacStats
}],
redundantAttribute: 'expr90',
selector: '[expr90]'
redundantAttribute: 'expr24',
selector: '[expr24]'
}, {
type: bindingTypes.TAG,
getComponent: getComponent,
@ -203,11 +203,11 @@ var schoolInfo = {
name: 'data',
evaluate: _scope => _scope.state.mentionStats
}],
redundantAttribute: 'expr91',
selector: '[expr91]'
redundantAttribute: 'expr25',
selector: '[expr25]'
}, {
redundantAttribute: 'expr92',
selector: '[expr92]',
redundantAttribute: 'expr26',
selector: '[expr26]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onclick',

View File

@ -30,6 +30,7 @@ var school = {
} else {
finalArray = this.state.schoolList;
}
this.updateMap();
this.update({
filteredSchoolList: finalArray
});
@ -63,24 +64,10 @@ var school = {
}
this.update();
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList];
state.filteredSchoolList = [...state.schoolList];
if (this.$("input")) this.$("input").value = "";
}
},
onUpdated(props, state) {
if (!state.map && props.shouldShowInfos) {
state.map = L.map("map").setView([47, 2.5], 5);
state.markers = L.markerClusterGroup();
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(state.map);
} else if (props.shouldShowInfos) {
state.markers.clearLayers();
for (let school of state.filteredSchoolList) {
updateMap() {
if (this.state.map && this.props.shouldShowInfos) {
this.state.markers.clearLayers();
for (let school of this.state.filteredSchoolList) {
let fields = school.fields;
let pos = fields.g_olocalisation_des_formations;
let popupHTML = document.createElement("div");
@ -95,9 +82,27 @@ var school = {
popupHTML.appendChild(linkToForma);
let marker = L.marker(pos);
marker.bindPopup(popupHTML);
state.markers.addLayer(marker);
this.state.markers.addLayer(marker);
}
state.map.addLayer(state.markers);
this.state.map.addLayer(this.state.markers);
}
},
onBeforeUpdate(props, state) {
if (props.schoolListUpdating) {
state.schoolList = [...props.schoolList];
state.filteredSchoolList = [...state.schoolList];
if (this.$("input")) this.$("input").value = "";
this.updateMap();
}
},
onUpdated(props, state) {
if (!state.map && props.shouldShowInfos) {
state.map = L.map("map").setView([47, 2.5], 5);
state.markers = L.markerClusterGroup();
L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '&copy; <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>'
}).addTo(state.map);
}
},
onBeforeMount(props, state) {
@ -109,14 +114,14 @@ var school = {
},
sortFields: SORT_TABLE
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr51="expr51" class="box p-2 m-2" disabled></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div expr41="expr41" class="box p-2 m-2" disabled></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.props.shouldShowInfos,
redundantAttribute: 'expr51',
selector: '[expr51]',
template: template('<div id="map" width="100%" style="border-radius: 5px"></div><div class="mt-2 mb-2 control has-icons-left is-inline-block is-pulled-right"><input expr52="expr52" 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 is-narrow"><thead><tr><th expr53="expr53"></th></tr></thead><tbody><tr expr55="expr55"></tr></tbody></table>', [{
redundantAttribute: 'expr52',
selector: '[expr52]',
redundantAttribute: 'expr41',
selector: '[expr41]',
template: template('<div id="map" width="100%" style="border-radius: 5px"></div><div class="mt-2 mb-2 control has-icons-left is-inline-block is-pulled-right"><input expr42="expr42" 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 is-narrow"><thead><tr><th expr43="expr43"></th></tr></thead><tbody><tr expr45="expr45"></tr></tbody></table>', [{
redundantAttribute: 'expr42',
selector: '[expr42]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onkeyup',
@ -126,15 +131,15 @@ var school = {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template(' <a expr54="expr54"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{
template: template(' <a expr44="expr44"><span class="icon"><i class="fas fa-sort"></i></span></a>', [{
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => [_scope.sortField.name].join('')
}]
}, {
redundantAttribute: 'expr54',
selector: '[expr54]',
redundantAttribute: 'expr44',
selector: '[expr44]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'id',
@ -145,8 +150,8 @@ var school = {
evaluate: _scope => () => _scope.sortList(_scope.sortField.id, true)
}]
}]),
redundantAttribute: 'expr53',
selector: '[expr53]',
redundantAttribute: 'expr43',
selector: '[expr43]',
itemName: 'sortField',
indexName: null,
evaluate: _scope => _scope.sortFields
@ -154,9 +159,9 @@ var school = {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<td><a expr56="expr56"> </a></td><td expr57="expr57"> </td><td expr58="expr58"> </td><td expr59="expr59"> </td><td><title-progress expr60="expr60" max="100" style="margin: auto"></title-progress></td>', [{
redundantAttribute: 'expr56',
selector: '[expr56]',
template: template('<td><a expr46="expr46"> </a></td><td expr47="expr47"> </td><td expr48="expr48"> </td><td expr49="expr49"> </td><td><title-progress expr50="expr50" max="100" style="margin: auto"></title-progress></td>', [{
redundantAttribute: 'expr46',
selector: '[expr46]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
@ -167,24 +172,24 @@ var school = {
evaluate: _scope => () => _scope.props.popup(_scope.school)
}]
}, {
redundantAttribute: 'expr57',
selector: '[expr57]',
redundantAttribute: 'expr47',
selector: '[expr47]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.school.fields.ville_etab
}]
}, {
redundantAttribute: 'expr58',
selector: '[expr58]',
redundantAttribute: 'expr48',
selector: '[expr48]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.school.fields.dep
}]
}, {
redundantAttribute: 'expr59',
selector: '[expr59]',
redundantAttribute: 'expr49',
selector: '[expr49]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
@ -200,11 +205,11 @@ var school = {
name: 'value',
evaluate: _scope => _scope.school.fields.taux_acces_ens
}],
redundantAttribute: 'expr60',
selector: '[expr60]'
redundantAttribute: 'expr50',
selector: '[expr50]'
}]),
redundantAttribute: 'expr55',
selector: '[expr55]',
redundantAttribute: 'expr45',
selector: '[expr45]',
itemName: 'school',
indexName: null,
evaluate: _scope => _scope.state.filteredSchoolList

View File

@ -150,9 +150,9 @@ var search = {
this.updateList();
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr45="expr45" class="input" type="input"/><button expr46="expr46" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr47="expr47" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr45',
selector: '[expr45]',
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div class="box p-1 m-2"><div class="columns m-1"><input expr35="expr35" class="input" type="input"/><button expr36="expr36" class="button ml-1">&lt;</button></div><div id="list-formations"><ul><li expr37="expr37" class="m-1"></li></ul></div></div>', [{
redundantAttribute: 'expr35',
selector: '[expr35]',
expressions: [{
type: expressionTypes.EVENT,
name: 'onkeyup',
@ -163,8 +163,8 @@ var search = {
evaluate: _scope => _scope.state.placeholder
}]
}, {
redundantAttribute: 'expr46',
selector: '[expr46]',
redundantAttribute: 'expr36',
selector: '[expr36]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'disabled',
@ -178,9 +178,9 @@ var search = {
type: bindingTypes.EACH,
getKey: null,
condition: null,
template: template('<button expr48="expr48" class="button is-fullwidth p-2" style="white-space: unset"><div style="display: flex; width: 100%"><span class="mt-auto mb-auto" style="font-size: 0.75em; text-align: left; "><strong expr49="expr49"> </strong></span><div style="margin-left: auto;"></div><span expr50="expr50" class="tag is-primary mt-auto mb-auto"> </span></div></button>', [{
redundantAttribute: 'expr48',
selector: '[expr48]',
template: template('<button expr38="expr38" class="button is-fullwidth p-2" style="white-space: unset"><div style="display: flex; width: 100%"><span class="mt-auto mb-auto" style="font-size: 0.75em; text-align: left; "><strong expr39="expr39"> </strong></span><div style="margin-left: auto;"></div><span expr40="expr40" class="tag is-primary mt-auto mb-auto"> </span></div></button>', [{
redundantAttribute: 'expr38',
selector: '[expr38]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'disabled',
@ -191,24 +191,24 @@ var search = {
evaluate: _scope => () => _scope.cruiseForward(_scope.item.name)
}]
}, {
redundantAttribute: 'expr49',
selector: '[expr49]',
redundantAttribute: 'expr39',
selector: '[expr39]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.name
}]
}, {
redundantAttribute: 'expr50',
selector: '[expr50]',
redundantAttribute: 'expr40',
selector: '[expr40]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.item.count
}]
}]),
redundantAttribute: 'expr47',
selector: '[expr47]',
redundantAttribute: 'expr37',
selector: '[expr37]',
itemName: 'item',
indexName: null,
evaluate: _scope => _scope.state.items

View File

@ -25,11 +25,11 @@ var titleProgress = {
state.class = this.computeClasses();
}
},
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div style="display: flex;"><span expr11="expr11"></span><span expr12="expr12" class="ml-1"> </span><progress expr13="expr13" style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress></div>', [{
template: (template, expressionTypes, bindingTypes, getComponent) => template('<div style="display: flex;"><span expr32="expr32"></span><span expr33="expr33" class="ml-1"> </span><progress expr34="expr34" style="box-shadow: 0 0.5em 1em -0.125em rgb(10 10 10 / 10%), 0 0 0 1px rgb(10 10 10 / 2%);"></progress></div>', [{
type: bindingTypes.IF,
evaluate: _scope => _scope.props.title,
redundantAttribute: 'expr11',
selector: '[expr11]',
redundantAttribute: 'expr32',
selector: '[expr32]',
template: template(' ', [{
expressions: [{
type: expressionTypes.TEXT,
@ -38,16 +38,16 @@ var titleProgress = {
}]
}])
}, {
redundantAttribute: 'expr12',
selector: '[expr12]',
redundantAttribute: 'expr33',
selector: '[expr33]',
expressions: [{
type: expressionTypes.TEXT,
childNodeIndex: 0,
evaluate: _scope => _scope.calcPct()
}]
}, {
redundantAttribute: 'expr13',
selector: '[expr13]',
redundantAttribute: 'expr34',
selector: '[expr34]',
expressions: [{
type: expressionTypes.ATTRIBUTE,
name: 'value',

1406
test.json

File diff suppressed because it is too large Load Diff