Permalink
Browse files

Refactoring Ward to Area in the code

  • Loading branch information...
1 parent cb9a49c commit 641b67aa9b5d5a3b5be2acc6b1d60f278a6b5363 @Mr0grog Mr0grog committed Apr 19, 2012
Showing with 19 additions and 13 deletions.
  1. +2 −2 index.html
  2. +8 −2 js/DailyBriefingController.js
  3. +6 −6 js/FilterBarController.js
  4. +3 −3 js/MapController.js
View
@@ -47,10 +47,10 @@
<span class="endcap"></span>
</p>
<ul>
- <!-- <li>Ward: <select id="filters_ward"><option value="">All</option></select></li> -->
+ <!-- <li>Ward: <select id="filters_area"><option value="">All</option></select></li> -->
<!-- <li>Service: <select id="filters_service"><option value="">All</option></select></li> -->
<!-- <li>Status: <select id="filters_status"><option value="">All</option></select></li> -->
- <li><span id="boundaryTitle">Ward</span>: <span id="filters_ward"></span></li>
+ <li><span id="boundaryTitle">Ward</span>: <span id="filters_area"></span></li>
<li>Service: <span id="filters_service"></span></li>
<li>Status: <span id="filters_status"></span></li>
</ul>
@@ -1,7 +1,7 @@
var DailyBriefingController = function () {
// default filters
this.filterConditions = {
- ward: null, // null means the whole city
+ area: null, // null means the whole city
states: ["open", "opened", "closed"],
services: null, // null means all services
dateRange: {
@@ -99,6 +99,12 @@ var DailyBriefingController = function () {
DailyBriefingController.prototype = {
constructor: DailyBriefingController,
+ updateFilters: function (newFilters) {
+
+
+ this.filterConditions = event.data;
+ },
+
_refreshData: function () {
console.log("_refreshData called: open requests count = " +
this.requests['open'].length);
@@ -114,7 +120,7 @@ DailyBriefingController.prototype = {
if (event.type === "filtersChanged") {
// alert(JSON.stringify(event.data));
// TODO: should really copy event.data here
- this.filterConditions = event.data;
+ this.updateFilters(event.data);
this._refreshData();
}
},
View
@@ -5,11 +5,11 @@ var FilterBarController = function (appController) {
$('#boundaryTitle').html(Config.boundaryTitle);
this.element = document.getElementById("filters");
- // this.wardSelector = document.getElementById("filters_ward");
+ // this.areaSelector = document.getElementById("filters_area");
// this.serviceSelector = document.getElementById("filters_service");
// this.statusSelector = document.getElementById("filters_status");
this.statusSelector = new MultiSelector(document.getElementById("filters_status"));
- this.wardSelector = new MultiSelector(document.getElementById("filters_ward"));
+ this.areaSelector = new MultiSelector(document.getElementById("filters_area"));
this.serviceSelector = new MultiSelector(document.getElementById("filters_service"));
this.applyButton = document.getElementById("filters_apply");
@@ -41,13 +41,13 @@ FilterBarController.prototype = {
// need a public way to update the filters so that they can get populated with
// data after the API callback returns
updateFilters: function() {
- // this._setSelectOptions(this.wardSelector, this.app.areas.map(function (area) {
+ // this._setSelectOptions(this.areaSelector, this.app.areas.map(function (area) {
// return {name: area.name};
// }));
- this.wardSelector.setOptions(this.app.areas.map(function (area) {
+ this.areaSelector.setOptions(this.app.areas.map(function (area) {
return {name: area.name};
}));
- this.wardSelector.setValue(null);
+ this.areaSelector.setValue(null);
// this._setSelectOptions(this.serviceSelector, this.app.services.map(function (service) {
// return {
// name: service.service_name,
@@ -82,7 +82,7 @@ FilterBarController.prototype = {
// TODO: should have something around default values
var filters = {
- ward: this.wardSelector.value || null,
+ area: this.areaSelector.value || null,
services: selectedService ? selectedService : null,
states: selectedState ? selectedState : ["open", "opened", "closed"],
dateRange: this.app.filterConditions.dateRange
View
@@ -2,7 +2,7 @@ var MapController = function () {
this.dataSource = null;
this._initializeMap();
- this.selectedWard = null; // Save the state of the ward selector so we don't move the map unnecessarily
+ this.selectedArea = null; // Save the state of the ward selector so we don't move the map unnecessarily
// TODO: the initial position should be the center of the markers or set by configuration
this.defaultView = {
@@ -119,8 +119,8 @@ MapController.prototype = {
updateMapCenterZoom: function() {
// Only move/zoom the map if the ward changes
- if (this.dataSource.filterConditions.ward !== this.selectedWard) {
- if (this.dataSource.filterConditions.ward == null) {
+ if (this.dataSource.filterConditions.area !== this.selectedArea) {
+ if (this.dataSource.filterConditions.area == null) {
// if ward == null, then entire city... so use out defaults
this.map.setView(new L.LatLng(this.defaultView.center[0], this.defaultView.center[1]), this.defaultView.zoom);
}

0 comments on commit 641b67a

Please sign in to comment.