Fixed: Various UI fixes

Co-Authored-By: Mark McDowall <markus101@users.noreply.github.com>
This commit is contained in:
Qstick 2018-09-06 20:59:49 -04:00
parent 2667d3ac21
commit 034ef2ad99
3 changed files with 26 additions and 18 deletions

View file

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

View file

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

View file

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