diff --git a/controllets/data-sevc-controllet/co-datalets-creator-controllet.html b/controllets/data-sevc-controllet/co-datalets-creator-controllet.html index 5cc885d..2f4e29e 100755 --- a/controllets/data-sevc-controllet/co-datalets-creator-controllet.html +++ b/controllets/data-sevc-controllet/co-datalets-creator-controllet.html @@ -18,7 +18,7 @@ <neon-animatable> - <select-data-controllet id="select_data" data-url={{dataUrl}} data={{data}}></select-data-controllet> + <select-data-controllet id="select_data"></select-data-controllet> </neon-animatable> @@ -76,6 +76,7 @@ ready : function(){ ln["localization"] = this.localization; + this.$.select_data.data = this.data; this.$.select_data.dataUrl = this.dataUrl; this.$.select_data.init(); this.$.select_visualization.dataUrl = this.dataUrl; diff --git a/controllets/data-sevc-controllet/datalets-modifier-controllet.html b/controllets/data-sevc-controllet/datalets-modifier-controllet.html index 3904831..86caf36 100755 --- a/controllets/data-sevc-controllet/datalets-modifier-controllet.html +++ b/controllets/data-sevc-controllet/datalets-modifier-controllet.html @@ -10,7 +10,7 @@ <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"> +<dom-module id="datalets-modifier-controllet"> <template> @@ -36,7 +36,7 @@ Polymer({ - is : 'data-sevc-controllet', + is : 'datalets-modifier-controllet', listeners : { 'page-slider-controllet_selected' : '_updateSlider', diff --git a/controllets/datalets-modifier-controllet/datalets-modifier-controllet.html b/controllets/datalets-modifier-controllet/datalets-modifier-controllet.html new file mode 100755 index 0000000..5a162bc --- /dev/null +++ b/controllets/datalets-modifier-controllet/datalets-modifier-controllet.html @@ -0,0 +1,140 @@ +<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-data-controllet/select-data-controllet.html" /> +<link rel="import" href="../select-visualization-controllet/select-visualization-controllet.html" /> + +<dom-module id="datalets-modifier-controllet"> + + <template> + + <page-slider-controllet id="slider"> + + <neon-animatable> + + <select-data-controllet id="select_data"></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 : 'datalets-modifier-controllet', + + listeners : { + 'page-slider-controllet_selected' : '_updateSlider', + 'select-fields-controllet_selected-fields' : '_allowThirdStep', + 'filters-controllet_filters': '_allowThirdStep', + 'data-ready': '_preselect' + }, + + properties : { + + dataUrl : { + type : String, + value : undefined + }, + + deepUrl : { + type : String, + value : undefined + }, + + dataletsListUrl : { + type : String , + value : undefined + }, + + selectedDatalet : { + type : String, + value : undefined + }, + + selectedFields : { + type : Array, + value : [] + }, + + dataletPreset : { + type : Object, + value : [] + }, + + localization : { + type : String, + value : "en" + } + + }, + + ready : function(){ + ln["localization"] = this.localization; + + this.$.select_data.dataUrl = this.dataletPreset["data-url"]; + this.$.select_data.init(); + this.$.select_visualization.dataUrl = this.dataletPreset["data-url"]; + this.$.select_visualization.init(); + }, + + _preselect : function(){ + this.$.select_data.setSelectedFields(this.selectedFields); + this.$.select_data.setFilters(JSON.parse(this.dataletPreset["filters"])); + }, + + _updateSlider : function(e){ + switch (e.detail.selected) { + case 0: + this.$.slider.setTitle(ln["slide2Title_" + this.localization], ln["slide2Subtitle_" + this.localization]); + + this.$.slider.chevronLeft("invisible"); + this.$.slider.chevronRight(false); + + if(this.$.slider.getPrevSelected() == 1) + this.$.slider.chevronRight(true); + break; + case 1: + this.$.slider.setTitle(ln["slide3Title_" + this.localization], ln["slide3Subtitle_" + this.localization]); + + this.$.slider.chevronLeft(true); + this.$.slider.chevronRight("invisible"); + + /**/this.$.select_visualization.show();//resize + } + }, + + _allowThirdStep : function(){ + this.$.slider.chevronRight(false); + var fields = this.$.select_data.getSelectedFields(); + var filters = this.$.select_data.getFilters(); + var data = this.$.select_data.getData(); + if(fields.length > 0) { + this.$.select_visualization.init(); + this.$.select_visualization.setFields(fields); + this.$.select_visualization.setFilters(filters); + this.$.select_visualization.setData(data); + this.$.slider.chevronRight(true); + } + } + + }); + + </script> + +</dom-module> \ No newline at end of file diff --git a/controllets/providers-utility-controllet/providers-utility-controllet.html b/controllets/providers-utility-controllet/providers-utility-controllet.html index 6fc868f..cf8f705 100644 --- a/controllets/providers-utility-controllet/providers-utility-controllet.html +++ b/controllets/providers-utility-controllet/providers-utility-controllet.html @@ -22,12 +22,21 @@ }; utility_getSelectedFields = function(fields, indices) { - selectedFileds = []; + var selectedFileds = []; for (var i = 0; i < indices.length; i++) selectedFileds.push(fields[indices[i]]); return selectedFileds; }; + utility_getSelectedIndices = function(fields, selectedFileds) { + console.log("we"); + var selectedIndices = []; + for (var i = 0; i < fields.length; i++) + if($.inArray(fields[i], selectedFileds) > -1) + selectedIndices.push(i); + return selectedIndices; + }; + // utility_getResourceUrl = function(url) { // //CKAN // var strDatasetPos = url.indexOf('/dataset/'); diff --git a/controllets/select-data-controllet/select-data-controllet.html b/controllets/select-data-controllet/select-data-controllet.html index 2eef6ba..02c9048 100755 --- a/controllets/select-data-controllet/select-data-controllet.html +++ b/controllets/select-data-controllet/select-data-controllet.html @@ -133,6 +133,21 @@ return this.data; }, + setSelectedFields : function(selectedFields) { + this.async(function() { + var selectedIndices = utility_getSelectedIndices(this.fields, selectedFields); + + console.log(selectedIndices); + this.$.select_fields.setSelectFields(selectedIndices); + }, 0); + }, + + setFilters : function(filters) { + this.async(function() { + this.$.filters.setFilters(filters); + }, 0); + }, + _resizeFilters : function() { if(!this.showFilter) { this.$.table_container.style.height = "calc(50% - 12px)"; @@ -186,9 +201,8 @@ that.$.select_fields.setFields(that.fields); that.$.filters.setFields(that.fields); -// that.$.data_table.setData(data); - that._preselect(); + that.fire('data-ready'); } }); } @@ -205,15 +219,10 @@ this.$.select_fields.setFields(this.fields); this.$.filters.setFields(this.fields); -// this.$.data_table.setData(data); - - this._preselect(); } }, reset : function() { -// this.dataUrl = undefined; -// this.data = undefined; this.filters = []; this.selectedFields = []; this.$.select_fields.reset(); @@ -221,15 +230,6 @@ this.$.filters.reset(); }, - _preselect : function() { - this.async(function() { - if(this.filters.length > 1) - this.$.filters.setFilters(this.filters); - if(this.selectedFields.length > 0) - this.$.select_fields.setSelectFields(this.selectedFields); - }, 0); - }, - _resize : function(){ var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0) - 16; h = h - 64 - 8; //height with page scroller + margin-top diff --git a/controllets/select-dataset-controllet/ortelio-controllet.html b/controllets/select-dataset-controllet/ortelio-controllet.html index 8bb28d6..3c27103 100755 --- a/controllets/select-dataset-controllet/ortelio-controllet.html +++ b/controllets/select-dataset-controllet/ortelio-controllet.html @@ -506,15 +506,15 @@ var url = this.$.list.selectedItem.resource_url; -// // Check if CKAN -// var strDatasetPos = url.indexOf('/dataset/'); -// var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; -// if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { -// var urlSegment1 = url.substring(0, strDatasetPos); -// var urlResourceEnd = url.indexOf('/', strResourcePos + 10); -// var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); -// url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; -// } + // Check if CKAN + var strDatasetPos = url.indexOf('/dataset/'); + var strResourcePos = (strDatasetPos >= 0) ? url.indexOf('/resource/') : -1; + if (strDatasetPos >= 0 && strResourcePos > strDatasetPos) { + var urlSegment1 = url.substring(0, strDatasetPos); + var urlResourceEnd = url.indexOf('/', strResourcePos + 10); + var resourceId = url.substring(strResourcePos + 10, urlResourceEnd); + url = urlSegment1 + "/api/action/datastore_search?resource_id=" + resourceId; + } // // // Check if OPENDATASOFT // var strExploreDatasetPos = url.indexOf('/explore/dataset/');