Skip to content

Commit

Permalink
Fixed default value date formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ranbena committed Jan 24, 2019
1 parent 6fe0509 commit 48743c7
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions client/app/components/ParameterMappingInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { extend, map, includes, findIndex, find, fromPairs, isNull, isUndefined } from 'lodash';
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import moment from 'moment';
import Select from 'antd/lib/select';
import Table from 'antd/lib/table';
import Popover from 'antd/lib/popover';
Expand Down Expand Up @@ -322,27 +321,22 @@ export class ParameterMappingListInput extends React.Component {
return '';
}

// array
if (value instanceof Array) {
const arr = value.map(v => this.getStringValue(v));
const delimiter = moment.isMoment(value[0]) ? ' ~ ' : ', ';
return arr.join(delimiter);
// range
if (value instanceof Object && 'start' in value && 'end' in value) {
return `${value.start} ~ ${value.end}`;
}

// moment
if (moment.isMoment(value)) {
return value.format('DD/MM/YY');
// just to be safe, array or object
if (typeof value === 'object') {
return map(value, v => this.getStringValue(v)).join(', ');
}

// rest
return value.toString();
}

static getDefaultValue(mapping) {
const value = mapping.type === MappingType.StaticValue
? mapping.value || mapping.param.normalizedValue
: mapping.param.normalizedValue;

const value = mapping.value || mapping.param.value;
return this.getStringValue(value);
}

Expand Down

0 comments on commit 48743c7

Please sign in to comment.