Skip to content

Commit 720d8c2

Browse files
authored
Merge pull request #2811 from appirio-tech/feature/filter-projects-by-columns
Filter project table by columns
2 parents b265876 + bdaa780 commit 720d8c2

File tree

8 files changed

+182
-291
lines changed

8 files changed

+182
-291
lines changed

src/components/Grid/GridView.jsx

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,17 @@ const GridView = props => {
3535
<LoadingIndicator />
3636
) : (
3737
<div className="container">
38-
{resultSet.length ? (
39-
<div className="flex-area">
40-
<div className="flex-data">
41-
<ListHeader {...headerProps} />
42-
{resultSet.map(renderItem)}
43-
</div>
44-
<PaginationBar {...paginationProps} />
45-
</div>
46-
) : (
47-
<div className="flex-area">
48-
{/* TODO replace this with proper style */}
49-
<div style={{textAlign: 'center'}}><br/><br/><h3> No results </h3><br/><br/></div>
38+
<div className="flex-area">
39+
<div className="flex-data">
40+
<ListHeader {...headerProps} />
41+
{resultSet.length ? (
42+
resultSet.map(renderItem)
43+
) : (
44+
<div style={{textAlign: 'center'}}><br/><br/><h3> No results </h3><br/><br/></div>
45+
)}
5046
</div>
51-
)}
47+
<PaginationBar {...paginationProps} />
48+
</div>
5249
</div>
5350
)
5451
)
@@ -77,6 +74,15 @@ const GridView = props => {
7774
>
7875
{[...resultSet, ...placeholders].map(renderItem)}
7976
</InfiniteScroll>
77+
{totalCount === 0 && <section className="content gridview-content">
78+
<div key="end" className="gridview-no-project">
79+
No results found based on current search criteria. <br /> Please modify your search criteria and/or search across all projects by selecting the "
80+
<a href="javascript:" onClick={() => { applyFilters({status: null }) }} className="tc-btn-all-projects" >
81+
All Projects
82+
</a>
83+
" filter.
84+
</div>
85+
</section>}
8086
</div>
8187
</div>
8288
</div>
@@ -94,20 +100,6 @@ const GridView = props => {
94100
)
95101
}
96102

97-
if (totalCount === 0) {
98-
return (
99-
<section className="content gridview-content">
100-
<div key="end" className="gridview-no-project">
101-
No results found based on current search criteria. <br /> Please modify your search criteria and/or search across all projects by selecting the "
102-
<a href="javascript:" onClick={() => { applyFilters({status: null }) }} className="tc-btn-all-projects" >
103-
All Projects
104-
</a>
105-
" filter.
106-
</div>
107-
</section>
108-
)
109-
}
110-
111103
return (
112104
<section className="content gridview-content">
113105
{infiniteScroll ? renderGridWithInfiniteScroll() : renderGridWithPagination()}

src/components/TopBar/Filters.js

Lines changed: 0 additions & 70 deletions
This file was deleted.

src/components/TopBar/ProjectsToolBar.js

Lines changed: 3 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ import PropTypes from 'prop-types'
55
import querystring from 'query-string'
66
import { withRouter, Prompt } from 'react-router-dom'
77
import { connect } from 'react-redux'
8-
import cn from 'classnames'
98
import _ from 'lodash'
109
import SearchBar from 'appirio-tech-react-components/components/SearchBar/SearchBar'
1110
import MenuBar from 'appirio-tech-react-components/components/MenuBar/MenuBar'
12-
import Filters from './Filters'
1311
import NotificationsDropdown from '../NotificationsDropdown/NotificationsDropdownContainer'
1412
import NewProjectNavLink from './NewProjectNavLink'
1513
import MobileMenu from '../MobileMenu/MobileMenu'
1614
import MobileMenuToggle from '../MobileMenu/MobileMenuToggle'
17-
import SearchFilter from '../../assets/icons/ui-filters.svg'
18-
import SearchIcon from '../../assets/icons/ui-16px-1_zoom.svg'
1915
import { projectSuggestions, loadProjects, setInfiniteAutoload } from '../../projects/actions/loadProjects'
2016
import { loadProjectsMetadata } from '../../actions/templates'
2117
import { getNewProjectLink } from '../../helpers/projectHelper'
@@ -26,17 +22,13 @@ class ProjectsToolBar extends Component {
2622
super(props)
2723
this.state = {
2824
errorCreatingProject: false,
29-
isFilterVisible: false,
3025
isMobileMenuOpen: false,
3126
isMobileSearchVisible: false
3227
}
33-
this.state.isFilterVisible = sessionStorage.getItem('isFilterVisible') === 'true'
3428
this.applyFilters = this.applyFilters.bind(this)
35-
this.toggleFilter = this.toggleFilter.bind(this)
3629
this.handleTermChange = this.handleTermChange.bind(this)
3730
this.handleSearch = this.handleSearch.bind(this)
3831
this.toggleMobileMenu = this.toggleMobileMenu.bind(this)
39-
this.toggleMobileSearch = this.toggleMobileSearch.bind(this)
4032
this.onLeave = this.onLeave.bind(this)
4133
}
4234

@@ -74,10 +66,6 @@ class ProjectsToolBar extends Component {
7466
}
7567

7668
componentDidMount() {
77-
const contentDiv = document.getElementById('wrapper-main')
78-
if (this.state.isFilterVisible) {
79-
contentDiv.classList.add('with-filters')
80-
}
8169
// sets window unload hook to show unsaved changes alert and persist incomplete project
8270
window.addEventListener('beforeunload', this.onLeave)
8371
}
@@ -125,38 +113,10 @@ class ProjectsToolBar extends Component {
125113
this.routeWithParams(criteria)
126114
}
127115

128-
toggleFilter() {
129-
const {isFilterVisible, isMobileSearchVisible} = this.state
130-
const contentDiv = document.getElementById('wrapper-main')
131-
this.setState({isFilterVisible: !isFilterVisible}, () => {
132-
sessionStorage.setItem('isFilterVisible', (!isFilterVisible).toString())
133-
if (this.state.isFilterVisible) {
134-
contentDiv.classList.add('with-filters')
135-
} else {
136-
contentDiv.classList.remove('with-filters')
137-
}
138-
})
139-
// if open filters, close search panel on mobile
140-
if (!isFilterVisible && isMobileSearchVisible) {
141-
this.toggleMobileSearch()
142-
}
143-
}
144-
145116
toggleMobileMenu() {
146117
this.setState({ isMobileMenuOpen: !this.state.isMobileMenuOpen })
147118
}
148119

149-
toggleMobileSearch() {
150-
const { isFilterVisible, isMobileSearchVisible } = this.state
151-
152-
// if open mobile search and filter is visible, then close filter
153-
if (!isMobileSearchVisible && isFilterVisible) {
154-
this.toggleFilter()
155-
}
156-
157-
this.setState({ isMobileSearchVisible: !isMobileSearchVisible })
158-
}
159-
160120
routeWithParams(criteria) {
161121
// because criteria is changed disable infinite autoload
162122
this.props.setInfiniteAutoload(false)
@@ -171,7 +131,7 @@ class ProjectsToolBar extends Component {
171131

172132
shouldComponentUpdate(nextProps, nextState) {
173133
const { user, criteria, creatingProject, projectCreationError, searchTermTag, projectTypes } = this.props
174-
const { errorCreatingProject, isFilterVisible, isMobileMenuOpen, isMobileSearchVisible } = this.state
134+
const { errorCreatingProject, isMobileMenuOpen, isMobileSearchVisible } = this.state
175135
return (nextProps.user || {}).handle !== (user || {}).handle
176136
|| (nextProps.user || {}).photoURL !== (this.props.user || {}).photoURL
177137
|| JSON.stringify(nextProps.criteria) !== JSON.stringify(criteria)
@@ -180,24 +140,15 @@ class ProjectsToolBar extends Component {
180140
|| nextProps.searchTermTag !== searchTermTag
181141
|| !!nextProps.projectTypes && !projectTypes
182142
|| nextState.errorCreatingProject !== errorCreatingProject
183-
|| nextState.isFilterVisible !== isFilterVisible
184143
|| nextState.isMobileMenuOpen !== isMobileMenuOpen
185144
|| nextState.isMobileSearchVisible !== isMobileSearchVisible
186145
}
187146

188147
render() {
189-
const { renderLogoSection, userMenu, userRoles, criteria, isPowerUser, user, mobileMenu, location, projectTypes, orgConfig } = this.props
190-
const { isFilterVisible, isMobileMenuOpen, isMobileSearchVisible } = this.state
148+
const { renderLogoSection, userMenu, userRoles, isPowerUser, user, mobileMenu, location, orgConfig } = this.props
149+
const { isMobileMenuOpen, isMobileSearchVisible } = this.state
191150
const isLoggedIn = !!(userRoles && userRoles.length)
192151

193-
let excludedFiltersCount = 1 // 1 for default sort criteria
194-
if (criteria.memberOnly) {
195-
// https://github.com/appirio-tech/connect-app/issues/1319
196-
// The switch should not count as a filter in the menu!
197-
excludedFiltersCount++
198-
}
199-
// Ignore status from filters count
200-
const noOfFilters = _.keys(_.omit(criteria, ['status', 'keyword'])).length - excludedFiltersCount
201152
const onLeaveMessage = this.onLeave() || ''
202153

203154
const primaryNavigationItems = [
@@ -240,20 +191,6 @@ class ProjectsToolBar extends Component {
240191
onSearch={ this.handleSearch }
241192
onClearSearch={ this.handleSearch }
242193
/>
243-
<div className="search-filter">
244-
<a
245-
href="javascript:"
246-
className={cn('tc-btn tc-btn-sm mobile-search-toggle', {active: isMobileSearchVisible})}
247-
onClick={ this.toggleMobileSearch }
248-
><SearchIcon /></a>
249-
{ !!projectTypes &&
250-
<a
251-
href="javascript:"
252-
className={cn('tc-btn tc-btn-sm', {active: isFilterVisible})}
253-
onClick={ this.toggleFilter }
254-
><SearchFilter className="icon-search-filter" /><span className="filter-text">Filters</span> { noOfFilters > 0 && <span className="filter-indicator">{ noOfFilters }</span> }</a>
255-
}
256-
</div>
257194
</div>
258195
}
259196
<div className="actions">
@@ -277,15 +214,6 @@ class ProjectsToolBar extends Component {
277214
/>
278215
</div>
279216
}
280-
{ !!projectTypes && isFilterVisible && isLoggedIn &&
281-
<div className="secondary-toolbar">
282-
<Filters
283-
applyFilters={ this.applyFilters }
284-
criteria={ criteria }
285-
projectTypes={ projectTypes }
286-
/>
287-
</div>
288-
}
289217
{isMobileMenuOpen && <MobileMenu user={user} onClose={this.toggleMobileMenu} menu={mobileMenu} />}
290218
</div>
291219
)

0 commit comments

Comments
 (0)