bug fixed in datePicker, onclick action added

This commit is contained in:
Daniel Herrero 2017-11-30 08:10:44 +01:00
parent 78f4685001
commit 4667b39b1a
2 changed files with 18 additions and 3 deletions

View File

@ -4,7 +4,8 @@
ng-focus="$ctrl.hasFocus = true" ng-focus="$ctrl.hasFocus = true"
ng-blur="$ctrl.hasFocus = false" ng-blur="$ctrl.hasFocus = false"
ng-mouseenter="$ctrl.hasMouseIn = true" ng-mouseenter="$ctrl.hasMouseIn = true"
ng-mouseleave="$ctrl.hasMouseIn = false" ng-mouseleave="$ctrl.hasMouseIn = false"
ng-click="$ctrl.onClick()"
> >
<input type="text" <input type="text"
class="mdl-textfield__input" class="mdl-textfield__input"

View File

@ -59,6 +59,11 @@ class DatePicker extends Component {
onClear() { onClear() {
this.modelView = null; this.modelView = null;
} }
onClick() {
if (this.vp) {
this.vp.open();
}
}
mdlUpdate() { mdlUpdate() {
let mdlField = this.element.firstChild.MaterialTextfield; let mdlField = this.element.firstChild.MaterialTextfield;
if (mdlField) if (mdlField)
@ -167,14 +172,23 @@ class DatePicker extends Component {
return this.iniOptions; return this.iniOptions;
} }
$onInit() { initPicker() {
this.iniOptions = this._getOptions(); this.iniOptions = this._getOptions();
this.isTimePicker = (this.iniOptions && this.iniOptions.enableTime && this.iniOptions.noCalendar); this.isTimePicker = (this.iniOptions && this.iniOptions.enableTime && this.iniOptions.noCalendar);
this.vp = new Flatpickr(this.input, this.iniOptions); this.vp = new Flatpickr(this.input, this.iniOptions);
} }
$onDestroy() { destroyPicker() {
if (this.vp) if (this.vp)
this.vp.destroy(); this.vp.destroy();
this.vp = undefined;
}
$onInit() {
this.initPicker();
}
$onDestroy() {
this.destroyPicker();
} }
} }
DatePicker.$inject = ['$element', '$translate', '$filter', '$timeout']; DatePicker.$inject = ['$element', '$translate', '$filter', '$timeout'];