1
- angular . module ( "schemaForm" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "directives/decorators/bootstrap/datepicker/datepicker.html" , "<div class=\"form-group {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div ng-class=\"{\'input-group\': (form.fieldAddonLeft || form.fieldAddonRight)}\">\n <span ng-if=\"form.fieldAddonLeft\"\n class=\"input-group-addon\"\n ng-bind-html=\"form.fieldAddonLeft\"></span>\n <input ng-show=\"form.key\"\n style=\"background-color: white\"\n type=\"text\"\n class=\"form-control {{form.fieldHtmlClass}}\"\n schema-validate=\"form\"\n ng-model=\"$$value$$\"\n ng-disabled=\"form.readonly\"\n pick-a-date=\"form.pickadate\"\n min-date=\"form.minDate\"\n max-date=\"form.maxDate\"\n name=\"{{form.key.slice(-1)[0]}}\"\n format=\"form.format\" />\n <span ng-if=\"form.fieldAddonRight\"\n class=\"input-group-addon\"\n ng-bind-html=\"form.fieldAddonRight\"></span>\n </div>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n</div>\n" ) ; } ] ) ;
2
- angular . module ( 'schemaForm' ) . directive ( 'pickADate' , function ( ) {
1
+ angular . module ( "schemaForm" ) . run ( [ "$templateCache" , function ( $templateCache ) { $templateCache . put ( "directives/decorators/bootstrap/datepicker/datepicker.html" , "<div class=\"form-group {{form.htmlClass}}\" ng-class=\"{\'has-error\': hasError()}\">\n <label class=\"control-label {{form.labelHtmlClass}}\" ng-show=\"showTitle()\">{{form.title}}</label>\n <div ng-class=\"{\'input-group\': (form.fieldAddonLeft || form.fieldAddonRight)}\">\n <span ng-if=\"form.fieldAddonLeft\"\n class=\"input-group-addon\"\n ng-bind-html=\"form.fieldAddonLeft\"></span>\n <input ng-show=\"form.key\"\n type=\"text\"\n class=\"form-control {{form.fieldHtmlClass}}\"\n schema-validate=\"form\"\n ng-model=\"$$value$$\"\n ng-disabled=\"form.readonly\"\n pick-a-date=\"form.pickadate\"\n min-date=\"form.minDate\"\n max-date=\"form.maxDate\"\n select-years=\"form.selectYears\"\n select-months=\"form.selectMonths\"\n name=\"{{form.key.slice(-1)[0]}}\"\n format=\"form.format\" />\n <span ng-if=\"form.fieldAddonRight\"\n class=\"input-group-addon\"\n ng-bind-html=\"form.fieldAddonRight\"></span>\n </div>\n <span class=\"help-block\">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>\n</div>\n" ) ; } ] ) ;
2
+ angular . module ( 'schemaForm' ) . directive ( 'pickADate' , function ( ) {
3
3
4
4
//String dates for min and max is not supported
5
5
//https://github.com/amsul/pickadate.js/issues/439
@@ -20,9 +20,11 @@ angular.module('schemaForm').directive('pickADate', function () {
20
20
pickADate : '=' ,
21
21
minDate : '=' ,
22
22
maxDate : '=' ,
23
- format : '='
23
+ format : '=' ,
24
+ selectYears : '=?' ,
25
+ selectMonths : '=?'
24
26
} ,
25
- link : function ( scope , element , attrs , ngModel ) {
27
+ link : function ( scope , element , attrs , ngModel ) {
26
28
//Bail out gracefully if pickadate is not loaded.
27
29
if ( ! element . pickadate ) {
28
30
return ;
@@ -32,10 +34,12 @@ angular.module('schemaForm').directive('pickADate', function () {
32
34
//hidden field that pickadate likes to create.
33
35
//We use ngModel formatters instead to format the value.
34
36
var opts = {
35
- onClose : function ( ) {
37
+ onClose : function ( ) {
36
38
element . blur ( ) ;
37
39
} ,
38
- formatSubmit : null
40
+ formatSubmit : null ,
41
+ selectYears : ( scope . selectYears || false ) ,
42
+ selectMonths : ( scope . selectMonths || false )
39
43
} ;
40
44
if ( scope . pickADate ) {
41
45
angular . extend ( opts , scope . pickADate ) ;
@@ -72,7 +76,7 @@ angular.module('schemaForm').directive('pickADate', function () {
72
76
73
77
//bind once.
74
78
if ( angular . isDefined ( attrs . minDate ) ) {
75
- var onceMin = scope . $watch ( 'minDate' , function ( value ) {
79
+ var onceMin = scope . $watch ( 'minDate' , function ( value ) {
76
80
if ( value ) {
77
81
picker . set ( 'min' , formatDate ( value ) ) ;
78
82
onceMin ( ) ;
@@ -81,7 +85,7 @@ angular.module('schemaForm').directive('pickADate', function () {
81
85
}
82
86
83
87
if ( angular . isDefined ( attrs . maxDate ) ) {
84
- var onceMax = scope . $watch ( 'maxDate' , function ( value ) {
88
+ var onceMax = scope . $watch ( 'maxDate' , function ( value ) {
85
89
if ( value ) {
86
90
picker . set ( 'max' , formatDate ( value ) ) ;
87
91
onceMax ( ) ;
0 commit comments