Skip to content

Commit

Permalink
add bundle resets on redirector and add map to bundling widget's bund…
Browse files Browse the repository at this point in the history
…led mode (#2291)

* add bundle resets on redirect

* add map to work on multiple tasks together widget and bundle tasks functions. Add other status's to map in widget as well

* fix conditions to prevent bundling in unwanted environments, increase cluster limit default, and add lasso back to pre-bundled task view in work on multiple tasks widget

* change the fetch bundle from a GET to a POST
  • Loading branch information
CollinBeczak authored May 12, 2024
1 parent f5aa51a commit c149d16
Show file tree
Hide file tree
Showing 32 changed files with 623 additions and 314 deletions.
2 changes: 1 addition & 1 deletion src/components/EnhancedMap/EnhancedMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export class EnhancedMap extends ReactLeafletMap {
this.leafletElement.panTo(this.props.center)
}

if (!_isEqual(this.props.fitToLayer, prevProps.fitToLayer)) {
if (!_isEqual(this.props.fitToLayer, prevProps.fitToLayer) || this.props.taskBundle !== prevProps.taskBundle) {
this.fitBoundsToLayer()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,25 @@ const LassoSelectionLeafletControl = L.Control.extend({
// build the control button, render it, and return it
const controlContent = (
<React.Fragment>
<button
onClick={() => {
deselecting = false
lasso.toggle()
this.options.onLassoInteraction && this.options.onLassoInteraction()
}}
className={classNames(
"mr-leading-none mr-p-2 mr-bg-black-50 mr-text-white mr-w-8 mr-h-8 mr-flex mr-items-center mr-transition-normal-in-out-quad hover:mr-text-green-lighter",
this.options.onLassoDeselection ? "mr-rounded-t-sm mr-border-b mr-border-white-15" : "mr-rounded-sm"
)}
>
<SvgSymbol
sym={this.options.onLassoDeselection ? "lasso-add-icon" : "lasso-icon"}
className="mr-w-4 mr-h-4 mr-fill-current mr-stroke-current"
viewBox="0 0 512 512"
/>
</button>
{this.options.onLassoSelection &&
<button
onClick={() => {
deselecting = false
lasso.toggle()
this.options.onLassoInteraction && this.options.onLassoInteraction()
}}
className={classNames(
"mr-leading-none mr-p-2 mr-bg-black-50 mr-text-white mr-w-8 mr-h-8 mr-flex mr-items-center mr-transition-normal-in-out-quad hover:mr-text-green-lighter",
this.options.onLassoDeselection ? "mr-rounded-t-sm mr-border-b mr-border-white-15" : "mr-rounded-sm"
)}
>
<SvgSymbol
sym={this.options.onLassoDeselection ? "lasso-add-icon" : "lasso-icon"}
className="mr-w-4 mr-h-4 mr-fill-current mr-stroke-current"
viewBox="0 0 512 512"
/>
</button>
}
{this.options.onLassoDeselection &&
<button
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import React, { Component } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import bboxPolygon from '@turf/bbox-polygon'
import booleanDisjoint from '@turf/boolean-disjoint'
import _omit from 'lodash/omit'
import _cloneDeep from 'lodash/cloneDeep'
import _get from 'lodash/get'
Expand All @@ -21,7 +19,6 @@ import { fetchTaskClusters, clearTaskClusters }
from '../../../services/Task/TaskClusters'
import { fetchBoundedTasks, clearBoundedTasks }
from '../../../services/Task/BoundedTask'
import AsMappableTask from '../../../interactions/Task/AsMappableTask'
import { MAX_ZOOM, UNCLUSTER_THRESHOLD } from '../../TaskClusterMap/TaskClusterMap'

/**
Expand All @@ -47,12 +44,6 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
const criteria = _cloneDeep(this.props.criteria)
criteria.boundingBox = arrayBounds.join(',')
this.props.updateTaskFilterBounds(bounds, zoom, fromUserAction)

// If task selection is active, prune any selections that no longer
// intersect with the new map bounds
this.props.pruneSelectedTasks && this.props.pruneSelectedTasks(task =>
booleanDisjoint(AsMappableTask(task).normalizedGeometries(), bboxPolygon(arrayBounds))
)
}
}

Expand Down Expand Up @@ -104,6 +95,10 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
_set(searchCriteria, 'filters.archived', true)
}

if (this.props.taskBundle && this.props.bundledOnly ){
_set(searchCriteria, 'filters.bundleId', this.props.taskBundle.bundleId)
}

if (process.env.REACT_APP_DISABLE_TASK_CLUSTERS && !overrideDisable) {
return this.setState({ loading: false })
}
Expand All @@ -119,7 +114,7 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
// (unless we are zoomed all the way in already)
if (results.totalCount > UNCLUSTER_THRESHOLD &&
_get(this.props, 'criteria.zoom', 0) < MAX_ZOOM) {
this.props.fetchTaskClusters(challengeId, searchCriteria, 25, overrideDisable
this.props.fetchTaskClusters(challengeId, searchCriteria, 500, overrideDisable
).then(results => {
const clusters = results.clusters
if (currentFetchId >= this.state.fetchId) {
Expand All @@ -140,7 +135,7 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
})
}
else {
this.props.fetchTaskClusters(challengeId, searchCriteria, 25, overrideDisable
this.props.fetchTaskClusters(challengeId, searchCriteria, 500, overrideDisable
).then(results => {
const clusters = results.clusters
if (currentFetchId >= this.state.fetchId) {
Expand Down Expand Up @@ -178,6 +173,10 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
else if (!_isEqual(_omit(prevProps.criteria, ['page', 'pageSize']),
_omit(this.props.criteria, ['page', 'pageSize']))) {
this.debouncedFetchClusters(this.state.showAsClusters)
} else if(this.props.taskBundle &&
(this.props.bundledOnly !== prevProps.bundledOnly ||
this.props.taskBundle !== prevProps.taskBundle)){
this.debouncedFetchClusters(this.state.showAsClusters)
}
}

Expand All @@ -200,8 +199,18 @@ export const WithChallengeTaskClusters = function(WrappedComponent, storeTasks=f
}

onBulkTaskSelection = taskIds => {
const tasks =
_filter(this.clustersAsTasks(), task => taskIds.indexOf(task.id) !== -1)
const tasks = this.clustersAsTasks().filter(task => {
const taskId = task.id || task.taskId
return taskIds.includes(taskId) &&
!(
this.props.task &&
![0, 3, 6].includes(task.taskStatus || task.status) &&
(!this.props.taskBundle?.taskIds?.includes(taskId) &&
!this.props.initialBundle?.taskIds?.includes(taskId))
) &&
taskId
})

this.props.onBulkTaskSelection(tasks)
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/HOCs/WithCurrentTask/WithCurrentTask.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ export const mapDispatchToProps = (dispatch, ownProps) => {
*/
saveTaskTags: (task, tags) => {
if (task.bundleId) {
dispatch(fetchTaskBundle(task.bundleId)).then(taskBundle => {
dispatch(fetchTaskBundle(task.bundleId), false).then(taskBundle => {
_each(taskBundle.tasks, task => {
dispatch(updateTaskTags(task.id, tags))
})
Expand Down
4 changes: 4 additions & 0 deletions src/components/HOCs/WithFilterCriteria/WithFilterCriteria.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export const WithFilterCriteria = function(WrappedComponent, ignoreURL = true,
loading: false,
criteria: DEFAULT_CRITERIA,
pageSize: DEFAULT_PAGE_SIZE,
bundledOnly: true
}

updateCriteria = (newCriteria) => {
Expand Down Expand Up @@ -330,6 +331,9 @@ export const WithFilterCriteria = function(WrappedComponent, ignoreURL = true,
updateCriteria={this.updateCriteria}
refreshTasks={this.refreshTasks}
clearAllFilters={this.clearAllFilters}
bundledOnly={this.state.bundledOnly}
setBundledOnly={(bundledOnly) => {
this.setState({bundledOnly})}}
{..._omit(this.props, ['loadingChallenge', 'clearAllFilters'])} />)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,18 +269,6 @@ export default function WithFilteredClusteredTasks(WrappedComponent,
this.state.includeLocked)

this.setState({filteredTasks})

// If task selection is active, prune any selections that no longer pass filters
this.props.pruneSelectedTasks && this.props.pruneSelectedTasks(task =>
!this.taskPassesFilters(
task,
this.state.includeStatuses,
this.state.includeReviewStatuses,
this.state.includeMetaReviewStatuses,
this.state.includePriorities,
this.state.includeLocked
)
)
}

// This will check for saved filters if the 'useSavedFilters' prop is true and a valid user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@ export default function WithSelectedClusteredTasks(WrappedComponent) {
* Toggle selection of the given task on or off
*/
toggleTaskSelection = task => {
const taskId = task.id ?? task.taskId

// If allSelected is false, then we work off the selectedTasks map;
// otherwise we work off the deselectedTasks map
if (!this.state.allSelected) {
const selected = new Map(this.state.selectedTasks)
selected.has(task.id) ? selected.delete(task.id) : selected.set(task.id, task)
selected.has(taskId) ? selected.delete(taskId) : selected.set(taskId, task)
this.setState({selectedTasks: selected})
}
else {
const deselected = new Map(this.state.deselectedTasks)
deselected.has(task.id) ? deselected.delete(task.id) : deselected.set(task.id, task)
deselected.has(taskId) ? deselected.delete(taskId) : deselected.set(taskId, task)
this.setState({deselectedTasks: deselected})
}
}
Expand Down
Loading

0 comments on commit c149d16

Please sign in to comment.