Skip to content

Commit

Permalink
fix bundling issues related to created status
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Jul 22, 2024
1 parent 1237106 commit 43ac559
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
onBulkTaskSelection = taskIds => {
const tasks = this.clustersAsTasks().filter(task => {
const taskId = task.id || task.taskId
return taskIds.includes(taskId) &&
const alreadyBundled = task.bundleId && this.props.taskBundle?.id !== task.bundleId

return taskIds.includes(taskId) && !alreadyBundled &&
!(
this.props.task &&
![0, 3, 6].includes(task.taskStatus || task.status) &&
Expand Down
11 changes: 4 additions & 7 deletions src/components/HOCs/WithTaskBundle/WithTaskBundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,9 @@ export function WithTaskBundle(WrappedComponent) {

componentDidMount() {
const { task } = this.props
this.setBundlingConditions()
this.setState({ completingTask: null })

if (_isFinite(_get(task, 'bundleId')) && task?.status === 0) {
this.props.deleteTaskBundle(task.bundleId)
} else if (_isFinite(_get(task, 'bundleId'))){
if (_isFinite(_get(task, 'bundleId'))){
this.setupBundle(task.bundleId)
}

Expand All @@ -43,7 +40,6 @@ export function WithTaskBundle(WrappedComponent) {
const { initialBundle } = this.state
const { task } = this.props
if (_get(task, 'id') !== _get(prevProps, 'task.id')) {
this.setBundlingConditions()
this.setState({ selectedTasks: [], initialBundle: null, taskBundle: null, loading: false, completingTask: null })
if (_isFinite(_get(task, 'bundleId'))) {
this.setupBundle(task.bundleId)
Expand Down Expand Up @@ -94,7 +90,7 @@ export function WithTaskBundle(WrappedComponent) {

const bundleEditsDisabled = taskReadOnly || (!enableMapperEdits && !enableSuperUserEdits)

this.setState({ bundleEditsDisabled })
return bundleEditsDisabled
}

handleBeforeUnload = () => {
Expand Down Expand Up @@ -161,7 +157,8 @@ export function WithTaskBundle(WrappedComponent) {
}
}
}
this.setState({ initialBundle: taskBundle, selectedTasks: taskBundle?.taskIds, taskBundle })
const bundleEditsDisabled = this.setBundlingConditions()
this.setState({ bundleEditsDisabled, initialBundle: taskBundle, selectedTasks: taskBundle?.taskIds, taskBundle })
})
this.setState({ loading: false })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ export const WithTaskClusterMarkers = function(WrappedComponent) {
updateMapMarkers() {
const markers = _map(this.props.taskClusters, cluster => {
const cluserStatus = cluster.status ?? cluster.taskStatus
const clusterId = cluster.id ?? cluster.taskId
const clusterId = cluster.id ?? cluster.taskId
const alreadyBundled = cluster.bundleId && !this.props.taskBundle?.id !== cluster.bundleId

const bundleConflict = Boolean(
clusterId &&
(clusterId &&
this.props.task &&
![0, 3, 6].includes(cluserStatus) &&
!this.props.taskBundle?.taskIds?.includes(clusterId) &&
!this.props.initialBundle?.taskIds?.includes(clusterId)
!this.props.initialBundle?.taskIds?.includes(clusterId)) ||
alreadyBundled
)

return AsMappableCluster(cluster).mapMarker(
Expand Down
2 changes: 2 additions & 0 deletions src/components/TaskAnalysisTable/TaskAnalysisTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ const setupColumnTypes = (props, taskBaseRoute, manager, data, openComments) =>
accessor: task => props.isTaskSelected(task.id),
Cell: ({ value, original }) => {
const status = original.status ?? original.taskStatus
const alreadyBundled = original.bundleId && !props.taskBundle?.id !== original.bundleId
const enableSelecting =
!alreadyBundled &&
!props.bundling &&
!props.taskReadOnly &&
[0, 3, 6].includes(status) &&
Expand Down
6 changes: 3 additions & 3 deletions src/components/TaskPane/TaskPane.js
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ TaskPane.propTypes = {
export default
WithChallengePreferences(
WithWidgetWorkspaces(
WithTaskBundle(
WithCooperativeWork(
WithLockedTask(
WithCooperativeWork(
WithLockedTask(
WithTaskBundle(
injectIntl(TaskPane)
)
),
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 @@ -59,6 +59,11 @@ export default defineMessages({
defaultMessage: "Selected",
},

alreadyBundledLabel: {
id: "Widgets.TaskBundleWidget.popup.controls.alreadyBundled.label",
defaultMessage: "Already bundled by someone else.",
},

bundleTasksLabel: {
id: "Widgets.TaskBundleWidget.controls.startBundling.label",
defaultMessage: "Start Bundling Tasks",
Expand Down
3 changes: 2 additions & 1 deletion src/components/Widgets/TaskBundleWidget/TaskMarkerContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class TaskMarkerContent extends Component {
const bundlePrimary = this.props.taskBundle?.tasks.find(task => task.isBundlePrimary === true)
const statusMessage = messagesByStatus[this.props.marker.options.status ?? this.props.marker.options.taskStatus]
const priorityMessage = messagesByPriority[this.props.marker.options.priority ?? this.props.marker.options.taskPriority ]
const alreadyBundled = this.props.marker.options.bundleId && !this.props.taskBundle?.taskIds?.includes(this.props.marker.options.bundleId)

const checkBoxEnabled =
!this.props.bundling &&
Expand Down Expand Up @@ -80,7 +81,7 @@ class TaskMarkerContent extends Component {

<div className="mr-flex mr-justify-center mr-mt-2">
<label>
{checkBoxEnabled ? (
{alreadyBundled ? <FormattedMessage {...messages.alreadyBundledLabel} /> : checkBoxEnabled ? (
<input
type="checkbox"
className="mr-mr-1"
Expand Down

0 comments on commit 43ac559

Please sign in to comment.