Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

Commit

Permalink
on develp
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Oct 6, 2015
1 parent c28afc9 commit 62ea2e1
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ define([
},


/**
* Triggered from 'Place/Go' events.
*
* @param {Object} place PlaceService's place object
*/
/**
* Triggered from 'Place/Go' events.
*
* @param {Object} place PlaceService's place object
*/
_onPlaceGo: function(place) {
this.view.start(place);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ define([

init: function(view) {
this.view = view;
this._super();
this.model = model;
this._super();

mps.publish('Place/register', [this]);
},
Expand Down Expand Up @@ -53,14 +53,6 @@ define([
// }
// }],

/**
* Trigger the selected display option
* @param {[string]} display
* Add below events publication
*/




/**
* Triggered from 'Place/Go' events.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
define([
'mps',
'countries/presenters/PresenterClass'
], function(mps, PresenterClass) {

'use strict';

var globalWidgetStatus = {};

var WidgetPresenter = PresenterClass.extend({

status: new (Backbone.Model.extend({
defaults: {
average: null,
id: null,
indicator: 1,
treshold: 30
}
})),

init: function(view) {
this.view = view;
this._super();

this.status.set('id', view.wid);

mps.publish('Place/register', [this]);
},

/**
* Application subscriptions.
*/
_subscriptions: [{
'Place/go': function(place) {
this._onPlaceGo(place);
}
}],

/**
* Used by PlaceService to get the current iso/area params.
*
* @return {object} iso/area params
*/
getPlaceParams: function() {
var p = {};

p.widgetStatus = {
average: this.status.attributes.average,
id: this.status.attributes.id,
indicator: this.status.attributes.indicator,
treshold: this.status.attributes.treshold
};

console.log(p);

return p;
},

/**
* Triggered from 'Place/Go' events.
*
* @param {Object} place PlaceService's place object
*/
_onPlaceGo: function(place) {
this.view.start(place);
},

onUpdateIndicator: function(status) {
this.status.set(status);
},

updateStatus: function(status) {
this.onUpdateIndicator(status);
mps.publish('Place/update');
}

});

return WidgetPresenter;

});
6 changes: 5 additions & 1 deletion app/assets/javascripts/countries/services/PlaceService.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ define([
params = this._destandardizeParams(
this._getPresenterParams(this._presenters));

console.log(params);

route = this._getRoute(params);
this.router.navigate(route, {silent: true});
},
Expand Down Expand Up @@ -165,10 +167,12 @@ define([

var localOptions = {
view : p.view ? p.view : null,
widgets: p.widgets ? p.widgets : null,
widgets: p.widgetStatus ? p.widgetStatus : null,
treshold: p.treshold ? p.treshold : null
};

console.log(localOptions);

p.options = btoa(JSON.stringify(localOptions));

console.log(p);
Expand Down
18 changes: 15 additions & 3 deletions app/assets/javascripts/views/WidgetView.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ define([
'backbone',
'handlebars',
'countries/models/CountryModel',
'countries/presenters/show/WidgetPresenter',
'countries/collections/widgetCollection',
'countries/views/indicators/LineChartIndicator',
'countries/views/indicators/MapIndicator',
'countries/views/indicators/PieChartIndicator',
'text!countries/templates/country-widget.handlebars'
], function(Backbone, Handlebars, CountryModel, widgetCollection, LineChartIndicator,
], function(Backbone, Handlebars, CountryModel, WidgetPresenter, widgetCollection, LineChartIndicator,
MapIndicator, PieChartIndicator, tpl) {

'use strict';
Expand All @@ -22,12 +23,23 @@ define([
'click .close' : '_close',
'click #info' : '_info',
'click #share' : '_share',
'click .indicators-grid__item': '_setCurrentIndicator'
'click .indicators-grid__item': '_setCurrentIndicator',
'change .selector': 'updateTreshold'
},

initialize: function(data) {
this.model = CountryModel;
this.wid = data.wid;
this.presenter = new WidgetPresenter(this);


this.model = CountryModel;
},

updateTreshold: function(e) {
var treshold = e.currentTarget.value;
this.presenter.updateStatus({
treshold: treshold
});
},

_setCurrentIndicator: function(e) {
Expand Down

0 comments on commit 62ea2e1

Please sign in to comment.