Skip to content

Commit

Permalink
Merge pull request #3560 from LiteFarmOrg/LF-4554-adjust-frontend-tas…
Browse files Browse the repository at this point in the history
…k-view-to-handle-tasks-with-no-locations

LF-4554 Adjust frontend task view to handle tasks with no locations
  • Loading branch information
antsgar authored Dec 3, 2024
2 parents ab76472 + 36ab30c commit 4ccd6ba
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
3 changes: 2 additions & 1 deletion packages/webapp/public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,8 @@
"ANIMAL_MOVEMENT_EXPANDING_SUMMARY_TITLE": "See detail list of animals to move",
"CARD": {
"MULTIPLE_CROPS": "Multiple crops",
"MULTIPLE_LOCATIONS": "Multiple locations"
"MULTIPLE_LOCATIONS": "Multiple locations",
"NO_LOCATION": "No location"
},
"COMPLETE": {
"DATE": "Completion date",
Expand Down
44 changes: 24 additions & 20 deletions packages/webapp/src/components/Task/TaskReadOnly/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,26 +233,30 @@ export default function PureTaskReadOnly({
</div>
)}

<Semibold style={{ marginBottom: '12px' }}>{t('TASK.LOCATIONS')}</Semibold>
{isTaskType(taskType, 'TRANSPLANT_TASK') && (
<TransplantLocationLabel
locations={task.locations}
selectedLocationId={task.selectedLocationIds[0]}
pinCoordinate={task.pinCoordinates[0]}
/>
)}
<LocationPicker
onSelectLocation={() => {
// TODO: fix onSelectLocationRef in LocationPicker
}}
readOnlyPinCoordinates={task.pinCoordinates}
style={{ minHeight: '160px', marginBottom: '40px' }}
locations={task.locations}
selectedLocationIds={task.selectedLocationIds || []}
farmCenterCoordinate={user.grid_points}
maxZoomRef={maxZoomRef}
getMaxZoom={getMaxZoom}
/>
{task.locations?.length || task.pinCoordinates?.length ? (
<>
<Semibold style={{ marginBottom: '12px' }}>{t('TASK.LOCATIONS')}</Semibold>
{isTaskType(taskType, 'TRANSPLANT_TASK') && (
<TransplantLocationLabel
locations={task.locations}
selectedLocationId={task.selectedLocationIds[0]}
pinCoordinate={task.pinCoordinates[0]}
/>
)}
<LocationPicker
onSelectLocation={() => {
// TODO: fix onSelectLocationRef in LocationPicker
}}
readOnlyPinCoordinates={task.pinCoordinates}
style={{ minHeight: '160px', marginBottom: '40px' }}
locations={task.locations}
selectedLocationIds={task.selectedLocationIds || []}
farmCenterCoordinate={user.grid_points}
maxZoomRef={maxZoomRef}
getMaxZoom={getMaxZoom}
/>
</>
) : null}

{Object.keys(task.managementPlansByLocation).map((location_id) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ const getLocationNameOfTask = (managementPlans, locations, taskType) => {
if (locationNameSet.size > 1) return i18n.t('TASK.CARD.MULTIPLE_LOCATIONS');
}

if (locationNameSet.size == 0) return i18n.t('TASK.CARD.NO_LOCATION');

return locationNameSet.values()?.next()?.value;
};

Expand Down

0 comments on commit 4ccd6ba

Please sign in to comment.