add color gradient to map visualisaion
authorymh <ymh.work@gmail.com>
Tue, 20 Dec 2016 23:42:18 +0100
changeset 481 002a05cd849f
parent 480 814468b0fc69
child 482 3ea05479ce17
add color gradient to map visualisaion
cms/app-client/app/components/color-gradient.js
cms/app-client/app/components/visu-carto.js
cms/app-client/app/helpers/int-display.js
cms/app-client/app/services/filter.js
cms/app-client/app/styles/app.scss
cms/app-client/app/styles/tabs/carto.scss
cms/app-client/app/templates/components/color-gradient.hbs
cms/app-client/app/templates/components/visu-carto.hbs
cms/app-client/package.json
cms/app-client/tests/unit/helpers/int-display-test.js
cms/package.json
common/corpus-common-addon/package.json
server/bo_client/package.json
server/src/config/version.php
--- a/cms/app-client/app/components/color-gradient.js	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/components/color-gradient.js	Tue Dec 20 23:42:18 2016 +0100
@@ -20,7 +20,7 @@
     }),
 
     domainMed: Ember.computed('domainStart', 'domainEnd', function() {
-        return Math.round((this.get('domainEnd')-this.get('domainStart'))/2);
+        return Math.round((this.get('domainEnd')+this.get('domainStart'))/2);
     }),
 
     colorList: Ember.computed('scale', function() {
--- a/cms/app-client/app/components/visu-carto.js	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/components/visu-carto.js	Tue Dec 20 23:42:18 2016 +0100
@@ -8,6 +8,7 @@
 
   constants: Ember.inject.service(),
   colors: Ember.inject.service(),
+  filter: Ember.inject.service(),
 
   map: null,
 
@@ -20,6 +21,14 @@
 
   dataProvider: {},
 
+  colorScale: Ember.computed('maxCount', 'minCount', function () {
+    let maxCount = this.get('maxCount');
+    let minCount = this.get('minCount');
+    return this.get('colors').getScaleLinear(minCount, maxCount);
+  }),
+  counts: Ember.computed.mapBy('geostats', 'count'),
+  maxCount: Ember.computed.max('counts'),
+  minCount: Ember.computed.min('counts'),
 
   area: null,
   originalZoomLevel: null,
@@ -28,7 +37,6 @@
 
   color: 'rgba(113,132,141,.2)',
 
-  filter: Ember.inject.service(),
   locationObserver: Ember.observer('filter.location', function () {
     if (this.get('filter').get('location') === null) {
       this.sendAction('setLocation', this.get('constants').GEONAMES['world']);
@@ -239,7 +247,11 @@
   },
 
   clickMapObject: function (event) {
-    this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + event.mapObject.id);
+    const changed = this.get('filter').setFilter('location', commonConstants.GEONAMES_BASE_URL + event.mapObject.id);
+    if(!changed) {
+      //force filter change
+      this.notifyPropertyChange('filter.location');
+    }
   },
 
   homeButtonClicked: function () {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/helpers/int-display.js	Tue Dec 20 23:42:18 2016 +0100
@@ -0,0 +1,14 @@
+import Ember from 'ember';
+
+export function intDisplay(params/*, hash*/) {
+  if(!params || params.length === 0) {
+    return Ember.String.htmlSafe('');
+  }
+  const nb = params[0];
+  if(nb === Number.NEGATIVE_INFINITY || Number.isNaN(nb) || nb === Number.POSITIVE_INFINITY ) {
+    return Ember.String.htmlSafe('');
+  }
+  return Ember.String.htmlSafe(`${nb}`);
+}
+
+export default Ember.Helper.helper(intDisplay);
--- a/cms/app-client/app/services/filter.js	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/services/filter.js	Tue Dec 20 23:42:18 2016 +0100
@@ -83,14 +83,16 @@
                     filterValues.push(value);
                     filterValues.sort();
                     this.set(filter, filterValues);
+                    return true;
                 }
-                break;
+                return false;
             case 'language':
             case 'location':
                 if(this.get(filter) !== value) {
                     this.set(filter, value);
+                    return true;
                 }
-                break;
+                return false;
         }
     },
     serializeQueryParam(value/*, urlKey, defaultValueType*/) {
--- a/cms/app-client/app/styles/app.scss	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/styles/app.scss	Tue Dec 20 23:42:18 2016 +0100
@@ -58,6 +58,7 @@
 
     @import 'tabs/chrono';
     @import 'tabs/langues';
+    @import 'tabs/carto';
 }
 
 @import 'components/sorting-component';
@@ -191,9 +192,6 @@
     float: right;
 }
 
-#mapdiv{
-  width: 100%;
-}
 
 
 i.fa {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/styles/tabs/carto.scss	Tue Dec 20 23:42:18 2016 +0100
@@ -0,0 +1,21 @@
+#tabs-carto {
+
+  #mapdiv{
+    width: 100%;
+  }
+
+  .color-gradient-wrapper {
+    position: absolute;
+    width: 100px;
+    top: 1px;
+    right: 5px;
+  }
+
+  .color-gradient-wrapper .color-gradient {
+    position: relative;
+    width: 100%;
+    height: 27px;
+    font-size: 0.75em;
+  }
+
+}
--- a/cms/app-client/app/templates/components/color-gradient.hbs	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/templates/components/color-gradient.hbs	Tue Dec 20 23:42:18 2016 +0100
@@ -1,4 +1,4 @@
 {{#each colorList as |c index|}}<span class="grad-step" style={{color-gradient-style c}}></span>{{/each}}
-<span class="domain-min">{{domainStart}}</span>
-<span class="domain-med">{{domainMed}}</span>
-<span class="domain-max">{{domainEnd}}</span>
\ No newline at end of file
+<span class="domain-min">{{int-display domainStart}}</span>
+<span class="domain-med">{{int-display domainMed}}</span>
+<span class="domain-max">{{int-display domainEnd}}</span>
\ No newline at end of file
--- a/cms/app-client/app/templates/components/visu-carto.hbs	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/app/templates/components/visu-carto.hbs	Tue Dec 20 23:42:18 2016 +0100
@@ -1,1 +1,2 @@
+<div class="color-gradient-wrapper">{{ color-gradient domainStart=minCount domainEnd=maxCount scale=colorScale }}</div>
 <div id="mapdiv"></div>
--- a/cms/app-client/package.json	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/app-client/package.json	Tue Dec 20 23:42:18 2016 +0100
@@ -1,6 +1,6 @@
 {
   "name": "app-client",
-  "version": "0.0.13",
+  "version": "0.0.14",
   "description": "Small description for app-client goes here",
   "license": "MIT",
   "author": "",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/tests/unit/helpers/int-display-test.js	Tue Dec 20 23:42:18 2016 +0100
@@ -0,0 +1,12 @@
+
+import { intDisplay } from 'app-client/helpers/int-display';
+import { module, test } from 'qunit';
+
+module('Unit | Helper | int display');
+
+// Replace this with your real tests.
+test('it works', function(assert) {
+  let result = intDisplay([42]);
+  assert.ok(result);
+});
+
--- a/cms/package.json	Tue Dec 20 18:12:12 2016 +0100
+++ b/cms/package.json	Tue Dec 20 23:42:18 2016 +0100
@@ -1,6 +1,6 @@
 {
   "name": "corpus-cms",
-  "version": "0.0.13",
+  "version": "0.0.14",
   "description": "drupal module to embed the Ember app \"app-client\"",
   "scripts": {
     "build": "npm run build --prefix app-client/ && gulp copy-module",
--- a/common/corpus-common-addon/package.json	Tue Dec 20 18:12:12 2016 +0100
+++ b/common/corpus-common-addon/package.json	Tue Dec 20 23:42:18 2016 +0100
@@ -1,6 +1,6 @@
 {
   "name": "corpus-common-addon",
-  "version": "0.0.13",
+  "version": "0.0.14",
   "description": "Common features between cms and bo.",
   "private": true,
   "keywords": [
--- a/server/bo_client/package.json	Tue Dec 20 18:12:12 2016 +0100
+++ b/server/bo_client/package.json	Tue Dec 20 23:42:18 2016 +0100
@@ -1,6 +1,6 @@
 {
   "name": "bo-client",
-  "version": "0.0.13",
+  "version": "0.0.14",
   "description": "Bo client for Corpus Parole",
   "license": "Ceccil-C",
   "author": "",
--- a/server/src/config/version.php	Tue Dec 20 18:12:12 2016 +0100
+++ b/server/src/config/version.php	Tue Dec 20 23:42:18 2016 +0100
@@ -8,5 +8,5 @@
         | Must be incremented as needed.
         |
         */
-        'version' => '0.0.13'
+        'version' => '0.0.14'
     ];