Skip to content

Commit 49aa254

Browse files
authored
Merge branch 'develop' into redasterisk
2 parents 5d05748 + 78c255d commit 49aa254

File tree

11 files changed

+61
-31
lines changed

11 files changed

+61
-31
lines changed

app/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ angular.module('app',
138138
// Load leaflet plugins here too
139139
require('imports-loader?L=leaflet!leaflet.markercluster');
140140
require('imports-loader?L=leaflet!leaflet.locatecontrol/src/L.Control.Locate');
141+
require('imports-loader?L=leaflet!leaflet-easybutton');
141142
return L;
142143
})
143144
.factory('moment', function () {

app/common/services/maps.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ function Maps(ConfigEndpoint, L, _, CONST) {
3939
pointToLayer: pointToLayer,
4040
getConfig: getConfig,
4141
getLayer: getLayer,
42-
pointIcon: pointIcon
42+
pointIcon: pointIcon,
43+
defaultConfig: defaultConfig
4344
};
4445

4546
function createMap(element) {
4647
return getLeafletConfig().then(function (config) {
4748
var map = L.map(element, config);
48-
4949
map.attributionControl.setPrefix(false);
5050
map.zoomControl.setPosition('bottomleft');
5151
map.setMaxBounds([[-90,-360],[90,360]]);
@@ -58,6 +58,25 @@ function Maps(ConfigEndpoint, L, _, CONST) {
5858

5959
// Add a layer control
6060
// L.control.layers(getBaseLayersForControl(), {}).addTo(map);
61+
var iconicSprite = require('ushahidi-platform-pattern-library/assets/img/iconic-sprite.svg');
62+
var resetButton = L.easyButton({
63+
id: 'reset-button',
64+
position: 'bottomleft',
65+
type: 'replace',
66+
leafletClasses: true,
67+
states:[{
68+
// specify different icons and responses for your button
69+
stateName: 'reset-button',
70+
onClick: function() {
71+
var defaultview = defaultValues(config);
72+
map.setView([defaultview.lat, defaultview.lon], defaultview.zoom);
73+
},
74+
title: 'Reset to default view',
75+
icon: '<svg class="iconic" style="fill:black;"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="' + iconicSprite + '#home"></use></svg>'
76+
}]
77+
});
78+
79+
resetButton.addTo(map);
6180

6281
return map;
6382
});
@@ -112,9 +131,9 @@ function Maps(ConfigEndpoint, L, _, CONST) {
112131

113132
function defaultConfig() {
114133
return {
115-
scrollWheelZoom: false,
134+
scrollWheelZoom: true,
116135
center: [-1.2833, 36.8167], // Default to centered on Nairobi
117-
zoom: 8,
136+
zoom: 3,
118137
layers: [L.tileLayer(layers.baselayers.streets.url, layers.baselayers.streets.layerOptions)]
119138
};
120139
}
@@ -124,7 +143,6 @@ function Maps(ConfigEndpoint, L, _, CONST) {
124143
icon: pointIcon(feature.properties['marker-color'])
125144
});
126145
}
127-
128146
// Icon configuration
129147
function pointIcon(color, size, className) {
130148
// Test string to make sure that it does not contain injection
@@ -140,4 +158,14 @@ function Maps(ConfigEndpoint, L, _, CONST) {
140158
popupAnchor: [0, 0 - size[1]]
141159
});
142160
}
161+
162+
// default view is centered on nairobi
163+
function defaultValues(config) {
164+
return {
165+
lat: config.center[0],
166+
lon: config.center[1],
167+
zoom: config.zoom
168+
}
169+
}
170+
143171
}

app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<meta name="apple-itunes-app" content="app-id={{appStoreId}}, app-argument={{currentFullUrl}}>">
1515

1616
<link rel="manifest" href="/manifest.json">
17-
17+
1818
<base href="/">
1919
</head>
2020
<!-- TODO: set layouts per view directive -->

app/main/posts/common/post-actions.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ function PostActionsDirective(
4141
$scope.statuses = PostActionsService.getStatuses();
4242
}
4343

44+
// Called when a single data item is deleted.
4445
function deletePost() {
4546
PostActionsService.delete($scope.post).then(function () {
4647
$rootScope.$broadcast('event:edit:post:status:data:mode:saveSuccess', {post: $scope.post, deleted: true});
@@ -52,7 +53,6 @@ function PostActionsDirective(
5253
// only map needs to reload
5354
$state.reload();
5455
}
55-
5656
});
5757
}
5858

app/main/posts/detail/map.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
<div class="postcard-field" ng-style="{'visibility': hideMap ? 'hidden' : 'visible'}" ng-hide="emptyGeoJSON">
23
<h2 class="form-label" translate>post.location</h2>
34
<div id="post-map" class="map"></div>

app/main/posts/modify/post-editor.html

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,23 +102,6 @@ <h1 class="mode-context-title"><bdi>{{post.form.name}}</bdi></h1>
102102
</div>
103103
</div>
104104
</div> -->
105-
<div class="form-sheet" ng-if="post.id">
106-
<div class="form-sheet-summary">
107-
<h3 class="form-sheet-title" translate="post.delete_post">Delete this post</h3>
108-
</div>
109-
110-
<div class="form-field">
111-
<p translate="post.delete_post_desc"><strong>If you delete this post</strong>, all of its comments and messages will also be deleted. Proceed with caution.</p>
112-
113-
<button class="button-destructive" ng-click="deletePost(post)">
114-
<svg class="iconic">
115-
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#trash"></use>
116-
</svg>
117-
<span class="button-label" translate="post.delete_post">Delete post</span>
118-
</button>
119-
</div>
120-
</div>
121-
122105
<ush-logo></ush-logo>
123106
</div> <!-- END main column -->
124107

app/main/posts/views/post-view-data.directive.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ function PostViewDataController(
181181
);
182182

183183
$scope.$on('event:edit:leave:form:complete', function () {
184-
// Bercause there is no state management
184+
// Because there is no state management
185185
// We copy the next Post to be the current Post
186186
// if the previous Post exited correctly
187187
// Ideally Post Card would become a service more akin
@@ -255,9 +255,11 @@ function PostViewDataController(
255255
function removePostFromList(postObj) {
256256
$scope.posts.forEach((post, index) => {
257257
// args.post is the post being updated/saved and sent from the broadcast
258+
// since a single post is being deleted here, reduce count of totalitems by 1.
258259
if (post.id === postObj.id) {
259260
let nextInLine = $scope.posts[index + 1];
260261
$scope.posts.splice(index, 1);
262+
$scope.totalItems = $scope.totalItems - 1;
261263
if ($scope.posts.length) {
262264
groupPosts($scope.posts);
263265
if ($scope.selectedPost.post) {
@@ -329,7 +331,6 @@ function PostViewDataController(
329331
PostEndpoint.query(postQuery).$promise.then(function (postsResponse) {
330332
//Clear posts
331333
clearPosts ? resetPosts() : null;
332-
333334
// If we're loading posts for the first time and we have a selected post (post detail view)
334335
// check to see that the selected post isn't in the list
335336
// and then deselect it and select the first item
@@ -360,6 +361,7 @@ function PostViewDataController(
360361
});
361362
}
362363

364+
// this function is called when multiple data items are deleted
363365
function deletePosts() {
364366
Notify.confirmDelete('notify.post.bulk_destroy_confirm', { count: $scope.selectedPosts.length }).then(function () {
365367
// ask server to delete selected posts

app/settings/site/map.directive.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ function (
3232
$scope.updateMapPreviewLayer = updateMapPreviewLayer;
3333
$scope.current_precision = 9;
3434
$scope.locationPrecisionEnabled = false;
35+
$scope.handleClick = handleClick;
3536

3637
activate();
3738

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"karma-coverage": "^2.0.1",
6565
"karma-firefox-launcher": "^1.2.0",
6666
"karma-fixture": "^0.2.6",
67-
"karma-jasmine": "^2.0.1",
67+
"karma-jasmine": "^3.1.1",
6868
"karma-json-fixtures-preprocessor": "0.0.6",
6969
"karma-notify-reporter": "^1.2.0",
7070
"karma-phantomjs-launcher": "^1.0.4",
@@ -85,7 +85,7 @@
8585
"sass-loader": "^8.0.0",
8686
"style-loader": "^1.1.2",
8787
"supports-color": "^3.1.2",
88-
"svg-url-loader": "^3.0.3",
88+
"svg-url-loader": "^4.0.0",
8989
"transifex": "^1.6.6",
9090
"uglifyjs-webpack-plugin": "^2.2.0",
9191
"url-loader": "^3.0.0",
@@ -112,8 +112,9 @@
112112
"angular-ui-bootstrap": "^2.5.0",
113113
"checklist-model": "~0.11.0",
114114
"d3": "^3.5.17",
115-
"leaflet": "~1.0.1",
116-
"leaflet.locatecontrol": "^0.62.0",
115+
"leaflet.locatecontrol": "^0.70.0",
116+
"leaflet": "^1.6.0",
117+
"leaflet-easybutton": "^2.4.0",
117118
"leaflet.markercluster": "1.0.5",
118119
"libphonenumber-js": "^1.0.24",
119120
"moment": "2.19.3",

sass/overrides/_leaflet.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ input.leaflet-control-layers-selector {
6565
.leaflet-map-pane svg.iconic {
6666
position: initial;
6767
}
68+
69+
// Override styles for reset button
70+
#reset-button {
71+
background-color: white;
72+
height: 30px;
73+
width: 27px;
74+
padding: 8px 8px;
75+
margin-right: 0px;
76+
margin-bottom: 0px;
77+
}

0 commit comments

Comments
 (0)