Skip to content

Commit

Permalink
fix: task status var type, openlayers styling (#1026)
Browse files Browse the repository at this point in the history
* fix (taskPriorityStr): task_priority_str enums added

* fix (projectDetails): task_priority_str added to statuses
  • Loading branch information
NSUWAL123 authored Dec 5, 2023
1 parent acf9995 commit bbe5f5d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/frontend/src/components/DialogTaskActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import ProjectTaskStatus from '../api/ProjectTaskStatus';
import MapStyles from '../hooks/MapStyles';
import CoreModules from '../shared/CoreModules';
import { CommonActions } from '../store/slices/CommonSlice';
import { task_priority_str } from '../types/enums';

export default function Dialog({ taskId, feature, map, view }) {
// const featureStatus = feature.id_ != undefined ? feature.id_.replace("_", ",").split(',')[1] : null;
const projectData = CoreModules.useAppSelector((state) => state.project.projectTaskBoundries);
const token = CoreModules.useAppSelector((state) => state.login.loginToken);
const loading = CoreModules.useAppSelector((state) => state.common.loading);
const [list_of_task_status, set_list_of_task_status] = useState([]);
const [task_status, set_task_status] = useState('READY');
const [task_status, set_task_status] = useState(task_priority_str['READY']);

const geojsonStyles = MapStyles();
const dispatch = CoreModules.useAppDispatch();
Expand All @@ -32,11 +34,11 @@ export default function Dialog({ taskId, feature, map, view }) {
})[0],
};
const findCorrectTaskStatusIndex = environment.tasksStatus.findIndex(
(data) => data.label == currentStatus.task_status,
(data) => data.label == task_priority_str[currentStatus.task_status],
);
const tasksStatus =
feature.id_ != undefined ? environment.tasksStatus[findCorrectTaskStatusIndex]?.['label'] : '';
set_task_status(tasksStatus);
set_task_status(task_priority_str[tasksStatus]);
const tasksStatusList =
feature.id_ != undefined ? environment.tasksStatus[findCorrectTaskStatusIndex]?.['action'] : [];

Expand All @@ -49,7 +51,7 @@ export default function Dialog({ taskId, feature, map, view }) {
// });

const handleOnClick = (event) => {
const status = event.target.id;
const status = task_priority_str[event.target.id];
const body = token != null ? { ...token } : {};
const geoStyle = geojsonStyles[status];
if (event.target.id != undefined) {
Expand Down Expand Up @@ -100,7 +102,8 @@ export default function Dialog({ taskId, feature, map, view }) {
</CoreModules.Stack>
<CoreModules.Stack direction={'row'} pl={1}>
<CoreModules.Typography variant="h3">
{`STATUS : ${task_status?.toString()?.replaceAll('_', ' ')}`}
{/* {`STATUS : ${task_status?.toString()?.replaceAll('_', ' ')}`} */}
{`STATUS : ${task_priority_str[task_status]}`}
</CoreModules.Typography>
</CoreModules.Stack>
<CoreModules.Link
Expand Down
12 changes: 12 additions & 0 deletions src/frontend/src/types/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@ export enum task_split_type {
choose_area_as_task = 1,
task_splitting_algorithm = 2,
}

export enum task_priority_str {
READY = 0,
LOCKED_FOR_MAPPING = 1,
MAPPED = 2,
LOCKED_FOR_VALIDATION = 3,
VALIDATED = 4,
INVALIDATED = 5,
BAD = 6,
SPLIT = 7,
ARCHIVED = 8,
}
3 changes: 2 additions & 1 deletion src/frontend/src/utilfunctions/getTaskStatusStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Fill, Icon, Stroke, Style } from 'ol/style';
import { transform } from 'ol/proj';
import { Point } from 'ol/geom';
import AssetModules from '../shared/AssetModules';
import { task_priority_str } from '../types/enums';

function createPolygonStyle(fillColor, strokeColor) {
return new Style({
Expand Down Expand Up @@ -34,7 +35,7 @@ const strokeColor = 'rgb(0,0,0,0.5)';

const getTaskStatusStyle = (feature, mapTheme) => {
let id = feature.getId().toString().replace('_', ',');
const status = id.split(',')[1];
const status = task_priority_str[id.split(',')[1]];
const lockedPolygonStyle = createPolygonStyle(mapTheme.palette.mapFeatureColors.locked_for_mapping_rgb, strokeColor);
const lockedValidationStyle = createPolygonStyle(
mapTheme.palette.mapFeatureColors.locked_for_validation_rgb,
Expand Down

0 comments on commit bbe5f5d

Please sign in to comment.