Bugfixing infoBox and search

pull/108/head
Candid Dauth 2017-05-17 19:33:07 +02:00
rodzic caee2c2ff2
commit 4c09d0168e
7 zmienionych plików z 33 dodań i 19 usunięć

Wyświetl plik

@ -588,6 +588,7 @@ their `idx` property.
* `icon` (string): Symbol key of the result * `icon` (string): Symbol key of the result
* `type` (string): Type of the result * `type` (string): Type of the result
* `id` (string): If the result is an OSM object, the ID of the OSM object, prefixed by `n` (node), `w` (way) or `r` (relation) * `id` (string): If the result is an OSM object, the ID of the OSM object, prefixed by `n` (node), `w` (way) or `r` (relation)
* `ele` (number): Elevation in meters
### route ### route

Wyświetl plik

@ -44,7 +44,7 @@
<div class="btn-group pull-left" uib-dropdown keyboard-nav="true" ng-if="(client.types | fmPropertyCount:{type:'line'}) > 1"> <div class="btn-group pull-left" uib-dropdown keyboard-nav="true" ng-if="(client.types | fmPropertyCount:{type:'line'}) > 1">
<button id="change-type-button" type="button" class="btn btn-default" uib-dropdown-toggle>Change type <span class="caret"></span></button> <button id="change-type-button" type="button" class="btn btn-default" uib-dropdown-toggle>Change type <span class="caret"></span></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="change-type-button" uib-dropdown-menu> <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="change-type-button" uib-dropdown-menu>
<li role="menuitem" ng-repeat="type in client.types | fmObjectFilter:{type:'line'}" ng-class="{active: type.id == line.typeId}"><a href="#" ng-click="line.typeId = type.id">{{type.name}}</a></li> <li role="menuitem" ng-repeat="type in client.types | fmObjectFilter:{type:'line'}" ng-class="{active: type.id == line.typeId}"><a href="javascript:" ng-click="line.typeId = type.id">{{type.name}}</a></li>
</ul> </ul>
</div> </div>

Wyświetl plik

@ -111,6 +111,11 @@ fm.app.factory("fmMapLines", function(fmUtils, $uibModal, $compile, $timeout, $r
}, },
_deleteLine: function(line) { _deleteLine: function(line) {
if(line.id != null && openLine && line.id == openLine.id) { if(line.id != null && openLine && line.id == openLine.id) {
if(openLineHighlight) {
openLineHighlight.remove();
openLineHighlight = null;
}
openLine.hide(); openLine.hide();
openLine = null; openLine = null;
} }
@ -145,9 +150,12 @@ fm.app.factory("fmMapLines", function(fmUtils, $uibModal, $compile, $timeout, $r
openLine = { openLine = {
hide: map.infoBox.show(template, scope, () => { hide: map.infoBox.show(template, scope, () => {
openLine = null; openLine = null;
if(linesById[line.id]) { // Does not exist anymore after line was deleted
linesById[line.id].remove(); linesById[line.id].remove();
linesById[line.id].options.pane = "overlayPane"; linesById[line.id].options.pane = "overlayPane";
linesById[line.id].addTo(map.map); linesById[line.id].addTo(map.map);
}
if(openLineHighlight)
openLineHighlight.remove(); openLineHighlight.remove();
}).hide, }).hide,
id: line.id id: line.id
@ -169,19 +177,21 @@ fm.app.factory("fmMapLines", function(fmUtils, $uibModal, $compile, $timeout, $r
elevationPlot.clear(); elevationPlot.clear();
scope.$watch("line.trackPoints", (trackPoints) => { scope.$watch("line.trackPoints", (trackPoints) => {
let latlngs = []; elevationPlot.clear();
if(line.trackPoints) { if(line.trackPoints) {
let latlngs = [];
for(let i=0; i<line.trackPoints.length; i++) { for(let i=0; i<line.trackPoints.length; i++) {
if(line.trackPoints[i] && line.trackPoints[i].ele != null) if(line.trackPoints[i] && line.trackPoints[i].ele != null)
latlngs.push(Object.assign(new L.latLng(line.trackPoints[i].lat, line.trackPoints[i].lon), { meta: { ele: line.trackPoints[i].ele } })); latlngs.push(Object.assign(new L.latLng(line.trackPoints[i].lat, line.trackPoints[i].lon), { meta: { ele: line.trackPoints[i].ele } }));
} }
}
elevationPlot.addData({ elevationPlot.addData({
_latlngs: latlngs _latlngs: latlngs
}, { }, {
on: () => {} // Otherwise a new event handler gets added every single time we add a line, and is never cleared on: () => {} // Otherwise a new event handler gets added every single time we add a line, and is never cleared
}); });
}
}, true); }, true);
let drawElevationPlot = () => { let drawElevationPlot = () => {
@ -386,7 +396,7 @@ fm.app.factory("fmMapLines", function(fmUtils, $uibModal, $compile, $timeout, $r
// We have to wait until the server sends us the trackPoints of the line // We have to wait until the server sends us the trackPoints of the line
var removeWatcher = $rootScope.$watch(function() { return !!linesById[line.id]; }, function(exists) { var removeWatcher = $rootScope.$watch(function() { return !!linesById[line.id]; }, function(exists) {
if(exists) { if(exists) {
linesUi.showLineInfoBox(line); linesUi.showLineInfoBox(map.client.lines[line.id]);
removeWatcher(); removeWatcher();
} }
}); });

Wyświetl plik

@ -38,7 +38,7 @@
<div class="btn-group pull-left" uib-dropdown keyboard-nav="true" ng-if="(client.types | fmPropertyCount:{type:'marker'}) > 1"> <div class="btn-group pull-left" uib-dropdown keyboard-nav="true" ng-if="(client.types | fmPropertyCount:{type:'marker'}) > 1">
<button id="change-type-button" type="button" class="btn btn-default" uib-dropdown-toggle>Change type <span class="caret"></span></button> <button id="change-type-button" type="button" class="btn btn-default" uib-dropdown-toggle>Change type <span class="caret"></span></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="change-type-button" uib-dropdown-menu> <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="change-type-button" uib-dropdown-menu>
<li role="menuitem" ng-repeat="type in client.types | fmObjectFilter:{type:'marker'}" ng-class="{active: type.id == marker.typeId}"><a href="#" ng-click="marker.typeId = type.id">{{type.name}}</a></li> <li role="menuitem" ng-repeat="type in client.types | fmObjectFilter:{type:'marker'}" ng-class="{active: type.id == marker.typeId}"><a href="javascript:" ng-click="marker.typeId = type.id">{{type.name}}</a></li>
</ul> </ul>
</div> </div>

Wyświetl plik

@ -16,14 +16,14 @@
<div class="buttons"> <div class="buttons">
{{filteredTypes = (result.isMarker && result.isLine ? client.types : (client.types | fmObjectFilter:{type:result.isMarker ? 'marker' : 'line'})); ""}} {{filteredTypes = (result.isMarker && result.isLine ? client.types : (client.types | fmObjectFilter:{type:result.isMarker ? 'marker' : 'line'})); ""}}
<div uib-dropdown keyboard-nav="true" ng-if="!readonly && (filteredTypes | fmPropertyCount) > 1" class="dropup"> <div uib-dropdown keyboard-nav="true" ng-if="!readonly && (filteredTypes | fmPropertyCount) > 1" class="dropup">
<button id="add-type-button" type="button" class="btn btn-default" uib-dropdown-toggle>Add to map <span class="caret"></span></button> <button id="add-type-button" type="button" class="btn btn-default btn-sm" uib-dropdown-toggle>Add to map <span class="caret"></span></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="add-type-button"> <ul class="dropdown-menu" uib-dropdown-menu role="menu" aria-labelledby="add-type-button">
<li role="menuitem" ng-repeat="type in filteredTypes"><a href="javascript:" ng-click="addToMap(type)">{{type.name}}</a></li> <li role="menuitem" ng-repeat="type in filteredTypes"><a href="javascript:" ng-click="addToMap(type)">{{type.name}}</a></li>
</ul> </ul>
</div> </div>
<button type="button" ng-if="!readonly && (filteredTypes | fmPropertyCount) == 1" ng-repeat="type in filteredTypes" class="btn btn-default" ng-click="addToMap(type)">Add to map</button> <button type="button" ng-if="!readonly && (filteredTypes | fmPropertyCount) == 1" ng-repeat="type in filteredTypes" class="btn btn-default btn-sm" ng-click="addToMap(type)">Add to map</button>
<div ng-if="result.isMarker" uib-dropdown keyboard-nav="true" class="dropup"> <div ng-if="result.isMarker" uib-dropdown keyboard-nav="true" class="dropup">
<button type="button" class="btn btn-default" uib-dropdown-toggle>Use as <span class="caret"></span></button> <button type="button" class="btn btn-default btn-sm" uib-dropdown-toggle>Use as <span class="caret"></span></button>
<ul class="dropdown-menu" uib-dropdown-menu role="menu"> <ul class="dropdown-menu" uib-dropdown-menu role="menu">
<li role="menuitem"><a href="javascript:" ng-click="useForRoute(1)">Route start</a></li> <li role="menuitem"><a href="javascript:" ng-click="useForRoute(1)">Route start</a></li>
<li role="menuitem"><a href="javascript:" ng-click="useForRoute(2)">Route via</a></li> <li role="menuitem"><a href="javascript:" ng-click="useForRoute(2)">Route via</a></li>

Wyświetl plik

@ -17,7 +17,7 @@
</form> </form>
<div class="fm-search-results"> <div class="fm-search-results">
<div uib-alert class="alert-danger no-results" ng-if="searchResults.length == 0">No results have been found.</div> <div uib-alert class="alert-danger no-results" ng-if="!searchResults.views.length && searchResults.features.length == 0 && (searchResults.types | fmPropertyCount) == 0">No results have been found.</div>
<div ng-if="searchResults.views.length > 0"> <div ng-if="searchResults.views.length > 0">
<h3>Views</h3> <h3>Views</h3>
<ul class="list-group"> <ul class="list-group">

Wyświetl plik

@ -157,7 +157,10 @@ module.exports = function(Database) {
updateStyle: (createLine) => { updateStyle: (createLine) => {
return this._updateObjectStyles(createLine, true); return this._updateObjectStyles(createLine, true);
} }
}).then(res => res.createLine); }).then((res) => {
this.emit("line", padId, res.setLinePoints); // res.linePoints returns the line with updated ascent and descent
return res.setLinePoints;
});
}, },
updateLine(padId, lineId, data, doNotUpdateStyles) { updateLine(padId, lineId, data, doNotUpdateStyles) {