Commit 278cc529 authored by Yohan Boniface's avatar Yohan Boniface

Add IDCC search in explorer tools

parent 432f944a
<idcc-search>
<section>
<h2>Recherche IDCC</h2>
<form onsubmit={ this.submit }>
<input type="text" ref="idcc" placeholder="Chercher une convention collective" name="idcc-autocomplete">
<input type="submit" value="Chercher">
</form>
</section>
<section class=results if={ this.refs.idcc.value }>
<h2>Conventions collectives</h2>
<ul if={ this.results.length }>
<li each={ this.results }>{ name } <strong>({ code })</strong></li>
</ul>
<p if={ this.refs.idcc.value && !this.results.length }>Aucune convention collective trouvée pour la recherche «{ this.refs.idcc.value }».</p>
</section>
<script>
this.results = []
this.search = (text) => {
fetch(`http://163.172.180.45/search/?q=${text}`)
.then((response) => response.json())
.then((data) => {
this.results = data.results
this.update()
})
}
this.submit = (e) => {
e.preventDefault();
const text = this.refs.idcc.value
if (!text) return
this.search(text)
}
</script>
<style scoped>
:scope {
display: grid;
grid-template-columns: 2fr 4fr;
grid-gap: 10px;
overflow: hidden;
}
h2 {
font-variant: small-caps;
}
.results {
padding: 10px;
border-left: 1px solid #ddd;
}
</style>
</idcc-search>
......@@ -4,6 +4,7 @@
<a href="#schema">Schéma</a>
<a href="#rules">Règles de gestion</a>
<a href="#simulate">Simuler</a>
<a href="#tools">Outils</a>
</section>
<style scoped>
......
<tools>
<idcc-search></idcc-search>
<script>
this.mixin(View)
</script>
<style scoped>
h2 {
font-variant: small-caps;
}
.results {
padding: 10px;
border-left: 1px solid #ddd;
}
</style>
</tools>
......@@ -10,6 +10,8 @@
<script src="components/rule.tag.html" type="riot/tag"></script>
<script src="components/rules.tag.html" type="riot/tag"></script>
<script src="components/simulate.tag.html" type="riot/tag"></script>
<script src="components/tools.tag.html" type="riot/tag"></script>
<script src="components/idcc-search.tag.html" type="riot/tag"></script>
<app>
<header data-is=navbar class=header></header>
......@@ -17,6 +19,7 @@
<schema></schema>
<rules></rules>
<simulate></simulate>
<tools></tools>
</section>
</app>
......@@ -25,6 +28,7 @@
route('/schema', () => riot.mount('schema'))
route('/rules', () => riot.mount('rules'))
route('/simulate', () => riot.mount('simulate'))
route('/tools', () => riot.mount('tools'))
let SCHEMA
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment