Commit e9d46756 authored by Yohan Boniface's avatar Yohan Boniface

Explorer: add features tab

parent c40f253f
......@@ -11,4 +11,4 @@ before_script:
test:
script:
- py.test -v --cov
- behave --lang fr -D coverage-format=long
- behave -D coverage-format=long
......@@ -3,6 +3,7 @@
## dev
- explorer: only display bénéficiaire and formation context in simulate
- explorer: add Features tab
## 0.6.0
......
......@@ -29,12 +29,12 @@
## Run integration tests
behave --lang fr
behave
Get a detailed coverage report:
behave --lang fr -D coverage-format=short
behave -D coverage-format=short
Get a more detailed coverage report:
behave --lang fr -D coverage-format=long
behave -D coverage-format=long
[behave]
lang = fr
paths=trefle/config/features
......@@ -4,7 +4,7 @@ from roll import HttpError, Roll
from roll.extensions import cors
from . import VERSION
from .config import FINANCEMENTS, GLOSSARY, NAF, RAW_RULES, SCHEMA
from .config import FEATURES, FINANCEMENTS, GLOSSARY, NAF, RAW_RULES, SCHEMA
from .core import simulate
from .debugging import data_from_lbf_url, make_scenario
from .loggers import log_simulate, logger
......@@ -89,6 +89,11 @@ async def explore_financements(request, response):
response.json = FINANCEMENTS
@app.route('/explore/features')
async def explore_features(request, response):
response.json = FEATURES
@app.route('/explore/catalog')
async def explore_catalog(request, response):
response.body = await get_formation_xml(request.query.get('id'))
......
......@@ -19,6 +19,7 @@ IDCC = {}
RAW_RULES = {}
GLOSSARY = {}
NAF = {}
FEATURES = {}
INTERCARIF_URL = 'https://labonneformation.pole-emploi.fr/ws_intercarif'
ELIGIBILITE_URL = 'http://www.intercariforef.org/serviceweb2/eligibilite/?filtre=branche&'
......@@ -126,6 +127,18 @@ def load_dir_rules(root):
yield load_rules(path)
def load_features():
paths = (ROOT / 'features').glob('*.feature')
for path in sorted(paths, key=lambda p: p.name.lower()):
raw = path.read_text()
id_ = str(path.relative_to(ROOT))
FEATURES[id_] = {
'raw': raw,
'path': id_,
'name': path.stem,
}
def init():
print('Initializing config')
with (ROOT / 'schema.yml').open() as f:
......@@ -147,4 +160,5 @@ def init():
GLOSSARY.update(yaml.safe_load(f.read()))
with (ROOT / 'naf.csv').open() as f:
NAF.update(load_naf(f.read()))
load_features()
print('Done initializing config')
<features>
<ul>
<li each={ props, id in this.features }><a href="#features/{ id }" class='{ on: this.active && this.active.startsWith(id) }' title={ id }>{ props.name }</a></li>
</ul>
<div if={ this.feature }>
<h3>{ this.feature.path } <a href=https://framagit.org/ybon/trefle/tree/master/trefle/config/{ this.feature.path } target=_blank> <i class="icon">edit</i></a></h3>
<rule content={ this.feature.raw } class=with-lines></rule>
</div>
<div if={ !this.feature }>
<p>Sélectionner un fichier dans le menu.</p>
</div>
<script>
this.features = []
this.feature = null
this.active = null
this.on('mount', () => this.load())
this.load_data = (data) => {
this.features = data
if (this.opts.id) {
this.active = decodeURIComponent(this.opts.id)
this.feature = data[this.active.split('~')[0]]
}
this.update()
// Force element target after DOM has been rebuilt
// (eg. if we have a ~line in the URL, to highlight it).
window.location.hash = window.location.hash
}
this.load = () => {
fetch('/explore/features')
.then((response) => response.json())
.then(this.load_data)
}
this.mixin(View)
</script>
<style scoped>
:scope.tools {
min-width: 1200px;
grid-template-columns: 1fr 4fr;
}
h3 {
font-variant: small-caps;
}
</style>
</features>
......@@ -5,6 +5,7 @@
<a href="#rules">Règles de gestion</a>
<a href="#simulate">Simuler</a>
<a href="#financements">Financements</a>
<a href="#features">Tests</a>
<a href="#tools">Outils</a>
<a href="#glossary">Glossaire</a>
</nav>
......
......@@ -11,6 +11,7 @@
<script src="components/glossary.tag.html" type="riot/tag"></script>
<script src="components/rule.tag.html" type="riot/tag"></script>
<script src="components/rules.tag.html" type="riot/tag"></script>
<script src="components/features.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/financements.tag.html" type="riot/tag"></script>
......@@ -25,6 +26,7 @@
<rules class=tools></rules>
<simulate class=tools></simulate>
<financements class=full></financements>
<features class=tools></features>
<tools></tools>
</main>
......@@ -34,6 +36,8 @@
route('/schema', () => riot.mount('schema'))
route('/rules/(.+)', (id) => riot.mount('rules', {id: id}))
route('/rules', () => riot.mount('rules'))
route('/features/(.+)', (id) => riot.mount('features', {id: id}))
route('/features', () => riot.mount('features'))
route('/simulate', () => riot.mount('simulate'))
route('/simulate/(.+)', (url) => riot.mount('simulate', {url: url}))
route('/tools', () => riot.mount('tools'))
......
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