Commit e83357ec authored by Yohan Boniface's avatar Yohan Boniface

Return éligibilité status even if the financement was éligible

parent 34fe5579
......@@ -579,10 +579,10 @@ financement:
reason:
type: string
nullable: true
# params:
# type: object
# additionalProperties:
# type: string
params:
type: object
additionalProperties:
type: string
terms:
# TODO dry me
type: array
......
let SCHEMA
let RULES
function renderValue (key, value) {
if (SCHEMA[key]['type'] === 'array') return value.join(', ')
if (SCHEMA[key]['type'] === 'boolean') return value ? 'oui' : 'non'
if (SCHEMA[key]['format'] === 'date') return (new Date(value * 1000)).toLocaleDateString()
if (SCHEMA[key]['enum']) return SCHEMA[key]['enum'][value]
return value
}
function renderLabel (key, value) {
return SCHEMA[key]['label']
}
function init () {
fetch('/explore/schema')
.then((response) => response.json())
.then((data) => {
SCHEMA = data
route.start(true)
})
}
<context>
<table>
<tr each={ value, key in this.opts.data }><th>{ this.renderLabel(key, value) }</th><td>{ this.renderValue(key, value) }</td></tr>
<tr each={ value, key in this.opts.data }><th>{ renderLabel(key, value) }</th><td>{ renderValue(key, value) }</td></tr>
</table>
<style scoped>
......@@ -20,17 +20,4 @@
background: #f3f3f3;
}
</style>
<script>
this.renderValue = (key, value) => {
if (SCHEMA[key]['type'] === 'array') return value.join(', ')
if (SCHEMA[key]['format'] === 'date') return (new Date(value * 1000)).toLocaleDateString()
if (SCHEMA[key]['enum']) return SCHEMA[key]['enum'][value]
return value
}
this.renderLabel = (key, value) => {
return SCHEMA[key]['label']
}
</script>
</context>
......@@ -26,7 +26,7 @@
<p><strong>Rémunération</strong> {remuneration}</p>
<p><strong>Organisme</strong> {organisme.nom}</p>
</virtual>
<p if={ !eligible }>
<p>
<strong>Critères d'éligibilité</strong>
<eligibilite conditions={ eligibilite }></eligibilite>
</p>
......@@ -140,10 +140,12 @@
<eligibilite>
<ul>
<li each={ props, i in this.opts.conditions } class={ passed: props.status, failed: !props.status }>
<span if={ i && this.opts.connective }> { this.opts.connective } </span>
<span class=tooltip if={ !props.terms && !props.status }><span>{ props.condition }</span><span class=tooltip-content>{ props.reason }</span></span>
<span if={ (!props.terms && props.status) || (props.status && props.terms) }>{ props.condition }</span>
<eligibilite if={ !props.status && props.terms } conditions={ props.terms } connective={ props.connective }></eligibilite>
<virtual if={ !props.terms }>
<span if={ i && this.opts.connective }> { this.opts.connective } </span>
<span class=tooltip if={ !props.status }><span>{ props.condition }</span><span class=tooltip-content>{ props.reason }</span></span>
<span class=tooltip if={ props.status }><span>{ props.condition }</span><span class=tooltip-content><span each={ value, key in props.params }>{ renderLabel(key, value) }: { renderValue(key, value) }<br></span></span></span>
</virtual>
<eligibilite if={ props.terms } conditions={ props.terms } connective={ props.connective }></eligibilite>
</li>
</ul>
......
......@@ -5,6 +5,7 @@
<script src="vendor/riot/route%2Btag.min.js"></script>
<link rel="stylesheet" type="text/css" href="app.css">
<script type="text/javascript" src="mixin/view.mixin.js"></script>
<script type="text/javascript" src="app.js"></script>
<script src="components/navbar.tag.html" type="riot/tag"></script>
<script src="components/schema.tag.html" type="riot/tag"></script>
<script src="components/glossary.tag.html" type="riot/tag"></script>
......@@ -36,14 +37,5 @@
route('/tools', () => riot.mount('tools'))
route('/glossary', () => riot.mount('glossary'))
let SCHEMA
let RULES
fetch('/explore/schema')
.then((response) => response.json())
.then((data) => {
SCHEMA = data
route.start(true)
})
init();
</script>
......@@ -78,21 +78,11 @@ class Pointer:
return ...
class Value:
def __init__(self, pointer, context):
self.value = pointer.get(**context)
self.pointer = pointer
def __str__(self):
return str(self.value or 'aucun(e)')
def action(pattern):
def wrapper(func):
Action.PATTERNS[re.compile(pattern)] = func
func.on_miss = None
func.on_act = None
return func