Skip to content

Commit

Permalink
Move map settings to tools
Browse files Browse the repository at this point in the history
Summary:
Move map settings
Fix lat lon entry to allow any float

Test Plan: Check you can load and save values

Reviewers: evansims, aMoniker, lkamau, vladimir

Subscribers: rjmackay, vladimir, lkamau, aMoniker

Differential Revision: https://phabricator.ushahidi.com/D825
  • Loading branch information
rjmackay committed May 14, 2015
1 parent 79662cf commit c7dfdbd
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 63 deletions.
1 change: 0 additions & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ angular.module('app',

.controller('navigation', require('./common/controllers/navigation.js'))
.controller('PageMetadata', require('./common/controllers/page-metadata.js'))
.controller('adminMapSettings', require('./common/controllers/admin/map-settings.js'))

.config(require('./common/configs/authentication-interceptor.js'))
.config(require('./common/configs/locale-config.js'))
Expand Down
4 changes: 0 additions & 4 deletions app/common/common-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ module.exports = ['$routeProvider', '$locationProvider', function ($routeProvide
.when('/register', {
controller: require('./controllers/register-controller.js'),
templateUrl: 'templates/register.html'
})
.when('/map-settings', {
controller: require('./controllers/admin/map-settings.js'),
templateUrl: 'templates/admin/map-settings.html'
});
}];
2 changes: 1 addition & 1 deletion app/common/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
"tools" : "Tools"
},
"map_settings" : {
"admin_map_settings" : "Admin: Map Settings"
"admin_map_settings" : "Map Settings"
},
"settings" :{
"site" : "Site Settings",
Expand Down
4 changes: 3 additions & 1 deletion app/common/services/maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ function (
this.getConfig().then(function (config) {
// Set active baselayer
var localLayers = angular.copy(layers);
localLayers.baselayers[config.default_view.baselayer].top = true;
if (localLayers.baselayers[config.default_view.baselayer]) {
localLayers.baselayers[config.default_view.baselayer].top = true;
}
deferred.resolve({
layers: localLayers,
center: {
Expand Down
4 changes: 3 additions & 1 deletion app/post/controllers/post-detail-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ function (
// Add settings to scope
// color, icon and baseLayer have been ignored
var localLayers = angular.copy(layers);
localLayers.baselayers[config.default_view.baselayer].top = true;
if (localLayers.baselayers[config.default_view.baselayer]) {
localLayers.baselayers[config.default_view.baselayer].top = true;
}
angular.extend($scope, {
center: {
lat: config.default_view.lat,
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions app/tool/tool-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function (
controller: require('./controllers/tool-settings-controller.js'),
templateUrl: 'templates/tool/settings.html'
})
.when('/tools/map-settings', {
controller: require('./controllers/tool-map-settings.js'),
templateUrl: 'templates/tool/map-settings.html'
})
.when('/tools/appearance', {
controller: require('./controllers/tool-appearance-controller.js'),
templateUrl: 'templates/tool/todo.html'
Expand Down
55 changes: 0 additions & 55 deletions server/www/templates/admin/map-settings.html

This file was deleted.

1 change: 1 addition & 0 deletions server/www/templates/partials/tool-menu.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<nav class="col-md-3 col-md-pull-9 col-xs-12">
<ul class="nav nav-pills nav-stacked tools-menu">
<li role="presentation" ng-class="{'active': active === 'settings' }"><a ng-href="/tools/settings" translate>nav.settings</a></li>
<li role="presentation" ng-class="{'active': active === 'map-settings' }"><a ng-href="/tools/map-settings" translate>tool.map_settings</a></li>
<!--
<li role="presentation" ng-class="{'active': active === 'appearance' }"><a ng-href="/tools/appearance" translate>nav.appearance</a></li>
<li role="presentation" ng-class="{'active': active === 'plugins' }"><a ng-href="/tools/plugins" translate>nav.plugins</a></li>
Expand Down
69 changes: 69 additions & 0 deletions server/www/templates/tool/map-settings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<div class="row">
<div class="col-md-12">
<ol class="breadcrumb">
<li><a ng-href="/" translate>nav.home</a></li>
<li><a ng-href="/tools" translate>nav.tools</a></li>
<li class="active" translate>tool.map_settings</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-9 col-md-push-3 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="title">{{title}}</h4>
</div>
<div class="panel-body">
<form id="map">
<div class="row">
<div class="col-md-6">
<div class="form-group" ng-if="mapSettingsReady">
<label translate>settings.map_default_location</label>
<leaflet defaults="defaults" tiles="baselayer" markers="markers" center="center" height="300px" width="100%"></leaflet>
</div>
</div>
<div class="col-md-6" ng-if="mapSettingsReady">
<div class="form-group">
<label for="map-settings-base-layer" translate>settings.map_default_baselayer</label>
<select id="map-settings-base-layer" class="form-control" ng-model="map.default_view.baselayer" ng-options="index as layer.name for (index, layer) in baseLayers | orderBy" ng-change="updateMapPreview()"></select>
</div>

<div class="row">
<div class="col-sm-6">
<div class="form-group" ng-class="{'has-error': map.latitude.$valid}">
<label for="map-settings-latitude" translate>settings.map_default_latitude</label>
<input name="latitude" id="map-settings-latitude" type="number" step="any" ng-min="-90" ng-max="90" required class="form-control" ng-model="map.default_view.lat" ng-pattern="patternFloat" ng-change="updateMapPreview()" />
</div>
</div>
<div class="col-sm-6">
<div class="form-group" ng-class="{'has-error': map.longitude.$valid}">
<label for="map-settings-longitude" translate>settings.map_default_longitude</label>
<input name="longitude" id="map-settings-longitude" type="number" step="any" ng-min="-180" ng-max="180" required class="form-control" ng-model="map.default_view.lon" ng-pattern="patternFloat" ng-change="updateMapPreview()" />
</div>
</div>
</div>

<div class="form-group">
<label for="map-settings-zoom" translate>settings.map_default_zoom_level</label>
<input id="map-settings-zoom" type="number" ng-min="minZoom" ng-max="maxZoom" required class="form-control" ng-model="map.default_view.zoom" ng-pattern="onlyNumbers" ng-change="updateMapPreview()" />
</div>

<div class="form-group">
<label><input type="checkbox" ng-model="map.clustering" id="map-settings-clustering" /> <span translate>settings.map_clustering</span></label>
</div>

<p>
<button class="btn btn-primary pull-right flip" ng-click="updateConfig('map', map)"
ng-disabled="form.$invalid || isUnchanged(map) || saving_config['map']">
<i class="fa fa-cog fa-spin" ng-show="saving_config['map']"></i>
<span translate>settings.save</span>
</button>
</p>
</div>
</div>
</form>
</div>
</div>
</div>
<tool-menu active="map-settings"></tool-menu>
</div>

0 comments on commit c7dfdbd

Please sign in to comment.