rules.tag.html 2.03 KB
Newer Older
Yohan Boniface's avatar
Yohan Boniface committed
1
<rules>
Yohan Boniface's avatar
Yohan Boniface committed
2
  <aside>
3
    <h2 class="page-title">Règles de gestion</h2>
Yohan Boniface's avatar
Yohan Boniface committed
4
    <rules-menu title="Règles régionales" namespace="région"></rules-menu>
5
    <rules-menu title="Règles nationales" namespace="règles nationales"></rules-menu>
Yohan Boniface's avatar
Yohan Boniface committed
6
    <rules-menu title="Règles des organismes paritaires" namespace="organisme paritaire"></rules-menu>
7
    <rules-menu title="Règles de rémunérations" namespace="rémunération"></rules-menu>
Yohan Boniface's avatar
Yohan Boniface committed
8 9
    <rules-menu title="Règles de normalisation" namespace="normalisation"></rules-menu>
  </aside>
10
  <div if={ this.rule }>
Yohan Boniface's avatar
Yohan Boniface committed
11
    <h3>{ this.rule.path } <a href=https://framagit.org/ybon/trefle/tree/master/trefle/config/rules/{ this.rule.path } target=_blank> <i class="icon">edit</i></a></h3>
12 13 14 15
    <rule content={ this.rule.data } class=with-lines></rule>
  </div>
  <div if={ !this.rule }>
    <p>Sélectionner une règle dans le menu.</p>
Yohan Boniface's avatar
Yohan Boniface committed
16 17 18
  </div>

  <script>
19 20
    this.rules = []
    this.rule = null
21
    this.active = null
Yohan Boniface's avatar
Yohan Boniface committed
22 23 24

    this.on('mount', () => this.load())

25 26 27
    this.load_data = (data) => {
      RULES = data
      this.rules = data
28 29 30 31
      if (this.opts.id) {
        this.active = decodeURIComponent(this.opts.id)
        this.rule = data[this.active.split('~')[0]]
      }
32 33 34 35 36 37
      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
    }

Yohan Boniface's avatar
Yohan Boniface committed
38
    this.load = () => {
39
      if (RULES) return this.load_data(RULES)
40
      request('../explore/rules')
41
      .then(this.load_data)
Yohan Boniface's avatar
Yohan Boniface committed
42 43 44 45 46
    }

    this.mixin(View)
  </script>

Yohan Boniface's avatar
Yohan Boniface committed
47
  <style scoped>
48
    :scope.tools {
Yohan Boniface's avatar
Yohan Boniface committed
49
      min-width: 1200px;
50
      grid-template-columns: 1fr 4fr;
Yohan Boniface's avatar
Yohan Boniface committed
51 52
    }
    h3 {
Yohan Boniface's avatar
Yohan Boniface committed
53 54 55 56 57 58
      font-variant: small-caps;
    }
  </style>

</rules>

Yohan Boniface's avatar
Yohan Boniface committed
59 60 61 62 63 64
<rules-menu>
<h4>{ this.opts.title }</h4>
  <ul>
    <li each={ props, id in this.parent.rules } if={ props.path.startsWith(this.opts.namespace) }><a href="#rules/{ id }" class='{ on: this.parent.parent.active && this.parent.parent.active.startsWith(id) }' title={ id }>{ props.name }</a></li>
  </ul>
</rules-menu>