Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tuxpiper committed Nov 20, 2020
2 parents f5a17cc + 0eec23b commit 95e4b03
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 8 deletions.
9 changes: 5 additions & 4 deletions app/main/posts/views/filters/filter-date.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
<fieldset>
<label translate>global_filter.date_range</label>
<div class="form-field date">
<label for="date" class="hidden" translate="global_filter.filter_tabs.created_after">Start date</label>
<label id="date-after" class="hidden" translate="global_filter.filter_tabs.created_after">Start date</label>
<div class="input-with-icon">
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#calendar"></use>
</svg>
<input id="date" type="date" pick-a-date="dateAfter" pick-a-date-options="options" placeholder="{{ 'global_filter.filter_tabs.created_after' | translate }}" ng-model="dateAfterModel" />
<input type="date" pick-a-date="dateAfter" pick-a-date-options="options" placeholder="{{ 'global_filter.filter_tabs.created_after' | translate }}" ng-model="dateAfterModel" aria-labelledby="date-after" />
</div>

</div>
<span class="date-joiner">to</span>


<div class="form-field date">
<label for="date" class="hidden" translate="global_filter.filter_tabs.created_before">End date</label>
<label id="date-before" class="hidden" translate="global_filter.filter_tabs.created_before">End date</label>
<div class="input-with-icon">
<svg class="iconic">
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/img/iconic-sprite.svg#calendar"></use>
</svg>
<input id="date" type="date" pick-a-date="dateBefore" pick-a-date-options="options" placeholder="{{ 'global_filter.filter_tabs.created_before' | translate }}" ng-model="dateBeforeModel">
<input type="date" pick-a-date="dateBefore" pick-a-date-options="options" placeholder="{{ 'global_filter.filter_tabs.created_before' | translate }}" ng-model="dateBeforeModel" aria-labelledby="date-before">
</div>
</div>

Expand Down
34 changes: 30 additions & 4 deletions app/main/posts/views/post-view-map.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,37 @@ function PostViewMap(PostEndpoint, Maps, _, PostFilters, L, $q, $rootScope, $com

function getStats () {
// Getting stats for filter-dropdown
let def = PostFilters.getQueryParams(PostFilters.getDefaults());
PostEndpoint.geojson(def).$promise.then(res => {
$scope.stats.totalItems = res.features.length;
$scope.stats.unmapped = res.total - res.features.length;
getPostStats(PostFilters.getDefaults()).$promise.then(function (result) {
$scope.stats.totalItems = result.totals[0].values.reduce(
function (a,b) {
return a.total + b.total
}
) - result.unmapped;

$scope.stats.unmapped = result.unmapped;
});
}

function getPostStats(filters) {
var query = PostFilters.getQueryParams(filters);
var queryParams = _.extend({}, query, {
include_unmapped: true,
status: 'all'
});

// we don't want a group_by or filter
if (queryParams.form) {
delete queryParams.form;
}
if (queryParams.group_by) {
delete queryParams.group_by;
}

// deleting source, we want stats for all datasources to keep the datasource-bucket-stats unaffected by data-source-filters
if (queryParams.source) {
delete queryParams.source;
}
return PostEndpoint.stats(queryParams);
}

function loadPosts(query) {
Expand Down

0 comments on commit 95e4b03

Please sign in to comment.