Skip to content

Commit

Permalink
Working on #7: added debug, need to fix the configuration handling (u…
Browse files Browse the repository at this point in the history
…se the months labels (the other option) but limit to the available months)
  • Loading branch information
Barbara Post committed Jun 1, 2017
1 parent 1785126 commit b36d327
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ First releases of fork: added ability to select a week or month in addition to s
[Issue#2](https://github.com/OSAMES/ionic-datepicker/issues/2)

### 2) v1.4.0

[Issue#4](https://github.com/OSAMES/ionic-datepicker/issues/4)
[Issue#5](https://github.com/OSAMES/ionic-datepicker/issues/5)

Expand All @@ -258,6 +257,9 @@ Since some bug fixes were added that conflicted with my changes, work again on i
### 4) v1.5.1
Swapped "Set" and "Close" buttons position, from user suggestion.
### 5) v1.6.0
[Issue#7](https://github.com/OSAMES/ionic-datepicker/issues/7)
##License:
[MIT](https://github.com/rajeshwarpatlolla/ionic-datepicker/blob/master/LICENSE.MD "MIT")
Expand Down
2 changes: 1 addition & 1 deletion dist/ionic-datepicker.bundle.min.js

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/ionic-datepicker.provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,15 @@ angular.module('ionic-datepicker.provider', [])
var lastDay = new Date(currentDate.getFullYear(), currentDate.getMonth() + 1, 0).getDate();

$scope.monthsList = [];
console.info("config ", $scope.mainObj.monthsList);
if ($scope.mainObj.monthsList && $scope.mainObj.monthsList.length === 12) {
$scope.monthsList = $scope.mainObj.monthsList;
} else {
$scope.monthsList = IonicDatepickerService.monthsList;
$scope.monthsList = IonicDatepickerService.getMonthsList($scope.mainObj.from, $scope.mainObj.to);
}

console.info("months list ", $scope.monthsList);

$scope.yearsList = IonicDatepickerService.getYearsList($scope.mainObj.from, $scope.mainObj.to);

$scope.dayList = [];
Expand Down
15 changes: 15 additions & 0 deletions src/ionic-datepicker.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ angular.module('ionic-datepicker.service', [])

return yearsList;
};

this.getMonthsList = function (from, to) {
var monthsList = [];
var minMonth = 0;
var maxMonth = 11;

minMonth = from ? new Date(from).getMonth() : minMonth;
maxMonth = to ? new Date(to).getMonth() : maxMonth;

for (var i = minMonth; i <= maxMonth; i++) {
monthsList.push(i);
}

return monthsList;
};
});

0 comments on commit b36d327

Please sign in to comment.