Skip to content

Commit

Permalink
Merge branch 'develop' into svg-img-role
Browse files Browse the repository at this point in the history
  • Loading branch information
AmTryingMyBest authored Nov 23, 2020
2 parents 150b4cc + 95e4b03 commit 41794cd
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 12 deletions.
7 changes: 7 additions & 0 deletions app/main/posts/detail/post-value.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ module.exports = ['PostEndpoint', 'moment', '_', function (PostEndpoint, moment,
return PostEndpoint.get({ id : entry });
});
}
// The below fix is to remove trailing decimals
// from the value fetched from the database.
if ($scope.attribute.type === 'decimal') {
$scope.value = $scope.value.map(function (entry) {
return parseFloat(entry);
});
}
if ($scope.attribute.input === 'tags') {
$scope.value = $scope.formatTags($scope.value);
}
Expand Down
3 changes: 2 additions & 1 deletion app/main/posts/modify/post-data-editor.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,8 @@ function PostDataEditorController(
$scope.post.values[attr.key] = [null];
}
} else if (attr.input === 'number') {
$scope.post.values[attr.key] = [parseInt(attr.default)];
// Using parseFloat to handle decimals too.
$scope.post.values[attr.key] = (attr.type === 'int') ? [parseInt(attr.default)] : [parseFloat(attr.default)];
} else if (attr.input === 'date' || attr.input === 'datetime') {
$scope.post.values[attr.key] = attr.default ? [new Date(attr.default)] : [new Date()];
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/main/posts/modify/post-editor.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ function PostEditorController(
$scope.post.values[attr.key] = [null];
}
} else if (attr.input === 'number') {
$scope.post.values[attr.key] = [parseInt(attr.default)];
// Using parseFloat to handle decimals too.
$scope.post.values[attr.key] = (attr.type === 'int') ? [parseInt(attr.default)] : [parseFloat(attr.default)];
} else if (attr.input === 'date' || attr.input === 'datetime') {
$scope.post.values[attr.key] = attr.default ? [new Date(attr.default)] : [new Date()];
} else {
Expand Down
14 changes: 13 additions & 1 deletion app/main/posts/modify/post-editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,19 @@ <h1 class="mode-context-title"><bdi linkify>{{post.form.name}}</bdi></h1>
</div>
</div> -->
<ush-logo></ush-logo>
<div class="toolbar-secondary">
<div class="button-group" ng-show="!post.id">
<post-share button="true" ng-show="!post.id"></post-share>
<button type="submit" class="button-alpha" ng-if="!saving_post">{{submit}}</button>
<button type="submit" class="button-alpha" disabled ng-if="saving_post">{{submitting}}
<div class="loading">
<div class="line"></div>
<div class="line"></div>
<div class="line"></div>
</div>
</button>
</div>
</div>
</div> <!-- END main column -->

</main>
</form>
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" role="img">
<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" role="img">
<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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"socket.io-client": "2.0.3",
"sortablejs": "1.10.0",
"underscore": "^1.7.0",
"ushahidi-platform-pattern-library": "4.4.4-pre.3"
"ushahidi-platform-pattern-library": "4.4.4-pre.4"
},
"engines": {
"node": ">=10.0"
Expand Down

0 comments on commit 41794cd

Please sign in to comment.