parent
046feb1f98
commit
4cc204b64a
|
@ -25,7 +25,7 @@
|
||||||
"@types/webpack-env": "1.13.1",
|
"@types/webpack-env": "1.13.1",
|
||||||
"@uifabric/icons": "^7.3.14",
|
"@uifabric/icons": "^7.3.14",
|
||||||
"moment": "^2.24.0",
|
"moment": "^2.24.0",
|
||||||
"office-ui-fabric-react": "^7.197.1",
|
"office-ui-fabric-react": "^6.189.2",
|
||||||
"react-dnd": "~2.5.4",
|
"react-dnd": "~2.5.4",
|
||||||
"react-dnd-html5-backend": "~2.5.4",
|
"react-dnd-html5-backend": "~2.5.4",
|
||||||
"react-html-parser": "^2.0.2",
|
"react-html-parser": "^2.0.2",
|
||||||
|
|
|
@ -34,15 +34,14 @@ export default class DateFormField extends React.Component<IDateFormFieldProps,
|
||||||
public componentDidUpdate(prevProps: IDateFormFieldProps, prevState: IDateFormFieldState) {
|
public componentDidUpdate(prevProps: IDateFormFieldProps, prevState: IDateFormFieldState) {
|
||||||
//Component Value property got updated from List State
|
//Component Value property got updated from List State
|
||||||
if (this.props.value && prevProps.value != this.props.value) {
|
if (this.props.value && prevProps.value != this.props.value) {
|
||||||
let momentDate = this.props.fieldSchema.DisplayFormat == 1 ?
|
let date: Date = this._parseDateString(this.props.value);
|
||||||
moment(this.props.value, moment.localeData(this.props.locale).longDateFormat('LT')) :
|
|
||||||
moment(this.props.value, moment.localeData(this.props.locale).longDateFormat('L'));
|
|
||||||
this.setState({
|
this.setState({
|
||||||
hours: momentDate.hour(),
|
date: date,
|
||||||
minutes: momentDate.minute(),
|
hours: date.getHours(),
|
||||||
date: momentDate.toDate()
|
minutes: date.getMinutes()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
//Component value updated
|
//Component value updated
|
||||||
if (this.state.date && this.state.date != prevState.date) {
|
if (this.state.date && this.state.date != prevState.date) {
|
||||||
let result = this.props.fieldSchema.DisplayFormat == 1 ?
|
let result = this.props.fieldSchema.DisplayFormat == 1 ?
|
||||||
|
@ -96,26 +95,23 @@ export default class DateFormField extends React.Component<IDateFormFieldProps,
|
||||||
}
|
}
|
||||||
|
|
||||||
private _onSelectDate = (inputDate: Date | null | undefined): void => {
|
private _onSelectDate = (inputDate: Date | null | undefined): void => {
|
||||||
|
|
||||||
|
|
||||||
this.setState(prevState => {
|
this.setState(prevState => {
|
||||||
let momentDate = inputDate ? this.props.fieldSchema.DisplayFormat == 1 ?
|
let momentDate = inputDate ?
|
||||||
moment(inputDate, moment.localeData(this.props.locale).longDateFormat('LT')) :
|
|
||||||
moment(inputDate, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
moment(inputDate, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
||||||
|
|
||||||
momentDate.hour(prevState.hours);
|
momentDate.hour(prevState.hours);
|
||||||
momentDate.minute(prevState.minutes);
|
momentDate.minute(prevState.minutes);
|
||||||
return {
|
return {
|
||||||
date: momentDate.toDate(),
|
date: momentDate.toDate(),
|
||||||
...prevState
|
hours: prevState.hours,
|
||||||
|
minutes: prevState.minutes
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private _onHoursChanged = (event: React.FormEvent<IComboBox>, option?: IComboBoxOption): void => {
|
private _onHoursChanged = (event: React.FormEvent<IComboBox>, option?: IComboBoxOption): void => {
|
||||||
if (option) {
|
if (option) {
|
||||||
this.setState(prevState => {
|
this.setState(prevState => {
|
||||||
let momentDate = prevState.date ? this.props.fieldSchema.DisplayFormat == 1 ?
|
let momentDate = prevState.date ?
|
||||||
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('LT')) :
|
|
||||||
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
||||||
let hours = parseInt(option.key.toString());
|
let hours = parseInt(option.key.toString());
|
||||||
momentDate.hour(hours);
|
momentDate.hour(hours);
|
||||||
|
@ -131,8 +127,7 @@ export default class DateFormField extends React.Component<IDateFormFieldProps,
|
||||||
private _onMinutesChanged = (event: React.FormEvent<IComboBox>, option?: IComboBoxOption): void => {
|
private _onMinutesChanged = (event: React.FormEvent<IComboBox>, option?: IComboBoxOption): void => {
|
||||||
if (option) {
|
if (option) {
|
||||||
this.setState(prevState => {
|
this.setState(prevState => {
|
||||||
let momentDate = prevState.date ? this.props.fieldSchema.DisplayFormat == 1 ?
|
let momentDate = prevState.date ?
|
||||||
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('LT')) :
|
|
||||||
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
moment(prevState.date, moment.localeData(this.props.locale).longDateFormat('L')) : moment();
|
||||||
let minutes = parseInt(option.key.toString());
|
let minutes = parseInt(option.key.toString());
|
||||||
momentDate.hour(prevState.hours);
|
momentDate.hour(prevState.hours);
|
||||||
|
@ -151,9 +146,12 @@ export default class DateFormField extends React.Component<IDateFormFieldProps,
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let momentDate = this.props.fieldSchema.DisplayFormat == 1 ?
|
let momentDate = moment(inputDate, moment.localeData(this.props.locale).longDateFormat('L'));
|
||||||
moment(inputDate, moment.localeData(this.props.locale).longDateFormat('LT')) :
|
let time = this.props.fieldSchema.DisplayFormat == 1 ? moment(this.props.value.split(" ")[1], moment.localeData(this.props.locale).longDateFormat('LT')) : null;
|
||||||
moment(inputDate, moment.localeData(this.props.locale).longDateFormat('L'));
|
if (time) {
|
||||||
|
momentDate.hours(time.hours());
|
||||||
|
momentDate.minutes(time.minutes());
|
||||||
|
}
|
||||||
return momentDate.toDate();
|
return momentDate.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue