-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add: third dashboard panel (Unassigned tours)
- Loading branch information
1 parent
7945e07
commit 9f2162b
Showing
13 changed files
with
402 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -580,6 +580,47 @@ Feature: Dispatch | |
} | ||
""" | ||
|
||
Scenario: Add/reorder tasks of a tour | ||
Given the fixtures files are loaded: | ||
| dispatch.yml | | ||
And the user "sarah" has role "ROLE_ADMIN" | ||
And the user "sarah" is authenticated | ||
When I add "Content-Type" header equal to "application/ld+json" | ||
And I add "Accept" header equal to "application/ld+json" | ||
And the user "sarah" sends a "PUT" request to "/api/tour/5" with body: | ||
""" | ||
{ | ||
"name":"Monday tour", | ||
"tasks":[ | ||
"/api/tasks/1", | ||
"/api/tasks/2", | ||
"/api/tasks/3", | ||
] | ||
} | ||
""" | ||
Then the response status code should be 201 | ||
And the response should be in JSON | ||
And the JSON should match: | ||
""" | ||
{ | ||
"@context":"/api/contexts/Tour", | ||
"@id":"/api/tours/5", | ||
"@type":"Tour", | ||
"name":"Monday tour", | ||
"items":[ | ||
"/api/tasks/1", | ||
"/api/tasks/2", | ||
"/api/tasks/3", | ||
], | ||
"distance":@integer@, | ||
"duration":@integer@, | ||
"polyline":@string@, | ||
"createdAt":"@[email protected]()", | ||
"updatedAt":"@[email protected]()" | ||
} | ||
""" | ||
|
||
|
||
Scenario: Administrator can assign multiple tasks at once | ||
Given the fixtures files are loaded: | ||
| sylius_channels.yml | | ||
|
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,73 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
import { withTranslation, useTranslation } from 'react-i18next' | ||
import { Draggable, Droppable } from "react-beautiful-dnd" | ||
import _ from 'lodash' | ||
import Task from './Task' | ||
|
||
const UnassignedTour = ({ tour, tasks, username = null, unassignTasks = null, isDropDisabled }) => { | ||
|
||
const { t } = useTranslation() | ||
|
||
const collapseId = `tour-panel-${tour['@id'].replaceAll('/', '-')}` | ||
|
||
return ( | ||
<div className="panel panel-default nomargin task__draggable"> | ||
<div className="panel-heading" role="tab"> | ||
<h4 className="panel-title d-flex align-items-center"> | ||
<i className="fa fa-repeat flex-grow-0"></i> | ||
<a role="button" data-toggle="collapse" href={ `#${collapseId}` } className="ml-2 flex-grow-1 text-truncate"> | ||
{ tour.name } <span className="badge">{ tasks.length }</span> | ||
</a> | ||
{ username && ( | ||
<a | ||
onClick={() => unassignTasks(username, tasks)} | ||
title={ t('ADMIN_DASHBOARD_UNASSIGN_TOUR', { name: tour.name }) } | ||
> | ||
<i className="fa fa-times"></i> | ||
</a> | ||
)} | ||
</h4> | ||
</div> | ||
<div id={ `${collapseId}` } className="panel-collapse collapse" role="tabpanel"> | ||
<Droppable isDropDisabled={isDropDisabled} droppableId={ `unassigned_tour:${tour['@id'].replace('/api/tours/', '')}` }> | ||
{(provided) => ( | ||
<div className="list-group list-group-padded nomargin taskList__tasks m-0" ref={ provided.innerRef } { ...provided.droppableProps }> | ||
{ _.map(tasks, (task, index) => { | ||
return ( | ||
<Draggable key={ `task-${task.id}` } draggableId={ `task:${task.id}` } index={ index }> | ||
{(provided) => ( | ||
<div | ||
ref={ provided.innerRef } | ||
{ ...provided.draggableProps } | ||
{ ...provided.dragHandleProps } | ||
> | ||
<Task | ||
key={ task['@id'] } | ||
task={ task } | ||
assigned={ false } | ||
/> | ||
</div> | ||
)} | ||
</Draggable> | ||
) | ||
})} | ||
{ provided.placeholder } | ||
</div> | ||
)} | ||
</Droppable> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
function mapStateToProps (state) { | ||
|
||
return { | ||
isDropDisabled: state.logistics.ui.unassignedTourTasksDroppableDisabled, | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps)(withTranslation()(UnassignedTour)) | ||
|
||
// export default withTranslation()(UnassignedTour) |
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,60 @@ | ||
import React from 'react' | ||
import _ from 'lodash' | ||
import { connect } from 'react-redux' | ||
import { withTranslation } from 'react-i18next' | ||
import { Draggable, Droppable } from "react-beautiful-dnd" | ||
|
||
import UnassignedTour from './UnassignedTour' | ||
import { selectUnassignedTours } from '../redux/selectors' | ||
|
||
|
||
class UnassignedTours extends React.Component { | ||
|
||
render() { | ||
return ( | ||
<div className="dashboard__panel"> | ||
<h4 className="d-flex justify-content-between"> | ||
<span>{ this.props.t('DASHBOARD_UNASSIGNED_TOURS') }</span> | ||
</h4> | ||
<div className="dashboard__panel__scroll"> | ||
<Droppable isDropDisabled={ this.props.isDropDisabled } droppableId="unassigned_tours"> | ||
{(provided) => ( | ||
<div className="list-group nomargin" ref={ provided.innerRef } { ...provided.droppableProps }> | ||
{ _.map(this.props.tours, (tour, index) => { | ||
return ( | ||
<Draggable key={ `tour-${tour['@id']}` } draggableId={ `tour:${tour['@id']}` } index={ index }> | ||
{(provided) => ( | ||
<div | ||
ref={ provided.innerRef } | ||
{ ...provided.draggableProps } | ||
{ ...provided.dragHandleProps } | ||
> | ||
<UnassignedTour | ||
key={ tour['@id'] } | ||
tour={ tour } | ||
tasks={ tour.items } | ||
/> | ||
</div> | ||
)} | ||
</Draggable> | ||
) | ||
})} | ||
{ provided.placeholder } | ||
</div> | ||
)} | ||
</Droppable> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
function mapStateToProps (state) { | ||
|
||
return { | ||
tours: selectUnassignedTours(state), | ||
isDropDisabled: state.logistics.ui.unassignedToursDroppableDisabled | ||
} | ||
} | ||
|
||
export default connect(mapStateToProps)(withTranslation()(UnassignedTours)) |
Oops, something went wrong.