Skip to content

Commit

Permalink
Merge branch 'develop' into dismiss-notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
AmTryingMyBest authored Apr 25, 2022
2 parents 322731b + 795bdac commit 38be241
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,33 @@ function PostValueEditController($rootScope, $scope, _, Flatpickr, SurveysSdk) {
function activate() {
addDefaultValue();
if (isDate($scope.attribute) || isDateTime($scope.attribute)) {

$scope.$watch('attribute.value.value', (newValue, oldValue) => {
if (newValue && newValue !== oldValue) {
let addTimezone = false;
// if the post is being created and is requred.
if ($scope.attribute.required && !$scope.attribute.value.value_meta) {
addTimezone = true;
}

// if the post is being created and has a default value.
if ($scope.attribute.default && !$scope.attribute.value.value_meta) {
addTimezone = true;
}

/* When adding a new value or editing an old. We only want to add/change the timezone if
* the value is changed. Converting to timestamp to ensure comparing the same thing */
if (newValue && new Date(newValue).valueOf() !== new Date(oldValue).valueOf()) {
addTimezone = true;
}

if (addTimezone) {
$scope.attribute.value.value_meta = {
from_tz:Intl.DateTimeFormat().resolvedOptions().timeZone
};
} else if (oldValue && newValue === '') {
// Removing timezone if the value is deleted
}

// Removing timezone if the value is deleted
if (oldValue && newValue === '') {
$scope.attribute.value.value_meta = null;
}
});
Expand Down
9 changes: 7 additions & 2 deletions legacy/app/data/post-view-data.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h4 translate>post.no_posts_yet</h4>
<div class="listing-item" ng-if="posts.length > 0 || isLoading()">

<div class="listing-item-primary">
<button ng-disabled="isLoading()" ng-hide="( isLoading() || posts.length >= totalItems)" class="button-gamma button-flat" ng-click="loadMore()" translate="app.load_more">Load more
<button ng-hide="( isLoading() || posts.length >= totalItems)" class="button-gamma button-flat" ng-click="loadMore()" translate="app.load_more">Load more
</button>
<loading-dots-button button-class="'button-gamma button-flat'" label="'app.loading'" ng-show="isLoading()"></loading-dots-button>
</div>
Expand All @@ -98,7 +98,12 @@ <h4 translate>post.no_posts_yet</h4>
</div>
<div class="post-col" ng-class="{'active' : activeCol === 'post' }">
<!-- Verify if we need all these bindings ie. parentForm savingPost -->
<div ui-view filters="filters" is-loading="isLoading" saving-post="savingPost"></post-detail-data>
<div
ui-view
filters="filters"
is-loading="isLoading"
saving-post="savingPost"
></div>
</div>
</div>
<ush-logo></ush-logo>
Expand Down
2 changes: 1 addition & 1 deletion legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"single-spa-angularjs": "^4.2.3",
"sortablejs": "1.10.0",
"underscore": "^1.7.0",
"ushahidi-platform-pattern-library": "5.0.2",
"ushahidi-platform-pattern-library": "5.0.3",
"ushahidi-platform-sdk": "^0.5.0"
},
"engines": {
Expand Down

0 comments on commit 38be241

Please sign in to comment.