bug fixed in dataPicker
This commit is contained in:
parent
bec05a1925
commit
ee7c4e214f
|
@ -37,7 +37,8 @@ class DatePicker extends Component {
|
|||
set model(value) {
|
||||
this._model = value;
|
||||
if (value && !this.modelView) {
|
||||
let initialDateFormat = (this.iniOptions && this.iniOptions.dateFormat) ? this.iniOptions.dateFormat : 'Y-m-d';
|
||||
let options = this._getOptions();
|
||||
let initialDateFormat = (options && options.dateFormat) ? options.dateFormat : 'Y-m-d';
|
||||
let format = this._formatFlat2Angular(initialDateFormat);
|
||||
this.modelView = this.$filter('date')(value, format);
|
||||
}
|
||||
|
@ -135,31 +136,37 @@ class DatePicker extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
if (!this.iniOptions)
|
||||
this.iniOptions = {};
|
||||
_getOptions() {
|
||||
if (this.iniOptions) {
|
||||
return this.iniOptions;
|
||||
}
|
||||
|
||||
if (!this.iniOptions.locale)
|
||||
this.iniOptions.locale = this.$translate.use();
|
||||
let iniOptions = {};
|
||||
if (!iniOptions.locale)
|
||||
iniOptions.locale = this.$translate.use();
|
||||
|
||||
if (!this.iniOptions.dateFormat && this.iniOptions.locale === 'es')
|
||||
this.iniOptions.dateFormat = 'd-m-Y';
|
||||
else if (this.iniOptions.dateFormat) {
|
||||
let format = this.iniOptions.dateFormat.split(/[ZT.,/ :-]/);
|
||||
if (!iniOptions.dateFormat && iniOptions.locale === 'es')
|
||||
iniOptions.dateFormat = 'd-m-Y';
|
||||
else if (iniOptions.dateFormat) {
|
||||
let format = iniOptions.dateFormat.split(/[ZT.,/ :-]/);
|
||||
if (format.length <= 1) {
|
||||
throw new Error(`Error: Invalid string format ${format}`);
|
||||
}
|
||||
format.forEach(
|
||||
val => {
|
||||
if (!formatEquivalence[val]) {
|
||||
throw new Error(`Error in dateFormat ${this.iniOptions.dateFormat}: is not like Flatpickr Formatting Token https://chmln.github.io/flatpickr/formatting/`);
|
||||
throw new Error(`Error in dateFormat ${iniOptions.dateFormat}: is not like Flatpickr Formatting Token https://chmln.github.io/flatpickr/formatting/`);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return iniOptions;
|
||||
}
|
||||
|
||||
if (this.input)
|
||||
this.vp = new Flatpickr(this.input, this.iniOptions);
|
||||
$onInit() {
|
||||
this.iniOptions = this._getOptions();
|
||||
|
||||
this.vp = new Flatpickr(this.input, this.iniOptions);
|
||||
}
|
||||
$onDestroy() {
|
||||
if (this.vp)
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.route"
|
||||
form="form"
|
||||
>
|
||||
</vn-watcher>
|
||||
<form name="form" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
|
|
Loading…
Reference in New Issue