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,7 +106,7 @@ | ||
| 106 | 106 | ||
| 107 | <div id="filters_container"> | 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 | <div id="filters_panel"> | 111 | <div id="filters_panel"> |
| 112 | 112 | ||
| @@ -116,7 +116,8 @@ | @@ -116,7 +116,8 @@ | ||
| 116 | <paper-dropdown-menu id="filter_field" label="Field"> | 116 | <paper-dropdown-menu id="filter_field" label="Field"> |
| 117 | <paper-menu id="filter_field_menu" class="dropdown-content"> | 117 | <paper-menu id="filter_field_menu" class="dropdown-content"> |
| 118 | <template is="dom-repeat" items={{fields}}> | 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 | </template> | 121 | </template> |
| 121 | </paper-menu> | 122 | </paper-menu> |
| 122 | </paper-dropdown-menu> | 123 | </paper-dropdown-menu> |
| @@ -125,7 +126,7 @@ | @@ -125,7 +126,7 @@ | ||
| 125 | <paper-dropdown-menu id="filter_operation" label="Operation"> | 126 | <paper-dropdown-menu id="filter_operation" label="Operation"> |
| 126 | <paper-menu id="filter_operation_menu" class="dropdown-content"> | 127 | <paper-menu id="filter_operation_menu" class="dropdown-content"> |
| 127 | <template is="dom-repeat" items={{operations}}> | 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 | </template> | 130 | </template> |
| 130 | </paper-menu> | 131 | </paper-menu> |
| 131 | </paper-dropdown-menu> | 132 | </paper-dropdown-menu> |
| @@ -187,6 +188,10 @@ | @@ -187,6 +188,10 @@ | ||
| 187 | $(this.$.filters_panel).perfectScrollbar(); | 188 | $(this.$.filters_panel).perfectScrollbar(); |
| 188 | }, | 189 | }, |
| 189 | 190 | ||
| 191 | + attached : function() { | ||
| 192 | + this._translate(); | ||
| 193 | + }, | ||
| 194 | + | ||
| 190 | setFields : function(fields) { | 195 | setFields : function(fields) { |
| 191 | this.fields = this._copy(fields); | 196 | this.fields = this._copy(fields); |
| 192 | }, | 197 | }, |
| @@ -195,6 +200,13 @@ | @@ -195,6 +200,13 @@ | ||
| 195 | return this.filters; | 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 | _fieldName : function(field) { | 210 | _fieldName : function(field) { |
| 199 | return field.substring(field.lastIndexOf(",")+1, field.length); | 211 | return field.substring(field.lastIndexOf(",")+1, field.length); |
| 200 | }, | 212 | }, |
| @@ -215,19 +227,21 @@ | @@ -215,19 +227,21 @@ | ||
| 215 | }, | 227 | }, |
| 216 | 228 | ||
| 217 | _addFilter : function() { | 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 | _deleteFilter : function(e) { | 247 | _deleteFilter : function(e) { |
| @@ -240,6 +254,16 @@ | @@ -240,6 +254,16 @@ | ||
| 240 | this.fire('filters-controllet_filters', {filters: this.filters}); | 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 | _copy : function(o) { | 267 | _copy : function(o) { |
| 244 | var out, v, key; | 268 | var out, v, key; |
| 245 | out = Array.isArray(o) ? [] : {}; | 269 | out = Array.isArray(o) ? [] : {}; |
controllets/select-data-controllet/demo/index.html
| @@ -9,14 +9,18 @@ | @@ -9,14 +9,18 @@ | ||
| 9 | <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> | 9 | <link rel="stylesheet" href="../../shared_js/perfect-scrollbar/css/perfect-scrollbar.min.css"> |
| 10 | 10 | ||
| 11 | <link rel="import" href="../../select-data-controllet/select-data-controllet.html" /> | 11 | <link rel="import" href="../../select-data-controllet/select-data-controllet.html" /> |
| 12 | + | ||
| 13 | + <script src="../../../locales/controllet_ln.js"></script> | ||
| 12 | </head> | 14 | </head> |
| 13 | 15 | ||
| 14 | <body> | 16 | <body> |
| 15 | 17 | ||
| 16 | <!--<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>--> | 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 | <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> | 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 | <script> | 22 | <script> |
| 23 | + ln["localization"] = "en"; | ||
| 20 | var tvmt = document.getElementById('tvmt'); | 24 | var tvmt = document.getElementById('tvmt'); |
| 21 | 25 | ||
| 22 | tvmt.addEventListener("tree-view-controllet_selected-fields", function (e) { | 26 | tvmt.addEventListener("tree-view-controllet_selected-fields", function (e) { |
locales/controllet_ln.js
| @@ -28,6 +28,15 @@ ln["dataletPreview_it"] = "ANTEPRIMA"; | @@ -28,6 +28,15 @@ ln["dataletPreview_it"] = "ANTEPRIMA"; | ||
| 28 | ln["addDatalet_it"] = "AGGIUNGI"; | 28 | ln["addDatalet_it"] = "AGGIUNGI"; |
| 29 | ln["modifyDatalet_it"] = "MODIFICA"; | 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 | ln["datatable_it"] = "tabella"; | 40 | ln["datatable_it"] = "tabella"; |
| 32 | ln["barchart_it"] = "bar-chart"; | 41 | ln["barchart_it"] = "bar-chart"; |
| 33 | ln["columnchart_it"] = "column-chart"; | 42 | ln["columnchart_it"] = "column-chart"; |