diff --git a/src/mapper/src/lib/components/dialog-task-actions.svelte b/src/mapper/src/lib/components/dialog-task-actions.svelte index 1b4c2c5072..dceaf3720e 100644 --- a/src/mapper/src/lib/components/dialog-task-actions.svelte +++ b/src/mapper/src/lib/components/dialog-task-actions.svelte @@ -35,7 +35,7 @@ >
-

Task #{taskStore.selectedTaskId}

+

Task #{taskStore.selectedTaskIndex}

{ clickMapNewFeature(); @@ -58,7 +58,7 @@
{#if taskStore.selectedTaskState === 'UNLOCKED_TO_MAP'} -

Do you want to start mapping task #{taskStore.selectedTaskId}?

+

Do you want to start mapping task #{taskStore.selectedTaskIndex}?

{:else if taskStore.selectedTaskState === 'LOCKED_FOR_MAPPING'} -

Task #{taskStore.selectedTaskId} has been locked. Is the task completely mapped?

+

Task #{taskStore.selectedTaskIndex} has been locked. Is the task completely mapped?

resetTask(projectData?.id, taskStore.selectedTaskId)} diff --git a/src/mapper/src/lib/components/map/main.svelte b/src/mapper/src/lib/components/map/main.svelte index 2c069f9809..ce75c68af5 100644 --- a/src/mapper/src/lib/components/map/main.svelte +++ b/src/mapper/src/lib/components/map/main.svelte @@ -164,7 +164,7 @@ if (clickedTaskFeature && clickedTaskFeature?.length > 0) { taskAreaClicked = true; const clickedTaskId = clickedTaskFeature[0]?.properties?.fid; - taskStore.setSelectedTaskId(clickedTaskId); + taskStore.setSelectedTaskId(clickedTaskId, clickedTaskFeature[0]?.properties?.task_index); if (+projectSetupStepStore.projectSetupStep === projectSetupStepEnum['task_selection']) { localStorage.setItem(`project-${projectId}-setup`, projectSetupStepEnum['complete_setup']); projectSetupStepStore.setProjectSetupStep(projectSetupStepEnum['complete_setup']); @@ -322,7 +322,7 @@ on:click={(_e) => { // deselect everything on click, to allow for re-selection // if the user clicks on a feature layer directly (on:click) - taskStore.setSelectedTaskId(null); + taskStore.setSelectedTaskId(null, null); taskAreaClicked = false; toggleActionModal(null); entitiesStore.setSelectedEntity(null); diff --git a/src/mapper/src/lib/components/more/activities.svelte b/src/mapper/src/lib/components/more/activities.svelte index b70409d052..de338f1c1b 100644 --- a/src/mapper/src/lib/components/more/activities.svelte +++ b/src/mapper/src/lib/components/more/activities.svelte @@ -21,7 +21,9 @@ {:else if taskEvents?.length === 0}

- {taskStore?.selectedTaskId ? `No activities yet on task ${taskStore?.selectedTaskId}` : 'No activities yet'} + {taskStore?.selectedTaskIndex + ? `No activities yet on task ${taskStore?.selectedTaskIndex}` + : 'No activities yet'}

{:else} diff --git a/src/mapper/src/lib/components/more/comment.svelte b/src/mapper/src/lib/components/more/comment.svelte index b377a22afc..6b8f502cf1 100644 --- a/src/mapper/src/lib/components/more/comment.svelte +++ b/src/mapper/src/lib/components/more/comment.svelte @@ -20,7 +20,7 @@
{#if false} {#each Array.from({ length: 5 }) as _, index} @@ -29,7 +29,7 @@ {:else if comments?.length === 0}

- {taskStore?.selectedTaskId ? `No comments yet on task ${taskStore?.selectedTaskId}` : 'No comments yet'} + {taskStore?.selectedTaskIndex ? `No comments yet on task ${taskStore?.selectedTaskIndex}` : 'No comments yet'}

{:else} diff --git a/src/mapper/src/routes/[projectId]/+page.svelte b/src/mapper/src/routes/[projectId]/+page.svelte index bfc4eb0177..43720e2694 100644 --- a/src/mapper/src/routes/[projectId]/+page.svelte +++ b/src/mapper/src/routes/[projectId]/+page.svelte @@ -59,7 +59,7 @@ if (!taskObj) return; // Set as selected task for buttons - taskStore.setSelectedTaskId(taskObj.id); + taskStore.setSelectedTaskId(taskObj.id, taskObj?.task_index); const taskPolygon = polygon(taskObj.outline.coordinates); const taskBuffer = buffer(taskPolygon, 5, { units: 'meters' }); diff --git a/src/mapper/src/store/tasks.svelte.ts b/src/mapper/src/store/tasks.svelte.ts index d918f56824..704f1d8230 100644 --- a/src/mapper/src/store/tasks.svelte.ts +++ b/src/mapper/src/store/tasks.svelte.ts @@ -8,7 +8,11 @@ let taskEventShape: Shape; let featcol = $state({ type: 'FeatureCollection', features: [] }); let latestEvent = $state(null); let events: TaskEventType[] = $state([]); + +// for UI show task index for simplicity & for api's use task id let selectedTaskId: number | null = $state(null); +let selectedTaskIndex: number | null = $state(null); + let selectedTask: any = $state(null); let selectedTaskState: string = $state(''); let selectedTaskGeom: GeoJSON | null = $state(null); @@ -45,7 +49,6 @@ function getTaskStore() { async function appendTaskStatesToFeatcol(projectTasks: ProjectTask[]) { const latestTaskStates = await getLatestStatePerTask(); - const features = projectTasks.map((task) => ({ type: 'Feature', geometry: task.outline, @@ -53,6 +56,7 @@ function getTaskStore() { fid: task.id, state: latestTaskStates.get(task.id)?.state || 'UNLOCKED_TO_MAP', actioned_by_uid: latestTaskStates.get(task.id)?.actioned_by_uid, + task_index: task?.project_task_index, }, })); @@ -78,12 +82,13 @@ function getTaskStore() { return currentTaskStates; } - async function setSelectedTaskId(newId: number) { - selectedTaskId = newId; + async function setSelectedTaskId(taskId: number | null, taskIndex: number | null) { + selectedTaskId = taskId; + selectedTaskIndex = taskIndex; const allTasksCurrentStates = await getLatestStatePerTask(); - selectedTask = allTasksCurrentStates.get(newId); + selectedTask = allTasksCurrentStates.get(taskId); selectedTaskState = selectedTask?.state || 'UNLOCKED_TO_MAP'; - selectedTaskGeom = featcol.features.find((x) => x.properties.fid === newId)?.geometry || null; + selectedTaskGeom = featcol.features.find((x) => x.properties.fid === taskId)?.geometry || null; } return { @@ -107,6 +112,9 @@ function getTaskStore() { get selectedTaskId() { return selectedTaskId; }, + get selectedTaskIndex() { + return selectedTaskIndex; + }, get selectedTask() { return selectedTask; },