Blame view

controllets/data-sevc-controllet/data-sevc-controllet_old.html 7.36 KB
4bd2f9c2   Renato De Donato   data-table
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
  <script src="../shared_js/perfect-scrollbar/js/min/perfect-scrollbar.jquery.min.js"></script>

  <link rel="stylesheet" href="../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css">

  

  <script src="../../locales/controllet_ln.js"></script>

  

  <link rel="import" href="../../bower_components/polymer/polymer.html">

  

  <link rel="import" href="../page-slider-controllet/page-slider-controllet.html">

  

  <link rel="import" href="../select-dataset-controllet/select-dataset-controllet.html">

  <link rel="import" href="../select-data-controllet/select-data-controllet.html" />

  <link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" />

  

  <dom-module id="data-sevc-controllet">

  

      <template>

  

          <page-slider-controllet id="slider">

  

              <neon-animatable>

  

                  <template is="dom-if" if={{!modify}}>

                      <select-dataset-controllet id="select_dataset" data={{data}} datasets={{datasets}} suggested-datasets={{suggestedDatasets}}></select-dataset-controllet>

                  </template>

  

              </neon-animatable>

  

              <neon-animatable>

  

                  <select-data-controllet id="select_data" data-url={{dataUrl}} preselected-fields={{selectedFields}} datalet-preset="{{dataletPreset}}"></select-data-controllet>

  

              </neon-animatable>

  

              <neon-animatable>

  

                  <select-visualization-controllet id="select_visualization" deep-url={{deepUrl}} datalets-list-url={{dataletsListUrl}} data-url={{dataUrl}} preselected-datalet={{selectedDatalet}} datalet-preset={{dataletPreset}}></select-visualization-controllet>

  

              </neon-animatable>

  

          </page-slider-controllet>

  

      </template>

  

      <script>

  

          Polymer({

  

              is : 'data-sevc-controllet',

  

              listeners : {

                  'page-slider-controllet_selected' : '_updateSlider',

                  'dataset-selection-controllet_data-url' : '_allowSecondStep',

                  'tree-view-controllet_selected-fields' : '_allowThirdStep'

              },

  

              properties : {

  

                  deepUrl : {

                      type : String,

                      value : undefined

                  },

  

                  dataletsListUrl : {

                      type : String ,

                      value : undefined

                  },

  

                  datasets : {

                      type : Array,

                      value : undefined

                  },

  

                  suggestedDatasets : {

                      type : Array,

                      value : undefined

                  },

  

                  dataUrl : {

                      type  : String,

                      value : undefined

                  },

  

                  jsonData : {

                      type  : Object,

                      value : undefined

                  },

  

                  modify : {

                      type  : Boolean,

                      value : false

                  },

  

                  selectedDatalet : {

                      type  : String,

                      value : undefined

                  },

  

                  selectedFields : {

                      type  : Array,

                      value : []

                  },

  

                  dataletPreset : {

                      type  : Object,

                      value : []

                  },

  

                  localization : {

                      type : String,

                      value : "en"

                  }

  

              },

  

              ready : function(){

                  if(this.selectedDatalet){

                      this.modify = true;

                      this.$.slider.selected = 1;

                      this.dataUrl = this.dataletPreset["data-url"];

                  }

                  ln["localization"] = this.localization;

              },

  

              _updateSlider : function(e){

                  switch (e.detail.selected) {

                      case 0:

                          slider.setTitle(ln["slide1Title_" + this.localization], ln["slide1Subtitle_" + this.localization]);

                          slider.chevronLeft("invisible");

                          slider.chevronRight(false);

                          if(slider.getPrevSelected() == 1)

                              slider.chevronRight(true);

                          break;

                      case 1:

                          slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]);

                          if(this.modify){

                              slider.chevronLeft("invisible");

                          }

                          else{

                              slider.chevronLeft(true);

                          }

                          slider.chevronRight(false);

                          this._allowThirdStep({detail: {fields: select_data.getSelectedFields()}});

                          if(this.modify){

                              this.$.select_visualization.setFields(select_data.getSelectedFields());

                              this.$.select_visualization.setFilters(select_data.getFilters());

                          }

                          break;

                      case 2:

                          slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]);

                          slider.chevronLeft(true);

                          slider.chevronRight("invisible");

  

                          this.$.select_visualization.setFields(select_data.getSelectedFields());

                          this.$.select_visualization.setFilters(select_data.getFilters());

                          if(this.modify) {

                              this.$.select_visualization.show();//resize

                          }

                  }

              },

  

              _allowSecondStep : function(e){

                  if(e.detail.url == "") {

                      slider.chevronRight(false);

                      select_dataset.$.selected_url.invalid = false;

                      return;

                  }

  

                  this.dataUrl = e.detail.url;

  

                  var that = this;

  

                  $.ajax({

                      url: e.detail.url,

                      dataType: "json",

                      success: function(data){

  //                        this.dataUrl = e.detail.url

  //                        this.jsonData = JSON.stringify(data);

                          slider.chevronRight(true);

                          select_dataset.$.selected_url.invalid = false;

  

                          that.$.select_data._init();

                      },

                      error: function(){

  //                        this.jsonData = undefined;

                          slider.chevronRight(false);

                          select_dataset.$.selected_url.invalid = true;

  

                          that.$.select_data._reset();

                      }

                  });

  

                  //NOT HERE ma quando VADO al secondo passo e l'url รจ cambiato

  //                this.$.select_data._init();

                  this.$.select_visualization.reset();

              },

  

              _allowThirdStep : function(e){

                  if(e.detail.fields.length > 0)

                      slider.chevronRight(true);

                  else

                      slider.chevronRight(false);

  

                  //this.$.select_visualization.reset();

              }

  

          });

  

      </script>

  

  </dom-module>