-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #528 from marmelab/date_filter
[RFR] Fix default date format in date field
- Loading branch information
Showing
6 changed files
with
89 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* Fixes an issue with Bootstrap Date Picker | ||
@see https://github.com/angular-ui/bootstrap/issues/2659 */ | ||
var datepickerPopup = function () { | ||
return { | ||
restrict: 'EAC', | ||
require: 'ngModel', | ||
link: function(scope, element, attr, controller) { | ||
//remove the default formatter from the input directive to prevent conflict | ||
controller.$formatters.shift(); | ||
} | ||
} | ||
}; | ||
|
||
datepickerPopup.$inject = []; | ||
|
||
export default datepickerPopup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,55 @@ | ||
/*global define*/ | ||
/** | ||
* Edition field for a date - a text input with a datepicker. | ||
* | ||
* @example <ma-date-field field="field" value="value"></ma-date-field> | ||
*/ | ||
function maDateField() { | ||
return { | ||
scope: { | ||
'field': '&', | ||
'value': '=' | ||
}, | ||
restrict: 'E', | ||
link: function(scope, element) { | ||
var field = scope.field(); | ||
scope.name = field.name(); | ||
scope.rawValue = scope.value; | ||
scope.$watch('rawValue', function(rawValue) { | ||
scope.value = field.parse()(rawValue); | ||
}); | ||
scope.format = field.format(); | ||
if (!scope.format) { | ||
scope.format = field.type() === 'date' ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'; | ||
} | ||
|
||
define(function (require) { | ||
'use strict'; | ||
scope.v = field.validation(); | ||
scope.isOpen = false; | ||
var input = element.find('input').eq(0); | ||
var attributes = field.attributes(); | ||
for (var name in attributes) { | ||
input.attr(name, attributes[name]); | ||
} | ||
scope.toggleDatePicker = function ($event) { | ||
$event.preventDefault(); | ||
$event.stopPropagation(); | ||
scope.isOpen = !scope.isOpen; | ||
}; | ||
}, | ||
template: ` | ||
<div class="input-group datepicker"> | ||
<input | ||
type="text" ng-model="rawValue" id="{{ name }}" name="{{ name }}" class="form-control" | ||
datepicker-popup="{{ format }}" is-open="isOpen" close-text="Close" ng-required="v.required" /> | ||
<span class="input-group-btn"> | ||
<button type="button" class="btn btn-default" ng-click="toggleDatePicker($event)"> | ||
<i class="glyphicon glyphicon-calendar"></i> | ||
</button> | ||
</span> | ||
</div> | ||
` | ||
}; | ||
} | ||
|
||
/** | ||
* Edition field for a date - a text input with a datepicker. | ||
* | ||
* @example <ma-date-field field="field" value="value"></ma-date-field> | ||
*/ | ||
function maDateField() { | ||
return { | ||
scope: { | ||
'field': '&', | ||
'value': '=' | ||
}, | ||
restrict: 'E', | ||
link: function(scope, element) { | ||
var field = scope.field(); | ||
scope.name = field.name(); | ||
scope.rawValue = scope.value; | ||
scope.$watch('rawValue', function(rawValue) { | ||
scope.value = field.parse()(rawValue); | ||
}); | ||
scope.format = field.format(); | ||
if (!scope.format) { | ||
scope.format = field.type() === 'date' ? 'yyyy-MM-dd' : 'yyyy-MM-dd HH:mm:ss'; | ||
} | ||
maDateField.$inject = []; | ||
|
||
scope.v = field.validation(); | ||
scope.isOpen = false; | ||
var input = element.find('input').eq(0); | ||
var attributes = field.attributes(); | ||
for (var name in attributes) { | ||
input.attr(name, attributes[name]); | ||
} | ||
scope.toggleDatePicker = function ($event) { | ||
$event.preventDefault(); | ||
$event.stopPropagation(); | ||
scope.isOpen = !scope.isOpen; | ||
}; | ||
}, | ||
template: | ||
'<div class="input-group datepicker">' + | ||
'<input type="text" ng-model="rawValue" id="{{ name }}" name="{{ name }}" class="form-control" ' + | ||
'datepicker-popup="{{ format }}" is-open="isOpen" close-text="Close" ' + | ||
'ng-required="v.required" />' + | ||
'<span class="input-group-btn">' + | ||
'<button type="button" class="btn btn-default" ng-click="toggleDatePicker($event)"><i class="glyphicon glyphicon-calendar"></i></button>' + | ||
'</span>' + | ||
'</div>' | ||
}; | ||
} | ||
|
||
maDateField.$inject = []; | ||
|
||
return maDateField; | ||
}); | ||
export default maDateField; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters