Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
Trèfle
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Open source
Trèfle
Commits
e83357ec
Commit
e83357ec
authored
Jul 17, 2018
by
Yohan Boniface
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return éligibilité status even if the financement was éligible
parent
34fe5579
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
53 deletions
+66
-53
trefle/config/schema.yml
trefle/config/schema.yml
+4
-4
trefle/explorer/app.js
trefle/explorer/app.js
+24
-0
trefle/explorer/components/context.tag.html
trefle/explorer/components/context.tag.html
+1
-14
trefle/explorer/components/simulate.tag.html
trefle/explorer/components/simulate.tag.html
+7
-5
trefle/explorer/index.html
trefle/explorer/index.html
+2
-10
trefle/rules.py
trefle/rules.py
+28
-20
No files found.
trefle/config/schema.yml
View file @
e83357ec
...
...
@@ -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
...
...
trefle/explorer/app.js
0 → 100644
View file @
e83357ec
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
)
})
}
trefle/explorer/components/context.tag.html
View file @
e83357ec
<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>
trefle/explorer/components/simulate.tag.html
View file @
e83357ec
...
...
@@ -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>
...
...
trefle/explorer/index.html
View file @
e83357ec
...
...
@@ -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>
trefle/rules.py
View file @
e83357ec
...
...
@@ -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