Skip to content

Commit 4f2b9a3

Browse files
author
Parth Shah
committed
Merge branch 'dev'
2 parents c640d27 + 3c884ae commit 4f2b9a3

File tree

10 files changed

+43
-15
lines changed

10 files changed

+43
-15
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"lodash": "^4.16.4",
4646
"moment": "^2.14.1",
4747
"react": "^15.3.1",
48+
"react-datetime": "2.7.1",
4849
"react-addons-css-transition-group": "^15.3.1",
4950
"react-addons-pure-render-mixin": "^15.3.1",
5051
"react-color": "^2.2.7",

src/components/LinksMenu/AddLink.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,18 @@ class AddLink extends React.Component {
3434
<Formsy.Form onValidSubmit={onAdd} onValid={this.enableSubmitBtn} onInvalid={this.disableSubmitBtn}>
3535
<TCFormFields.TextInput
3636
name="title"
37-
label="Title"
37+
label="Name"
3838
type="text"
3939
validations="isRequired"
40-
validationError="Title is required"
40+
validationError="Name is required"
4141
maxLength={250}
4242
wrapperClass="form-group"
4343
/>
4444
<TCFormFields.TextInput
4545
name="address"
46-
label="Address"
46+
label="URL"
4747
type="text"
48-
validationError="This is a required field."
48+
validationError="URL is required."
4949
validations={{
5050
isRelaxedUrl: true,
5151
isRequired: true

src/components/TeamManagement/AddTeamMember.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import AutoCompleteInput from './AutoCompleteInput'
33
import cn from 'classnames'
44
import { Icons } from 'appirio-tech-react-components'
55
import { PROJECT_ROLE_CUSTOMER } from '../../config/constants'
6-
6+
import Scroll from 'react-scroll'
77

88
const { XMarkIcon } = Icons
99

@@ -17,6 +17,7 @@ const AddTeamMember = (props) => {
1717
const onBtnClose = () => {
1818
onKeywordChange('')
1919
onToggleAddTeamMember(false)
20+
Scroll.animateScroll.scrollMore(1)
2021
}
2122
const onConfirmAddMember = () => {
2223
// if adding a customer and there is no owner yet for the project

src/components/TeamManagement/AutoCompleteInput.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class AutoCompleteInput extends React.Component {
6363
{selectedNewMember && <img src={selectedNewMember.photoURL} />}
6464
</span>
6565
<input
66+
autoFocus
6667
ref="input"
6768
value={keyword}
6869
className="tc-file-field__inputs"

src/components/TopBar/TopBar.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class TopBar extends Component {
3232
}
3333
/*eslint-enable */
3434

35-
handleSearch(name) {
36-
this.props.applyFilters({ name })
35+
handleSearch(keyword) {
36+
this.props.applyFilters({ keyword })
3737
}
3838

3939
handleMyProjectsFilter(event) {
@@ -107,7 +107,7 @@ class TopBar extends Component {
107107
<SearchBar
108108
hideSuggestionsWhenEmpty
109109
showPopularSearchHeader={ false }
110-
searchTermKey="name"
110+
searchTermKey="keyword"
111111
onTermChange={ this.handleTermChange }
112112
onSearch={ this.handleSearch }
113113
onClearSearch={ this.handleSearch }

src/components/TopBar/TopBarContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ class TopBarContainer extends React.Component {
7878

7979
applyFilters(filter) {
8080
const criteria = _.assign({}, this.props.criteria, filter)
81-
if (criteria && criteria.name)
82-
criteria.name = encodeURIComponent(criteria.name)
81+
if (criteria && criteria.keyword)
82+
criteria.keyword = encodeURIComponent(criteria.keyword)
8383
this.routeWithParams(criteria, 1)
8484
}
8585

src/projects/actions/projectTopics.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const getTopicsWithComments = (projectId, tag) => {
6262
return Promise.all(additionalPosts)
6363
.then(postArr => {
6464
_.forEach(postArr, (p) => {
65-
const topic = _.find(topics, t => p.topicId)
65+
const topic = _.find(topics, t => t.id === p.topicId)
6666
topic.posts = _.sortBy(topic.posts.concat(p.posts), ['id'])
6767
})
6868
return { topics, totalCount }

src/projects/detail/components/EditProjectForm.jsx

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React, { Component, PropTypes } from 'react'
2+
import { withRouter } from 'react-router'
23
import Modal from 'react-modal'
34
import _ from 'lodash'
45
import update from 'react-addons-update'
@@ -18,6 +19,7 @@ class EditProjectForm extends Component {
1819
this.saveFeatures = this.saveFeatures.bind(this)
1920
this.onFeaturesSaveAttachedClick = this.onFeaturesSaveAttachedClick.bind(this)
2021
this.submit = this.submit.bind(this)
22+
this.onLeave = this.onLeave.bind(this)
2123
}
2224

2325
componentWillMount() {
@@ -37,11 +39,33 @@ class EditProjectForm extends Component {
3739
}
3840
this.setState({
3941
project: updatedProject,
40-
canSubmit: this.state.isFeaturesDirty,
42+
isFeaturesDirty: false, // Since we just saved, features are not dirty anymore.
43+
canSubmit: false,
4144
isSaving: false
4245
})
4346
}
4447

48+
componentDidMount() {
49+
this.props.router.setRouteLeaveHook(this.props.route, this.onLeave)
50+
window.addEventListener('beforeunload', this.onLeave)
51+
}
52+
53+
componentWillUnmount() {
54+
window.removeEventListener('beforeunload', this.onLeave)
55+
}
56+
57+
// Notify user if they navigate away while the form is modified.
58+
onLeave(e) {
59+
if (this.isChanged()) {
60+
return e.returnValue = 'You have unsaved changes. Are you sure you want to leave?'
61+
}
62+
}
63+
64+
isChanged() {
65+
// We check if this.refs.form exists because this may be called before the
66+
// first render, in which case it will be undefined.
67+
return (this.refs.form && this.refs.form.isChanged()) || this.state.isFeaturesDirty
68+
}
4569

4670
enableButton() {
4771
this.setState( { canSubmit: true })
@@ -102,7 +126,7 @@ class EditProjectForm extends Component {
102126
/>
103127
<div className="section-footer section-footer-spec">
104128
<button className="tc-btn tc-btn-primary tc-btn-md"
105-
type="submit" disabled={!this.state.canSubmit || this.state.isSaving }
129+
type="submit" disabled={!this.isChanged() || this.state.isSaving}
106130
>Save Changes</button>
107131
</div>
108132
</div>
@@ -146,4 +170,4 @@ EditProjectForm.propTypes = {
146170
submitHandler: PropTypes.func.isRequired
147171
}
148172

149-
export default EditProjectForm
173+
export default withRouter(EditProjectForm)

src/projects/detail/containers/SpecificationContainer.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class SpecificationContainer extends Component {
6767
isEdittable={!!currentMemberRole}
6868
submitHandler={this.saveProject}
6969
saving={processing}
70+
route={this.props.route}
7071
/>
7172
</div>
7273

src/projects/list/components/Projects/Projects.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Projects extends Component {
2424
if (!_.isEmpty(queryParams)) {
2525
const initialCriteria = {}
2626
if (queryParams.sort) initialCriteria.sort = queryParams.sort
27-
if (queryParams.name) initialCriteria.name = decodeURIComponent(queryParams.name)
27+
if (queryParams.keyword) initialCriteria.keyword = decodeURIComponent(queryParams.keyword)
2828
if (queryParams.status) initialCriteria.status = queryParams.status
2929
if (queryParams.type) initialCriteria.type = queryParams.type
3030
if (queryParams.memberOnly) initialCriteria.memberOnly = queryParams.memberOnly

0 commit comments

Comments
 (0)