date-field-parser.ts (dspace-angular-dspace-7.0) | : | date-field-parser.ts (dspace-angular-dspace-7.1) | ||
---|---|---|---|---|
import { FieldParser } from './field-parser'; | import { FieldParser } from './field-parser'; | |||
import { DynamicDatePickerModelConfig } from '@ng-dynamic-forms/core'; | import { | |||
import { DynamicDsDatePickerModel } from '../ds-dynamic-form-ui/models/date-pick | DynamicDsDateControlModelConfig, | |||
er/date-picker.model'; | DynamicDsDatePickerModel | |||
} from '../ds-dynamic-form-ui/models/date-picker/date-picker.model'; | ||||
import { isNotEmpty } from '../../../empty.util'; | import { isNotEmpty } from '../../../empty.util'; | |||
import { DS_DATE_PICKER_SEPARATOR } from '../ds-dynamic-form-ui/models/date-pick er/date-picker.component'; | import { DS_DATE_PICKER_SEPARATOR } from '../ds-dynamic-form-ui/models/date-pick er/date-picker.component'; | |||
import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu e.model'; | import { FormFieldMetadataValueObject } from '../models/form-field-metadata-valu e.model'; | |||
export class DateFieldParser extends FieldParser { | export class DateFieldParser extends FieldParser { | |||
public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: b oolean): any { | public modelFactory(fieldValue?: FormFieldMetadataValueObject | any, label?: b oolean): any { | |||
let malformedDate = false; | let malformedDate = false; | |||
const inputDateModelConfig: DynamicDatePickerModelConfig = this.initModel(nu | const inputDateModelConfig: DynamicDsDateControlModelConfig = this.initModel | |||
ll, label); | (null, false, true); | |||
inputDateModelConfig.legend = this.configData.label; | ||||
inputDateModelConfig.toggleIcon = 'fas fa-calendar'; | inputDateModelConfig.toggleIcon = 'fas fa-calendar'; | |||
this.setValues(inputDateModelConfig as any, fieldValue); | this.setValues(inputDateModelConfig as any, fieldValue); | |||
// Init Data and validity check | // Init Data and validity check | |||
if (isNotEmpty(inputDateModelConfig.value)) { | if (isNotEmpty(inputDateModelConfig.value)) { | |||
const value = inputDateModelConfig.value.toString(); | const value = inputDateModelConfig.value.toString(); | |||
if (value.length >= 4) { | if (value.length >= 4) { | |||
const valuesArray = value.split(DS_DATE_PICKER_SEPARATOR); | const valuesArray = value.split(DS_DATE_PICKER_SEPARATOR); | |||
if (valuesArray.length < 4) { | if (valuesArray.length < 4) { | |||
for (let i = 0; i < valuesArray.length; i++) { | for (let i = 0; i < valuesArray.length; i++) { | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 7 lines changed or added |