Skip to content

Commit

Permalink
add broken task handler
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Aug 2, 2023
1 parent d2d0792 commit 78f8493
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export class ActiveTaskControls extends Component {

return (
<div>
{!isEditingTask && isComplete &&
{this.props.task.geometries.features !== null ? !isEditingTask && isComplete &&
<div className="mr-text-white mr-text-md mr-my-4 mr-links-green-lighter">
<div className="mr-flex mr-justify-between mr-items-center">
<span>
Expand All @@ -288,6 +288,9 @@ export class ActiveTaskControls extends Component {
<FormattedMessage {...messages.awaitingReview} />
</div>
}
</div> :
<div className="mr-text-lg mr-text-red-light mr-flex">
<FormattedMessage {...messages.brokenTask} />
</div>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export default defineMessages({
defaultMessage: "Task is awaiting review.",
},

brokenTask: {
id: 'Task.brokenTask.label',
defaultMessage: "This task is broken!",
},

readOnly: {
id: 'Task.readonly.message',
defaultMessage: "Previewing task in read-only mode",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ export default class TaskNextControl extends Component {
}

render() {
if(this.props.task.geometries.features === null){
return (
<button
className={classNames("mr-button mr-button--white mr-w-full", this.props.className)}
onClick={() => {
if (this.props.loadBy === TaskLoadMethod.proximity) {
this.setState({chooseNearbyTasks: true})
}
else {
this.props.nextTask(this.props.task.parent.id, this.props.task.id)
}
}}
>
<FormattedMessage {...messages.nextLabel} />
</button>
)
}

const loadNearbyModal =
<External>
<Modal
Expand Down
5 changes: 5 additions & 0 deletions src/components/Widgets/TaskBundleWidget/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ export default defineMessages({
id: "Widgets.TaskBundleWidget.readOnly",
defaultMessage: "Previewing task in read-only mode",
},

mapFailed: {
id: "Widgets.mapFailed",
defaultMessage: "Widget Failed",
},
})
17 changes: 11 additions & 6 deletions src/components/Widgets/TaskBundleWidget/TaskBundleWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,18 @@ export default class TaskBundleWidget extends Component {
}
noMain
>
{!this.props.task.geometries.features === null ?
<WidgetContent
{...this.props}
updateBounds={this.updateBounds}
bundleTasks={this.bundleTasks}
unbundleTasks={this.unbundleTasks}
loading={this.props.loading}
/>
{...this.props}
updateBounds={this.updateBounds}
bundleTasks={this.bundleTasks}
unbundleTasks={this.unbundleTasks}
loading={this.props.loading}
/> :
<div className="mr-text-lg mr-text-red-light mr-flex">
<FormattedMessage {...messages.mapFailed} />
</div>
}
</QuickWidget>
)
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/Widgets/TaskMapWidget/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default defineMessages({

title: {
id: "Widgets.TaskMapWidget.title",
defaultMessage: "Task",
defaultMessage: "Task Map",
},
mapFailed: {
id: "Widgets.mapFailed",
defaultMessage: "Widget Failed",
},
})
16 changes: 12 additions & 4 deletions src/components/Widgets/TaskMapWidget/TaskMapWidget.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
import { FormattedMessage } from 'react-intl'
import { WidgetDataTarget, registerWidgetType }
from '../../../services/Widget/Widget'
import MapPane from '../../EnhancedMap/MapPane/MapPane'
Expand All @@ -23,11 +24,18 @@ export default class TaskMapWidget extends Component {
{...this.props}
className="task-map-widget"
noMain
permanent
widgetTitle={
<FormattedMessage {...messages.title} />
}
>
<MapPane {...this.props}>
<TaskMap {...this.props} challenge={this.props.task.parent} />
</MapPane>
{!this.props.task.geometries.features === null ?
<MapPane {...this.props}>
<TaskMap {...this.props} challenge={this.props.task.parent} />
</MapPane>:
<div className="mr-text-lg mr-text-red-light mr-flex">
<FormattedMessage {...messages.mapFailed} />
</div>
}
</QuickWidget>
)
}
Expand Down
1 change: 1 addition & 0 deletions src/services/Error/AppErrors.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export default {
searchFailure: messages.projectSearchFailure,
deleteFailure: messages.projectDeleteFailure,
notManager: messages.projectNotManager,
brokenTask: messages.projectBrokenTask,
},

map: {
Expand Down
4 changes: 4 additions & 0 deletions src/services/Error/Messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ export default defineMessages({
id: "Errors.project.notManager",
defaultMessage: "You must be a manager of that project to proceed.",
},
projectBrokenTask: {
id: "Errors.project.brokenTask",
defaultMessage: "Error in task: {Features: Null} - This task is broken.",
},

mapRenderFailure: {
id: "Errors.map.renderFailure",
Expand Down
4 changes: 4 additions & 0 deletions src/services/Task/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ export const fetchTask = function(taskId, suppressReceive=false, includeMapillar
variables: {id: taskId},
params: {mapillary: includeMapillary}
}).execute().then(normalizedResults => {
if (_get(normalizedResults.entities.tasks, taskId).geometries.features === null) {
dispatch(addError(AppErrors.project.brokenTask));
}

if (!suppressReceive) {
dispatch(receiveTasks(normalizedResults.entities))
}
Expand Down

0 comments on commit 78f8493

Please sign in to comment.