Commit e94f95130be3fde3c420a2d3ee46512a360eb2cd
1 parent
1efea0f2
filter ln
Showing
3 changed files
with
50 additions
and
13 deletions
controllets/filters-controllet/filters-controllet.html
... | ... | @@ -106,7 +106,7 @@ |
106 | 106 | |
107 | 107 | <div id="filters_container"> |
108 | 108 | |
109 | - <div id="filters_header" class="filters_header" on-click="_showFiltersPanel"><span id="filters">ADD FILTERS</span></div> | |
109 | + <div id="filters_header" class="filters_header" on-click="_showFiltersPanel"><span id="filters"><span id="addFilters"></span></span></div> | |
110 | 110 | |
111 | 111 | <div id="filters_panel"> |
112 | 112 | |
... | ... | @@ -116,7 +116,8 @@ |
116 | 116 | <paper-dropdown-menu id="filter_field" label="Field"> |
117 | 117 | <paper-menu id="filter_field_menu" class="dropdown-content"> |
118 | 118 | <template is="dom-repeat" items={{fields}}> |
119 | - <paper-item id={{index}} on-tap="">{{_fieldName(item)}}</paper-item> | |
119 | + <paper-item id={{index}}>{{_fieldName(item)}}</paper-item> | |
120 | + <!--on-tap=""--> | |
120 | 121 | </template> |
121 | 122 | </paper-menu> |
122 | 123 | </paper-dropdown-menu> |
... | ... | @@ -125,7 +126,7 @@ |
125 | 126 | <paper-dropdown-menu id="filter_operation" label="Operation"> |
126 | 127 | <paper-menu id="filter_operation_menu" class="dropdown-content"> |
127 | 128 | <template is="dom-repeat" items={{operations}}> |
128 | - <paper-item id={{index}} on-tap="">{{item}}</paper-item> | |
129 | + <paper-item id={{index}}>{{_getOperationlName(item)}}</paper-item> | |
129 | 130 | </template> |
130 | 131 | </paper-menu> |
131 | 132 | </paper-dropdown-menu> |
... | ... | @@ -187,6 +188,10 @@ |
187 | 188 | $(this.$.filters_panel).perfectScrollbar(); |
188 | 189 | }, |
189 | 190 | |
191 | + attached : function() { | |
192 | + this._translate(); | |
193 | + }, | |
194 | + | |
190 | 195 | setFields : function(fields) { |
191 | 196 | this.fields = this._copy(fields); |
192 | 197 | }, |
... | ... | @@ -195,6 +200,13 @@ |
195 | 200 | return this.filters; |
196 | 201 | }, |
197 | 202 | |
203 | + _translate : function() { | |
204 | + this.$.addFilters.innerHTML = ln["addFilters_" + ln["localization"]]; | |
205 | + this.$.filter_field.setAttribute("label", ln["filterField_" + ln["localization"]]); | |
206 | + this.$.filter_operation.setAttribute("label", ln["filterOperation_" + ln["localization"]]); | |
207 | + this.$.filter_value.setAttribute("label", ln["filterValue_" + ln["localization"]]); | |
208 | + }, | |
209 | + | |
198 | 210 | _fieldName : function(field) { |
199 | 211 | return field.substring(field.lastIndexOf(",")+1, field.length); |
200 | 212 | }, |
... | ... | @@ -215,19 +227,21 @@ |
215 | 227 | }, |
216 | 228 | |
217 | 229 | _addFilter : function() { |
218 | - var field = this.$.filter_field.value; | |
219 | - var operation = this.$.filter_operation.value; | |
220 | - var value = this.$.filter_value.value; | |
230 | + if (this.$.filter_field.selectedItem && this.$.filter_operation_menu.selectedItem && this.$.filter_value.value != "" && !this.$.filter_value.invalid) { | |
231 | + var field = this.$.filter_field.value; | |
232 | + var operation = this.$.filter_operation.value; | |
233 | + var value = this.$.filter_value.value; | |
221 | 234 | |
222 | - var filters = this.filters; | |
223 | - filters.push({"field": field, "operation": operation, "value": value}); | |
224 | - this.filters = this._copy(filters); | |
235 | + var filters = this.filters; | |
236 | + filters.push({"field": field, "operation": operation, "value": value}); | |
237 | + this.filters = this._copy(filters); | |
225 | 238 | |
226 | - this.$.filter_field_menu.select(-1); | |
227 | - this.$.filter_operation_menu.select(-1); | |
228 | - this.$.filter_value.value = ""; | |
239 | + this.$.filter_field_menu.select(-1); | |
240 | + this.$.filter_operation_menu.select(-1); | |
241 | + this.$.filter_value.value = ""; | |
229 | 242 | |
230 | - this.fire('filters-controllet_filters', {filters: this.filters}); | |
243 | + this.fire('filters-controllet_filters', {filters: this.filters}); | |
244 | + } | |
231 | 245 | }, |
232 | 246 | |
233 | 247 | _deleteFilter : function(e) { |
... | ... | @@ -240,6 +254,16 @@ |
240 | 254 | this.fire('filters-controllet_filters', {filters: this.filters}); |
241 | 255 | }, |
242 | 256 | |
257 | + _getOperationlName: function(operation) { | |
258 | + if(operation.indexOf("contains") > -1) | |
259 | + return ln["contains_" + ln["localization"]]; | |
260 | + if(operation.indexOf("start") > -1) | |
261 | + return ln["start_" + ln["localization"]]; | |
262 | + if(operation.indexOf("ends") > -1) | |
263 | + return ln["ends_" + ln["localization"]]; | |
264 | + return operation; | |
265 | + }, | |
266 | + | |
243 | 267 | _copy : function(o) { |
244 | 268 | var out, v, key; |
245 | 269 | out = Array.isArray(o) ? [] : {}; | ... | ... |
controllets/select-data-controllet/demo/index.html
... | ... | @@ -9,14 +9,18 @@ |
9 | 9 | <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> |
10 | 10 | |
11 | 11 | <link rel="import" href="../../select-data-controllet/select-data-controllet.html" /> |
12 | + | |
13 | + <script src="../../../locales/controllet_ln.js"></script> | |
12 | 14 | </head> |
13 | 15 | |
14 | 16 | <body> |
15 | 17 | |
16 | 18 | <!--<select-data-controllet id="tvmt" root-name="data" opened-path="records,geometry" preselected-fields='["nhits", "records,datasetid", "records,recordid"]' data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet>--> |
19 | + <!--<select-data-controllet id="tvmt" root-name="data" data-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%2F10"></select-data-controllet>--> | |
17 | 20 | <select-data-controllet id="tvmt" root-name="data" data-url="http://ckan.routetopa.eu/api/action/datastore_search?resource_id=73e02092-85a1-434e-85fe-0c9a43aa9a52&limit=5"></select-data-controllet> |
18 | 21 | |
19 | 22 | <script> |
23 | + ln["localization"] = "en"; | |
20 | 24 | var tvmt = document.getElementById('tvmt'); |
21 | 25 | |
22 | 26 | tvmt.addEventListener("tree-view-controllet_selected-fields", function (e) { | ... | ... |
locales/controllet_ln.js
... | ... | @@ -28,6 +28,15 @@ ln["dataletPreview_it"] = "ANTEPRIMA"; |
28 | 28 | ln["addDatalet_it"] = "AGGIUNGI"; |
29 | 29 | ln["modifyDatalet_it"] = "MODIFICA"; |
30 | 30 | |
31 | +ln["addFilters_en"] = "ADD FILTERS"; | |
32 | +ln["filterField_en"] = "Field"; | |
33 | +ln["filterOperation_en"] = "Operation"; | |
34 | +ln["filterValue_en"] = "Value"; | |
35 | +ln["contains_en"] = "contains"; | |
36 | +ln["start_en"] = "start"; | |
37 | +ln["ends_en"] = "ends"; | |
38 | + | |
39 | + | |
31 | 40 | ln["datatable_it"] = "tabella"; |
32 | 41 | ln["barchart_it"] = "bar-chart"; |
33 | 42 | ln["columnchart_it"] = "column-chart"; | ... | ... |