From b2a4c8ca4db4cf133286ea61d1c6a68e9de70add Mon Sep 17 00:00:00 2001 From: Roman Blanco Date: Mon, 17 Jun 2019 12:55:26 +0000 Subject: [PATCH] Convert the component value to Date after refresh from Automate --- src/dialog-user/services/dialogData.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/dialog-user/services/dialogData.ts b/src/dialog-user/services/dialogData.ts index c8fe465086..a8a0dd8745 100644 --- a/src/dialog-user/services/dialogData.ts +++ b/src/dialog-user/services/dialogData.ts @@ -43,6 +43,14 @@ export default class DialogDataService { } } + if (field.type === 'DialogFieldDateControl') { + if (_.isNull(field.default_value) || _.isUndefined(field.default_value)) { + field.dateField = field.timeField = new Date(); + } else { + field.dateField = field.timeField = new Date(data.default_value); + } + } + field.default_value = this.setDefaultValue(field); return field; @@ -95,14 +103,14 @@ export default class DialogDataService { defaultValue = data.values[firstOption][fieldValue]; } - if (data.type === 'DialogFieldDateControl' || data.type === 'DialogFieldDateTimeControl') { - defaultValue = data.values ? new Date(data.values) : new Date(); - } - if (data.default_value) { defaultValue = data.default_value; } + if (data.type === 'DialogFieldDateControl' || data.type === 'DialogFieldDateTimeControl') { + defaultValue = data.dateField ? new Date(data.dateField) : new Date(); + } + if (data.type === 'DialogFieldDropDownList' && data.options.force_multi_value && data.default_value) { defaultValue = JSON.parse(data.default_value); }