-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
289 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
app/assets/javascripts/components/story/ExpandedStory/ExpandedStoryLabels.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React from 'react'; | ||
import ReactTags from 'react-tag-autocomplete'; | ||
import PropTypes from 'prop-types'; | ||
|
||
class ExpandedStoryLabels extends React.Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
tags: props.labels | ||
} | ||
|
||
this.handleAddition = this.handleAddition.bind(this); | ||
this.handleDelete = this.handleDelete.bind(this); | ||
} | ||
|
||
handleDelete(index) { | ||
const { onEdit } = this.props; | ||
const tags = this.state.tags.filter((tag, tagIndex) => tagIndex !== index); | ||
|
||
this.setState( | ||
{ tags }, () => { | ||
onEdit(this.state.tags) | ||
} | ||
); | ||
} | ||
|
||
handleAddition(tag) { | ||
const { onEdit } = this.props; | ||
|
||
this.setState( | ||
{ tags: [...this.state.tags, tag] }, () => { | ||
onEdit(this.state.tags) | ||
} | ||
); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="Story__section"> | ||
<div className="Story__section-title"> | ||
{I18n.t('activerecord.attributes.story.labels')} | ||
</div> | ||
{ | ||
<ReactTags | ||
tags={this.state.tags} | ||
handleDelete={this.handleDelete} | ||
handleAddition={this.handleAddition} | ||
allowNew={true} | ||
placeholder={I18n.t('add new label')} | ||
allowBackspace={false} | ||
addOnBlur={true} | ||
delimiterChars={[' ']} | ||
autoresize={false} /> | ||
} | ||
</div> | ||
); | ||
} | ||
}; | ||
|
||
ExpandedStoryLabels.propTypes = { | ||
labels: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
onEdit: PropTypes.func.isRequired | ||
}; | ||
|
||
export default ExpandedStoryLabels; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const splitLabels = (labels) => { | ||
if (labels) { | ||
return labels.split(',') | ||
.map((label, index) => ( | ||
{ | ||
id: index, | ||
name: label | ||
} | ||
)) | ||
} | ||
|
||
return []; | ||
}; | ||
|
||
export const joinLabels = (labels) => | ||
labels.map(label => label.name).join(','); | ||
|
||
export const getNames = (labels) => | ||
labels.map(label => label.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
import httpService from '../../services/httpService'; | ||
import changeCase from'change-object-case'; | ||
import changeCase from 'change-object-case'; | ||
import * as Story from './story'; | ||
|
||
export function get(projectId) { | ||
return httpService | ||
.get(`/beta/project_boards/${projectId}`) | ||
.then(({ data }) => changeCase.camelKeys(data, {recursive: true, arrayRecursive: true})) | ||
.then(( projectBoard ) => ({ | ||
...projectBoard, | ||
stories: projectBoard.stories.map((story) => ({ | ||
...story, | ||
estimate: story.estimate || '', | ||
collapsed: true | ||
})) | ||
})); | ||
.then(({ data }) => changeCase.camelKeys(data, { recursive: true, arrayRecursive: true })) | ||
.then((projectBoard) => ({ | ||
...projectBoard, | ||
stories: projectBoard.stories.map(Story.deserialize) | ||
})); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
.react-tags { | ||
position: relative; | ||
padding: 6px 0 0 6px; | ||
border: 1px solid $lightgrey-9; | ||
border-radius: 3px; | ||
background-color: $white; | ||
|
||
font-size: 10px; | ||
line-height: 1.2; | ||
} | ||
|
||
.react-tags.is-focused { | ||
border-color: $lightgrey-18; | ||
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); | ||
} | ||
|
||
.react-tags__selected { | ||
display: inline; | ||
} | ||
|
||
.react-tags__selected-tag { | ||
display: inline-block; | ||
box-sizing: border-box; | ||
margin: 0 6px 6px 0; | ||
padding: 6px 8px; | ||
border: 1px solid $lightgrey-17; | ||
border-radius: 2px; | ||
background: $lightgrey-10; | ||
|
||
font-size: inherit; | ||
line-height: inherit; | ||
} | ||
|
||
.react-tags__selected-tag:after { | ||
content: '\2715'; | ||
color: $lightgrey-16; | ||
margin-left: 8px; | ||
} | ||
|
||
.react-tags__selected-tag:hover, | ||
.react-tags__selected-tag:focus { | ||
border-color: $lightgrey-18; | ||
} | ||
|
||
.react-tags__search { | ||
display: inline-block; | ||
|
||
padding: 7px 2px; | ||
margin-bottom: 6px; | ||
|
||
max-width: 100%; | ||
} | ||
|
||
.react-tags__search input { | ||
max-width: 100%; | ||
height: 100%; | ||
|
||
margin: 0; | ||
padding: 0; | ||
border: 0; | ||
outline: none; | ||
|
||
font-size: inherit; | ||
line-height: inherit; | ||
} | ||
|
||
.react-tags__search input::-ms-clear { | ||
display: none; | ||
} | ||
|
||
.react-tags__suggestions { | ||
position: absolute; | ||
top: 100%; | ||
left: 0; | ||
width: 100%; | ||
} | ||
|
||
.react-tags__suggestions ul { | ||
margin: 4px -1px; | ||
padding: 0; | ||
list-style: none; | ||
background: $white; | ||
border: 1px solid $lightgrey-19; | ||
border-radius: 2px; | ||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); | ||
} | ||
|
||
.react-tags__suggestions li { | ||
border-bottom: 1px solid $lightgrey-13; | ||
padding: 6px 8px; | ||
} | ||
|
||
.react-tags__suggestions li mark { | ||
text-decoration: underline; | ||
background: none; | ||
font-weight: 600; | ||
} | ||
|
||
.react-tags__suggestions li:hover { | ||
cursor: pointer; | ||
background: $lightgrey-8; | ||
} | ||
|
||
.react-tags__suggestions li.is-active { | ||
background: $lightgrey-15; | ||
} | ||
|
||
.react-tags__suggestions li.is-disabled { | ||
opacity: 0.5; | ||
cursor: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.