Skip to content

Commit

Permalink
fix(departments): issue with creating department with no teams #206
Browse files Browse the repository at this point in the history
  • Loading branch information
polonel committed Jun 7, 2019
1 parent cc3a880 commit 94ff47a
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 77 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "trudesk",
"version": "1.0.13",
"version": "1.0.14-beta",
"private": true,
"engines": {
"node": ">=9.10.0"
Expand Down
141 changes: 73 additions & 68 deletions src/client/containers/Departments/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,76 +114,81 @@ class DepartmentsContainer extends React.Component {
</tr>
</thead>
<tbody className={'scrollable full-height'}>
{this.props.departments.map(department => {
return (
<tr key={department.get('_id')}>
{/*<td style={{ padding: '17px 18px', verticalAlign: 'middle' }}>*/}
{/* <input*/}
{/* type='checkbox'*/}
{/* id={'c_' + department.get('_id')}*/}
{/* style={{ display: 'none' }}*/}
{/* className='svgcheckinput'*/}
{/* />*/}
{/* <label htmlFor={'c_' + department.get('_id')} className='svgcheck'>*/}
{/* <svg width='16px' height='16px' viewBox='0 0 18 18'>*/}
{/* <path d='M1,9 L1,3.5 C1,2 2,1 3.5,1 L14.5,1 C16,1 17,2 17,3.5 L17,14.5 C17,16 16,17 14.5,17 L3.5,17 C2,17 1,16 1,14.5 L1,9 Z' />*/}
{/* <polyline points='1 9 7 14 15 4' />*/}
{/* </svg>*/}
{/* </label>*/}
{/*</td>*/}
<td style={{ verticalAlign: 'middle', padding: '8px 8px 8px 26px' }}>
<div style={{ fontWeight: '500' }}>{department.get('name')}</div>
</td>
<td style={{ verticalAlign: 'middle' }}>
{department.get('teams').map(team => {
return (
<div key={team.get('_id')} style={{ marginBottom: 4 }}>
{team.get('name')}
{this.props.departments &&
this.props.departments.map(department => {
const teams = department.get('teams')
const groups = department.get('groups')
return (
<tr key={department.get('_id')}>
{/*<td style={{ padding: '17px 18px', verticalAlign: 'middle' }}>*/}
{/* <input*/}
{/* type='checkbox'*/}
{/* id={'c_' + department.get('_id')}*/}
{/* style={{ display: 'none' }}*/}
{/* className='svgcheckinput'*/}
{/* />*/}
{/* <label htmlFor={'c_' + department.get('_id')} className='svgcheck'>*/}
{/* <svg width='16px' height='16px' viewBox='0 0 18 18'>*/}
{/* <path d='M1,9 L1,3.5 C1,2 2,1 3.5,1 L14.5,1 C16,1 17,2 17,3.5 L17,14.5 C17,16 16,17 14.5,17 L3.5,17 C2,17 1,16 1,14.5 L1,9 Z' />*/}
{/* <polyline points='1 9 7 14 15 4' />*/}
{/* </svg>*/}
{/* </label>*/}
{/*</td>*/}
<td style={{ verticalAlign: 'middle', padding: '8px 8px 8px 26px' }}>
<div style={{ fontWeight: '500' }}>{department.get('name')}</div>
</td>
<td style={{ verticalAlign: 'middle' }}>
{teams &&
teams.map(team => {
return (
<div key={team.get('_id')} style={{ marginBottom: 4 }}>
{team.get('name')}
</div>
)
})}
</td>
<td style={{ verticalAlign: 'middle' }}>
{department.get('allGroups') === true && (
<div>
<h6 className={'text-success'} style={{ fontWeight: 'bold' }}>
All Groups
</h6>
</div>
)
})}
</td>
<td style={{ verticalAlign: 'middle' }}>
{department.get('allGroups') === true && (
<div>
<h6 className={'text-success'} style={{ fontWeight: 'bold' }}>
All Groups
</h6>
</div>
)}
{department.get('allGroups') !== true &&
department.get('groups').map(group => {
return (
<div key={group.get('_id')} style={{ marginBottom: 4 }}>
{group.get('name')}
</div>
)
})}
</td>
<td>
<ButtonGroup>
{helpers.canUser('departments:update', true) && (
<Button
text={'Edit'}
small={true}
waves={true}
onClick={() => this.onEditDepartmentClick(department)}
/>
)}
{helpers.canUser('departments:delete', true) && (
<Button
text={'Delete'}
style={'danger'}
small={true}
waves={true}
onClick={() => this.onDeleteDepartmentClick(department.get('_id'))}
/>
)}
</ButtonGroup>
</td>
</tr>
)
})}
{department.get('allGroups') !== true &&
groups &&
groups.map(group => {
return (
<div key={group.get('_id')} style={{ marginBottom: 4 }}>
{group.get('name')}
</div>
)
})}
</td>
<td>
<ButtonGroup>
{helpers.canUser('departments:update', true) && (
<Button
text={'Edit'}
small={true}
waves={true}
onClick={() => this.onEditDepartmentClick(department)}
/>
)}
{helpers.canUser('departments:delete', true) && (
<Button
text={'Delete'}
style={'danger'}
small={true}
waves={true}
onClick={() => this.onDeleteDepartmentClick(department.get('_id'))}
/>
)}
</ButtonGroup>
</td>
</tr>
)
})}
</tbody>
</table>
</PageContent>
Expand Down
12 changes: 4 additions & 8 deletions src/client/containers/Modals/EditDepartmentModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class EditDepartmentModal extends React.Component {

render () {
const { department } = this.props
const departmentTeams = department.get('teams')
const departmentGroups = department.get('groups')
const mappedTeams = this.props.teams
.map(team => {
return { text: team.get('name'), value: team.get('_id') }
Expand Down Expand Up @@ -112,10 +114,7 @@ class EditDepartmentModal extends React.Component {
<label style={{ marginBottom: 5 }}>Teams</label>
<MultiSelect
items={mappedTeams}
initialSelected={department
.get('teams')
.map(d => d.get('_id'))
.toArray()}
initialSelected={departmentTeams ? departmentTeams.map(d => d.get('_id')).toArray() : []}
onChange={() => {}}
ref={r => (this.teamsSelect = r)}
/>
Expand Down Expand Up @@ -146,10 +145,7 @@ class EditDepartmentModal extends React.Component {
<MultiSelect
items={mappedGroups}
onChange={() => {}}
initialSelected={this.props.department
.get('groups')
.map(d => d.get('_id'))
.toArray()}
initialSelected={departmentGroups ? departmentGroups.map(d => d.get('_id')).toArray() : []}
ref={r => (this.groupSelect = r)}
disabled={this.allGroups}
/>
Expand Down

0 comments on commit 94ff47a

Please sign in to comment.