Blame view

controllets/tree-view-controllet/demo/index.html 2.14 KB
24be6abb   Luigi Serra   selection control...
1
2
3
  <html>
  
  <head>
9d4a34db   Luigi Serra   selection control...
4
      <script src="../../shared_js/jquery-1.11.2.min.js"></script>
24be6abb   Luigi Serra   selection control...
5
  
9d4a34db   Luigi Serra   selection control...
6
      <script src="../../../bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
24be6abb   Luigi Serra   selection control...
7
8
9
10
11
12
13
  
      <link rel="import" href="../tree-view-controllet.html" />
  </head>
  
  <body>
  
      <style>
9d4a34db   Luigi Serra   selection control...
14
15
16
17
18
          .container {
              display: flex;
              flex-direction: row;
          }
          #tree_container {
24be6abb   Luigi Serra   selection control...
19
              width: 300px;
24be6abb   Luigi Serra   selection control...
20
          }
9d4a34db   Luigi Serra   selection control...
21
22
          #fields_container {
              margin-left: 100px;
24be6abb   Luigi Serra   selection control...
23
24
25
          }
      </style>
  
9d4a34db   Luigi Serra   selection control...
26
27
28
29
30
      <div class="container">
  
          <div id="tree_container">
  
              <tree-view-controllet id="tree" root-name="data" opened-path="records,geometry" preselected-fields='["records,datasetid", "records,recordid", "nhits"]'></tree-view-controllet>
24be6abb   Luigi Serra   selection control...
31
  
9d4a34db   Luigi Serra   selection control...
32
          </div>
24be6abb   Luigi Serra   selection control...
33
  
9d4a34db   Luigi Serra   selection control...
34
35
36
37
          <div id="fields_container">
              <h3>Selected fields:</h3>
              <p id="fields">&nbsp;</p>
          </div>
24be6abb   Luigi Serra   selection control...
38
39
40
41
42
43
44
45
46
47
48
49
  
      </div>
  
      <script>
          var tree = document.getElementById('tree');
          var fields = document.getElementById('fields');
  
          $.ajax({
              url: 'https://data.issy.com/api/records/1.0/search?dataset=liste-des-restaurants-a-issy-les-moulineaux&sort=type&facet=type&facet=terrasse',
              dataType: "json",
              success: function(data){
                  tree.setAttribute("json-data", JSON.stringify(data));
9d4a34db   Luigi Serra   selection control...
50
                  tree.ready();//chrome
24be6abb   Luigi Serra   selection control...
51
52
53
              }
          });
  
9d4a34db   Luigi Serra   selection control...
54
55
          tree.addEventListener("tree-view-controllet_selected-fields", function (e) {
              fields.innerHTML = e.detail.fields;
24be6abb   Luigi Serra   selection control...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
              console.log(tree.getFlatFields());
              console.log(tree.getFields());//firefox console.log does not recognize associative array?
          });
  
      </script>
  
  </body>
  
  </html>
  
  <!--urls:-->
  <!--url: 'http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5',-->
  <!--url: 'https://data.issy.com/api/records/1.0/search?dataset=liste-des-restaurants-a-issy-les-moulineaux&sort=type&facet=type&facet=terrasse',-->
  <!--url: 'https://data.issy.com/api/records/1.0/search?dataset=flux-rss-des-offres-demplois-a-issy-les-moulineaux&sort=published&facet=published&refine.published=2015',-->