Skip to content

Commit

Permalink
Fix 'today' in the datepicker
Browse files Browse the repository at this point in the history
This involved two fixes:
- recreating the config on resume so that the end date is reset (`list.js`), and
- setting "today" to the correct date when the datepicker is opened
    (`ionic-datepicker.bundle.min.js`)

I have also added build instructions to my fork of the ionic-datepicker repo,
but in case I delete the fork later, the instructions are:

Install node 10.19.0 ([gulp-sass will fail for more recent version of node](nodejs/node-gyp#1763))

```
node -v
v10.19.0
```

Install and check gulp version

```
npm install
npm list | grep gulp
├─┬ gulp@3.9.0
```

Build

```
npx gulp build
```

Testing done:

Followed the steps in e-mission/e-mission-docs#531 (comment)
Both end date and today are updated correctly
  • Loading branch information
shankari authored and asiripanich committed May 10, 2020
1 parent 155d4ea commit 7d4ad86
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
53 changes: 30 additions & 23 deletions www/js/diary/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,31 +128,38 @@ angular.module('emission.main.diary.list',['ui-leaflet',
}
}

$scope.datepickerObject = {

todayLabel: $translate.instant('list-datepicker-today'), //Optional
closeLabel: $translate.instant('list-datepicker-close'), //Optional
setLabel: $translate.instant('list-datepicker-set'), //Optional
monthsList: moment.monthsShort(),
weeksList: moment.weekdaysMin(),
titleLabel: $translate.instant('diary.list-pick-a-date'),
setButtonType : 'button-positive', //Optional
todayButtonType : 'button-stable', //Optional
closeButtonType : 'button-stable', //Optional
inputDate: new Date(), //Optional
from: new Date(2015, 1, 1),
to: new Date(),
mondayFirst: true, //Optional
templateType: 'popup', //Optional
showTodayButton: 'true', //Optional
modalHeaderColor: 'bar-positive', //Optional
modalFooterColor: 'bar-positive', //Optional
callback: $scope.setCurrDay, //Mandatory
dateFormat: 'dd MMM yyyy', //Optional
closeOnSelect: true //Optional
$scope.getDatePickerObject = function() {
return {
todayLabel: $translate.instant('list-datepicker-today'), //Optional
closeLabel: $translate.instant('list-datepicker-close'), //Optional
setLabel: $translate.instant('list-datepicker-set'), //Optional
monthsList: moment.monthsShort(),
weeksList: moment.weekdaysMin(),
titleLabel: $translate.instant('diary.list-pick-a-date'),
setButtonType : 'button-positive', //Optional
todayButtonType : 'button-stable', //Optional
closeButtonType : 'button-stable', //Optional
inputDate: new Date(), //Optional
from: new Date(2015, 1, 1),
to: new Date(),
mondayFirst: true, //Optional
templateType: 'popup', //Optional
showTodayButton: 'true', //Optional
modalHeaderColor: 'bar-positive', //Optional
modalFooterColor: 'bar-positive', //Optional
callback: $scope.setCurrDay, //Mandatory
dateFormat: 'dd MMM yyyy', //Optional
closeOnSelect: true //Optional
}
};

$scope.pickDay = function () {
$scope.datepickerObject = $scope.getDatePickerObject();

$ionicPlatform.on("resume", function() {
$scope.datepickerObject = $scope.getDatePickerObject();
});

$scope.pickDay = function() {
ionicDatePicker.openDatePicker($scope.datepickerObject);
}

Expand Down
Loading

0 comments on commit 7d4ad86

Please sign in to comment.