Fixed: Various UI fixes

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
pull/481/head
Qstick 6 years ago
parent 2667d3ac21
commit 034ef2ad99

@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import isString from 'Utilities/String/isString';
import split from 'Utilities/String/split';
import TagInput from './TagInput';
@ -11,8 +10,7 @@ function createMapStateToProps() {
return createSelector(
(state, { value }) => value,
(tags) => {
const isArray = !isString(tags);
const tagsArray = isArray ? tags :split(tags);
const tagsArray = Array.isArray(tags) ? tags : split(tags);
return {
tags: tagsArray.reduce((result, tag) => {
@ -25,7 +23,7 @@ function createMapStateToProps() {
return result;
}, []),
isArray
valueArray: tagsArray
};
}
);
@ -39,13 +37,20 @@ class TextTagInputConnector extends Component {
onTagAdd = (tag) => {
const {
name,
value,
isArray,
valueArray,
onChange
} = this.props;
const newValue = isArray ? [...value] : split(value);
newValue.push(tag.name);
// Split and trim tags before adding them to the list, this will
// cleanse tags pasted in that had commas and spaces which leads
// to oddities with restrictions (as an example).
const newValue = [...valueArray];
const newTags = split(tag.name);
newTags.forEach((newTag) => {
newValue.push(newTag.trim());
});
onChange({ name, value: newValue.join(',') });
}
@ -53,12 +58,11 @@ class TextTagInputConnector extends Component {
onTagDelete = ({ index }) => {
const {
name,
value,
isArray,
valueArray,
onChange
} = this.props;
const newValue = isArray ? [...value] : split(value);
const newValue = [...valueArray];
newValue.splice(index, 1);
onChange({
@ -84,7 +88,7 @@ class TextTagInputConnector extends Component {
TextTagInputConnector.propTypes = {
name: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
valueArray: PropTypes.arrayOf(PropTypes.string).isRequired,
isArray: PropTypes.bool.isRequired,
onChange: PropTypes.func.isRequired
};

@ -65,7 +65,9 @@ function keyboardShortcuts(WrappedComponent) {
}
stopCallback = (event, element, combo) => {
if (this._mousetrapBindings[combo].isGlobal) {
const binding = this._mousetrapBindings[combo];
if (!binding || binding.isGlobal) {
return false;
}

@ -10,6 +10,12 @@ function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat,
return null;
}
const isTodayDate = isToday(date);
if (isTodayDate && timeForToday && timeFormat) {
return formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds });
}
if (!showRelativeDates) {
return moment(date).format(shortDateFormat);
}
@ -18,11 +24,7 @@ function getRelativeDate(date, shortDateFormat, showRelativeDates, { timeFormat,
return 'Yesterday';
}
if (isToday(date)) {
if (timeForToday && timeFormat) {
return formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds });
}
if (isTodayDate) {
return 'Today';
}

Loading…
Cancel
Save