Add the possibility to import views and types (#10)

pull/108/head
Candid Dauth 2017-03-06 16:01:58 +01:00
rodzic 939973603b
commit f7a20ec7a8
2 zmienionych plików z 36 dodań i 1 usunięć

Wyświetl plik

@ -24,16 +24,27 @@
<li ng-repeat="view in searchResults.views" class="list-group-item">
<a href="javascript:" ng-click="showView(view)">{{view.name}}</a>
<span class="result-type">(View)</span>
<a href="javascript:" ng-if="!viewExists(view)" ng-click="addView(view)" class="pull-right" uib-tooltip="Add this view to the map" tooltip-append-to-body="true"><span class="glyphicon glyphicon-plus"></span></a>
</li>
</ul>
</div>
<h3 ng-if="searchResults.views.length > 0">Markers/Lines</h3>
<h3 ng-if="searchResults.views.length > 0 || (searchResults.types | fmPropertyCount) > 0">Markers/Lines</h3>
<ul class="list-group" ng-if="searchResults.features.length > 0">
<li ng-repeat="result in searchResults.features" class="list-group-item" ng-class="{active: activeResult === result}">
<a href="javascript:" ng-click="showResult(result)">{{result.display_name}}</a>
<span class="result-type" ng-if="result.type">({{result.type}})</span>
</li>
</ul>
<div ng-if="(searchResults.types | fmPropertyCount) > 0">
<h3>Types</h3>
<ul class="list-group">
<li ng-repeat="type in searchResults.types" class="list-group-item">
{{type.name}}
<span class="result-type">(Type)</span>
<a href="javascript:" ng-if="!typeExists(type)" ng-click="addType(type)" class="pull-right" uib-tooltip="Add this type to the map" tooltip-append-to-body="true"><span class="glyphicon glyphicon-plus"></span></a>
</li>
</ul>
</div>
</div>
<div class="fm-search-buttons" ng-show="searchResults.features.length > 0">

Wyświetl plik

@ -130,6 +130,30 @@ fm.app.factory("fmMapSearch", function($rootScope, $compile, fmUtils, $timeout,
map.displayView(view);
};
scope.viewExists = function(view) {
for(let viewId in map.socket.views) {
if(["name", "baseLayer", "layers", "top", "bottom", "left", "right", "filter"].filter((idx) => !ng.equals(view[idx], map.socket.views[viewId][idx])).length == 0)
return true;
}
return false;
};
scope.addView = function(view) {
map.socket.addView(view);
};
scope.typeExists = function(type) {
for(let typeId in map.socket.types) {
if(["name", "type", "defaultColour", "colourFixed", "defaultSize", "sizeFixed", "defaultSymbol", "symbolFixed", "defaultWidth", "widthFixed", "defaultMode", "modeFixed", "fields"].filter((idx) => !ng.equals(type[idx], map.socket.types[typeId][idx])).length == 0)
return true;
}
return false;
};
scope.addType = function(type) {
map.socket.addType(type);
};
scope.addResultToMap = function(result, type, noEdit) {
importUi.addResultToMap(result, type, !noEdit);
};