Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b993539
Merge conflict resolution
gautam1168 Feb 28, 2019
bcb202c
React select version update
gautam1168 Feb 28, 2019
389a141
Modify reducer to keep suggested members separate
gautam1168 Feb 28, 2019
2adc79c
Forgot to run linter
gautam1168 Feb 28, 2019
092ba61
Added code to clear suggestions once selection is made or item is del…
gautam1168 Mar 1, 2019
ab29f10
Styling changes for autoselect input
gautam1168 Mar 1, 2019
e43a518
More style updated
gautam1168 Mar 1, 2019
1a8cc3a
Added code to clear suggestion list when input length goes below 3 ch…
gautam1168 Mar 1, 2019
b67b5d8
Changes for userautocomplete box
gautam1168 Mar 1, 2019
4dfc992
Add creation option
gautam1168 Mar 1, 2019
344be8e
Replace custom debounce with lodash debounce
gautam1168 Mar 1, 2019
dbd25ce
Lint fixes
gautam1168 Mar 1, 2019
e46bf6b
Style changes to input box and adding placeholder
gautam1168 Mar 2, 2019
df39a36
More style changes
gautam1168 Mar 2, 2019
b85558a
Border color change for autocompletebox
gautam1168 Mar 2, 2019
dea3ad2
Fast typing enabled
gautam1168 Mar 2, 2019
0bfe6da
Moved styles to jsx
gautam1168 Mar 2, 2019
5fd81a0
Use scss variables to set colors and fonts
gautam1168 Mar 2, 2019
36aa43a
Final fixes
gautam1168 Mar 2, 2019
83ccda9
Fix for jumping placeholder and shifting selected values and input bo…
gautam1168 Mar 3, 2019
5c80304
Debounce fix
gautam1168 Mar 3, 2019
4890af8
Email fix
gautam1168 Mar 3, 2019
14c03e1
Fix for selected value box moving down on focus lost on react select
gautam1168 Mar 3, 2019
633060e
Lint fixes
gautam1168 Mar 3, 2019
0bca8cd
Move creation option to top and move styles used to hide dropdown ind…
gautam1168 Mar 4, 2019
89b3f90
Fix for select text moving down
gautam1168 Mar 4, 2019
112b06c
box shadow fix
gautam1168 Mar 4, 2019
69cc662
Lint fixes
gautam1168 Mar 4, 2019
23b36d6
Fixes for placeholder jumping down and charters getting chopped from …
gautam1168 Mar 4, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,903 changes: 1,584 additions & 1,319 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
"react-s-alert": "^1.1.4",
"react-scroll": "^1.7.6",
"react-scroll-lock-component": "^1.1.2",
"react-select": "^0.9.1",
"react-select": "^2.4.0",
"react-stickynode": "^1.2.1",
"react-text-truncate": "^0.8.3",
"react-transition-group": "^2.5.0",
Expand Down
4 changes: 2 additions & 2 deletions src/components/FileList/FileListItem.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ export default class FileListItem extends React.Component {
{ (errors && errors.title) && <div className="error-message">{ errors.title }</div> }
<textarea defaultValue={description} ref="desc" maxLength={250} className="tc-textarea" />
{ (errors && errors.desc) && <div className="error-message">{ errors.desc }</div> }
<UserAutoComplete onUpdate={this.onUserIdChange}
<UserAutoComplete onUpdate={this.onUserIdChange}
projectMembers={projectMembers}
loggedInUser={loggedInUser}
selectedUsers={this.userIdsToHandles(allowedUsers).join(',')}
selectedUsers={this.userIdsToHandles(allowedUsers).join(',')}
/>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/LinksMenu/EditFileAttachment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ export class EditFileAttachment extends React.Component {
<input className="edit-input" type="text" value={title} onChange={this.handleTitleChange.bind(this)} name="title"/>
<br />
<label for="title">File Viewers:</label>
<UserAutoComplete onUpdate={this.onUserIdChange}
<UserAutoComplete onUpdate={this.onUserIdChange}
projectMembers={projectMembers}
loggedInUser={loggedInUser}
selectedUsers={this.userIdsToHandles(allowedUsers).join(',')}
selectedUsers={this.userIdsToHandles(allowedUsers).map(user => ({value: user, label: user}))}
/>
<br />

Expand Down
31 changes: 27 additions & 4 deletions src/components/Select/Select.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,36 @@
*/
import React from 'react'
import ReactSelect from 'react-select'
import 'react-select/dist/react-select.css'
import CreatableSelect from 'react-select/lib/Creatable'
import './Select.scss'

const Select = (props) => {
return (
<ReactSelect {...props} />
)
let containerclass = 'react-select-hiddendropdown-container'
if (props.showDropdownIndicator) {
containerclass = 'react-select-container'
}

if (props.createOption) {
return (
<CreatableSelect
{...props}
createOptionPosition="first"
className={containerclass}
classNamePrefix="react-select"
noOptionsMessage={() => ('Type to search')}
/>
)
} else {
return (
<ReactSelect
{...props}
createOptionPosition="first"
className={containerclass}
classNamePrefix="react-select"
noOptionsMessage={() => ('Type to search')}
/>
)
}
}

export default Select
161 changes: 75 additions & 86 deletions src/components/Select/Select.scss
Original file line number Diff line number Diff line change
@@ -1,90 +1,79 @@
@import '~tc-ui/src/styles/tc-includes';

:global {
.Select {
line-height: normal;
text-align: left;
}

/* to override input styles use same params like in tc-includes */
.Select-input {
height: 28px;
}

.Select-input > input:not([type="checkbox"]) {
border: 0 none;
height: 28px;
line-height: 17px;
padding: 0;
transition: none;

&:focus:not(.error),
&:active {
box-shadow: none;
}
}

.Select-placeholder {
@include roboto;
color: $tc-gray-50;
font-size: 13px;
line-height: 28px;
}

.Select-control {
height: 30px;
}

.Select-item {
background-color: $tc-gray-10;
border: 0;
height: 21px;
margin-left: 4px;
margin-top: 4px;
padding: 0 10px 0 4px;
}

.Select-item-label {
@include roboto-medium;
display: inline;
color: $tc-black;
font-size: 13px;
line-height: 20px;
padding: 0 0 0 4px;
}

.Select-item-icon {
color:$tc-gray-40;
border-right-color: $tc-gray-10;
padding: 0 5px 1px;

&:active,
&:focus,
&:hover {
background-color: transparent;
color: $tc-red-110;
}
}

.Select-option {
@include roboto-medium;
color: $tc-black;
font-size: 13px;
padding-top: 5px;
padding-bottom: 6px;

&:hover,
&.is-focused {
background-color: $tc-gray-neutral-dark;
}
}

.Select-noresults,
.Select-search-prompt,
.Select-searching {
@include roboto-medium;
color: $tc-gray-50;
font-size: 13px;
}
$reactselectheight : 40px;
$reactselectcontentheight: 20px;
@mixin reactselectstyles {

& .react-select__control:hover {
border-color: $tc-gray-50;
}

& .react-select__control--is-focused {
border-color: #0681ff !important;
box-shadow: 0 0 2px 0 rgba(6, 129, 255, 0.7) !important;
}

& .react-select__control {
height: $reactselectheight;
border-color: $tc-gray-30;
box-shadow: none;//0 0 2px 0 rgba(6, 129, 255, 0.7) !important;

& > div {
height: $reactselectheight - 2px;
}

& > div:nth-child(1) > div:nth-last-child(1) {
height: $reactselectcontentheight + 4px;
}

& input {
height: $reactselectcontentheight;
line-height: $reactselectcontentheight;
transition: none !important;
box-shadow: none !important;
-webkit-box-shadow: none !important;
}

}

& .react-select__value-container {
& > div:nth-last-child(1) {
height: $reactselectcontentheight + 4px;
}
}

& .react-select__option {
@include roboto-medium;
font-size: 13px;
}

& .react-select__multi-value {
background-color: $tc-gray-20 !important;
font-weight: bold;
}

& .react-select__menu-notice--no-options {
text-align : left !important;
font-size : 15px;
color: $tc-gray-50;
}
}
.react-select-hiddendropdown-container {
@include reactselectstyles;
/*hide dropdown indicator*/
& .react-select__control {
& > div:nth-child(2) {
display: none;
}
& .react-select__dropdown-indicator {
display: none;
}
}
}

.react-select-container {
@include reactselectstyles;
}

}

71 changes: 8 additions & 63 deletions src/components/TeamManagement/AutocompleteInput.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import {findIndex} from 'lodash'
import Select from '../Select/Select'
import './AutocompleteInput.scss'
import {loadMemberSuggestions} from '../../api/projectMembers'
import {AUTOCOMPLETE_TRIGGER_LENGTH} from '../../config/constants'

/**
* Render a searchable dropdown for selecting users that can be invited
Expand All @@ -13,78 +10,27 @@ class AutocompleteInput extends React.Component {
constructor(props) {
super(props)

this.onChange = this.onChange.bind(this)
this.asyncOptions = this.asyncOptions.bind(this)

this.debounceTimer = null
}

// cannot use debounce method from lodash, because we have to return Promise
loadMemberSuggestionsDebounced(value) {
return new Promise((resolve) => {
if (this.debounceTimer) {
clearTimeout(this.debounceTimer)
}

this.debounceTimer = setTimeout(() => {
resolve(loadMemberSuggestions(value))
}, 500)
})
}

onChange(inputValue, selectedOptions = []) {
const { onUpdate } = this.props

if (onUpdate) {
onUpdate(selectedOptions)
}
}

asyncOptions(input) {
const { allMembers } = this.props

const value = typeof input === 'string' ? input : ''
const createOption = {
handle: value,
// Decide if it's email
isEmail: (/(.+)@(.+){2,}\.(.+){2,}/).test(value),
}
if (value.length >= AUTOCOMPLETE_TRIGGER_LENGTH) {
return this.loadMemberSuggestionsDebounced(value).then(r => {
// Remove current members from suggestions
const suggestions = r.filter(suggestion => (
findIndex(allMembers, (member) => member.handle === suggestion.handle) === -1 &&
// Remove current value from list to add it manually on top
suggestion.handle !== value
))
// Only allow creation if it is not already exists in members
const shouldIncludeCreateOption = findIndex(allMembers, (member) => member.handle === value) === -1

return Promise.resolve({options: shouldIncludeCreateOption?[createOption, ...suggestions]: suggestions})
}).catch( () => {
return Promise.resolve({options: [createOption] })
})
}
return Promise.resolve({options: value.length > 0 ? [createOption] : []})
}

render() {
const {
placeholder,
selectedMembers,
disabled,
disabled
} = this.props

return (
<div className="autocomplete-wrapper">
<Select
multi
isMulti
closeMenuOnSelect
showDropdownIndicator={false}
createOption
placeholder={placeholder}
value={selectedMembers}
onChange={this.onChange}
asyncOptions={this.asyncOptions}
valueKey="handle"
labelKey="handle"
onInputChange={this.props.onInputChange}
onChange={this.props.onUpdate}
options={this.props.suggestedMembers}
disabled={disabled}
/>
</div>
Expand Down Expand Up @@ -132,5 +78,4 @@ AutocompleteInput.propTypes = {
allMembers: PropTypes.arrayOf(PropTypes.object)
}


export default AutocompleteInput
Loading