Skip to content

Commit

Permalink
Convert the component value to Date after refresh from Automate
Browse files Browse the repository at this point in the history
  • Loading branch information
romanblanco committed Jun 17, 2019
1 parent 1744f67 commit b2a4c8c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/dialog-user/services/dialogData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit b2a4c8c

Please sign in to comment.