Skip to content

Commit 4852751

Browse files
author
Vikas Agarwal
committed
Github issue#1212, Filter project types in admin view
— Fixed. Made the list of the project types to be dynamic. It was hard coded earlier because earlier we were showing different label in filters than what we have in the projectWizard/index.js
1 parent de0c30e commit 4852751

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/components/TopBar/Filters.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@ import React, {PropTypes} from 'react'
22
import _ from 'lodash'
33
import { Dropdown, DropdownItem, SwitchButton } from 'appirio-tech-react-components'
44
import { PROJECT_STATUS } from '../../config/constants'
5-
6-
const projectTypes = [
7-
{ val: null, label: 'All Types' },
8-
{ val: 'generic', label: 'Work Project' },
9-
{ val: 'visual_design', label: 'Visual Design' },
10-
{ val: 'visual_prototype', label: 'Visual Prototype' },
11-
{ val: 'app_dev', label: 'App Development' }
12-
]
5+
import { projectTypes } from '../../config/projectWizard'
136

147
const projectStatuses = [
158
{ val: 'in(draft,in_review,reviewed,active)', label: 'Open' },
@@ -19,12 +12,15 @@ const projectStatuses = [
1912

2013
const Filters = ({ criteria, handleMyProjectsFilter, applyFilters }) => {
2114

22-
const type = _.find(projectTypes, t => t.val === (criteria.type || null))
15+
const type = _.find(projectTypes, t => t.id === (criteria.type || null))
2316
const status = _.find(projectStatuses, t => t.val === (criteria.status || null))
2417

2518
const _types = _.map(projectTypes, p => {
26-
return { val: { type: p.val }, label: p.label }
19+
return { val: { type: p.id }, label: p.name }
2720
})
21+
// adds null valued object for All Types selection
22+
_types.splice(0, 0, { val: { type: null}, label: 'All Types' })
23+
2824
const _statuses = _.map(projectStatuses, p => {
2925
return { val: { status: p.val }, label: p.label }
3026
})
@@ -36,7 +32,7 @@ const Filters = ({ criteria, handleMyProjectsFilter, applyFilters }) => {
3632
<label className="first">Project Type</label>
3733
<div className="search-select-widget">
3834
<Dropdown theme="new-theme" noPointer pointerShadow>
39-
<a className="dropdown-menu-header">{ type.label || 'All Types' }</a>
35+
<a className="dropdown-menu-header">{ _.get(type, 'name') || 'All Types' }</a>
4036
<ul className="dropdown-menu-list">
4137
{
4238
_types.map((item, i) =>

src/config/projectWizard/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ const products = {
171171

172172
export default products
173173

174+
// exports all project types as an array
175+
export const projectTypes = _.mapValues(products, (p, key) => ({...p, name: key }) )
176+
174177
export function findProduct(product) {
175178
if (product === 'generic_dev') {
176179
return 'Development'

0 commit comments

Comments
 (0)