Skip to content

Commit ef1288f

Browse files
committed
Mark image/table tools active; improve skip error
Update rich text editor to treat image and table tools as active (add mappings and tests). Make useTaskEditorSubmission pass a skip-specific fallback message and allow custom fallback messages from resolveTaskSubmitErrorMessage; add unit test for skip failure. Also include minor formatting/whitespace cleanups across components, pages, services, and utils.
1 parent 10007cb commit ef1288f

14 files changed

Lines changed: 111 additions & 48 deletions

File tree

components/project-wizard/RichTextEditor.vue

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,23 +57,25 @@ const TOOL_DEFINITIONS: Array<{ icon: string; id: RichTextToolId; label: string
5757
{ id: 'numbered-list', icon: 'format_list_numbered', label: 'Numbered list' },
5858
{ id: 'image', icon: 'image', label: 'Image' },
5959
{ id: 'table', icon: 'table_rows', label: 'Table' },
60-
{ id: 'quote', icon: 'format_quote', label: 'Quote' },
60+
{ id: 'quote', icon: 'format_quote', label: 'Quote' }
6161
];
6262
const ACTIVE_TOOL_NAMES: Partial<Record<RichTextToolId, string>> = {
6363
'bold': 'bold',
6464
'italic': 'italic',
6565
'link': 'link',
6666
'bullet-list': 'bulletList',
6767
'numbered-list': 'orderedList',
68-
'quote': 'blockquote',
68+
'image': 'image',
69+
'table': 'table',
70+
'quote': 'blockquote'
6971
};
7072
const activeToolIds = ref<Set<RichTextToolId>>(new Set());
7173
const lastEditorModelValue = ref(model.value);
7274
const tools = computed(() =>
7375
TOOL_DEFINITIONS.map(tool => ({
7476
...tool,
75-
active: activeToolIds.value.has(tool.id),
76-
})),
77+
active: activeToolIds.value.has(tool.id)
78+
}))
7779
);
7880
7981
const editor = useEditor({
@@ -84,21 +86,21 @@ const editor = useEditor({
8486
link: {
8587
openOnClick: false,
8688
autolink: true,
87-
defaultProtocol: 'https',
88-
},
89+
defaultProtocol: 'https'
90+
}
8991
}),
9092
Image,
9193
Table.configure({
92-
resizable: false,
94+
resizable: false
9395
}),
9496
TableRow,
9597
TableHeader,
96-
TableCell,
98+
TableCell
9799
],
98100
editorProps: {
99101
attributes: {
100-
class: 'project-wizard-rich-text-editor-surface project-wizard-rich-text-content',
101-
},
102+
class: 'project-wizard-rich-text-editor-surface project-wizard-rich-text-content'
103+
}
102104
},
103105
onUpdate({ editor: currentEditor }) {
104106
const nextValue = currentEditor.isEmpty ? '' : currentEditor.getHTML();
@@ -110,7 +112,7 @@ const editor = useEditor({
110112
},
111113
onTransaction({ editor: currentEditor }) {
112114
updateActiveTools(currentEditor);
113-
},
115+
}
114116
});
115117
116118
watch(
@@ -133,7 +135,7 @@ watch(
133135
134136
currentEditor.commands.setContent(nextValue, { emitUpdate: false });
135137
lastEditorModelValue.value = value;
136-
},
138+
}
137139
);
138140
139141
function updateActiveTools(currentEditor: Editor) {
@@ -143,7 +145,7 @@ function updateActiveTools(currentEditor: Editor) {
143145
const activeToolName = ACTIVE_TOOL_NAMES[id];
144146
return activeToolName ? currentEditor.isActive(activeToolName) : false;
145147
})
146-
.map(({ id }) => id),
148+
.map(({ id }) => id)
147149
);
148150
}
149151

components/project-wizard/steps/AreaOfInterestStep.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ const emit = defineEmits<{
203203
const fileInputRef = useTemplateRef<HTMLInputElement>('fileInputRef');
204204
const isDraggingFile = ref(false);
205205
const formattedArea = computed(() =>
206-
formatArea(props.areaSquareKilometers, props.areaDisplayUnit),
206+
formatArea(props.areaSquareKilometers, props.areaDisplayUnit)
207207
);
208208
209209
watch(

components/project-wizard/steps/ReviewStep.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ const props = defineProps<Props>();
108108
const displayValidators = computed(() =>
109109
props.summary.selectedValidators.map(validator => ({
110110
...validator,
111-
roleLabel: formatRole(validator.role),
112-
})),
111+
roleLabel: formatRole(validator.role)
112+
}))
113113
);
114114
115115
function formatRole(role: WorkspaceRole): string {

components/project-wizard/steps/SettingsStep.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ const hourOptions = Array.from({ length: 24 }, (_, index) => {
123123
124124
return {
125125
label: String(value).padStart(2, '0'),
126-
value,
126+
value
127127
};
128128
});
129129
const instructionsModel = computed({
130130
get: () => props.instructions,
131-
set: value => emit('update:instructions', value),
131+
set: value => emit('update:instructions', value)
132132
});
133133
134134
function onLockTimeoutChange(event: Event) {

components/workspace-project-details/TaskSetupPanel.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,16 @@ const { areaUnit, selectAreaUnit } = useAreaDisplayUnit();
245245
246246
/** Formatted strings for the min/max labels and current value display. */
247247
const formattedMinimumTaskArea = computed(() =>
248-
formatArea(props.minimumTaskAreaSquareKilometers, areaUnit.value),
248+
formatArea(props.minimumTaskAreaSquareKilometers, areaUnit.value)
249249
);
250250
const formattedMaximumTaskArea = computed(() =>
251-
formatArea(props.maximumTaskAreaSquareKilometers, areaUnit.value),
251+
formatArea(props.maximumTaskAreaSquareKilometers, areaUnit.value)
252252
);
253253
const formattedTaskArea = computed(() =>
254-
formatArea(props.taskAreaSquareKilometers, areaUnit.value),
254+
formatArea(props.taskAreaSquareKilometers, areaUnit.value)
255255
);
256256
const taskGenerationActionLabel = computed(() =>
257-
props.generatedSummary ? 'Generate Again' : 'Generate Tasks',
257+
props.generatedSummary ? 'Generate Again' : 'Generate Tasks'
258258
);
259259
260260
/**

components/workspace-project-details/TasksTab.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ const statusOptions: SelectOption[] = [
236236
{ label: 'Ready for mapping', value: 'ready_for_mapping' },
237237
{ label: 'Ready for validation', value: 'ready_for_validation' },
238238
{ label: 'More mapping required', value: 'needs_more_mapping' },
239-
{ label: 'Completed', value: 'completed' },
239+
{ label: 'Completed', value: 'completed' }
240240
];
241241
242242
const sortOptions: SelectOption[] = [

composables/useTaskEditorSubmission.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ export function useTaskEditorSubmission(options: UseTaskEditorSubmissionOptions)
184184
await options.onFinished(true);
185185
}
186186
catch (error) {
187-
submitErrorMessage.value = await resolveTaskSubmitErrorMessage(error);
187+
submitErrorMessage.value = await resolveTaskSubmitErrorMessage(
188+
error,
189+
'Task could not be skipped. Please try again.'
190+
);
188191
}
189192
finally {
190193
activeTaskAction.value = null;
@@ -203,6 +206,9 @@ export function useTaskEditorSubmission(options: UseTaskEditorSubmissionOptions)
203206
};
204207
}
205208

206-
async function resolveTaskSubmitErrorMessage(error: unknown): Promise<string> {
207-
return await resolveHttpErrorMessage(error, 'Task submission failed.');
209+
async function resolveTaskSubmitErrorMessage(
210+
error: unknown,
211+
fallbackMessage = 'Task submission failed.'
212+
): Promise<string> {
213+
return await resolveHttpErrorMessage(error, fallbackMessage);
208214
}

pages/workspace/[id]/projects/[projectId]/edit.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -535,11 +535,11 @@ const BASE_SECTIONS: ProjectEditSection[] = [
535535
const hourOptions = Array.from({ length: 24 }, (_, index) => index + 1);
536536
const workspace = await workspacesClient.getWorkspace(workspaceId);
537537
const myTdeiRoles = await tdeiUserClient.getMyRolesForProjectGroupById(
538-
workspace.tdeiProjectGroupId,
539-
).catch(() => []);
538+
workspace.tdeiProjectGroupId
539+
);
540540
const { canEditProjectMetadata } = useWorkspaceProjectPermissions(
541541
() => workspace.role,
542-
myTdeiRoles,
542+
myTdeiRoles
543543
);
544544
545545
if (!canEditProjectMetadata.value) {
@@ -564,8 +564,8 @@ await rolePromise;
564564
565565
const sections = computed(() =>
566566
BASE_SECTIONS.filter(section =>
567-
section.id !== 'team' || canManageContributors.value,
568-
),
567+
section.id !== 'team' || canManageContributors.value
568+
)
569569
);
570570
571571
const initialCustomImageryJson = formatCustomImagery(project.value.customImagery);

pages/workspace/[id]/projects/create.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,14 @@ const workspace = await workspacesClient.getWorkspace(workspaceId).catch((error)
221221
});
222222
223223
const myTdeiRoles = await tdeiUserClient.getMyRolesForProjectGroupById(
224-
workspace.tdeiProjectGroupId,
224+
workspace.tdeiProjectGroupId
225225
).catch((error) => {
226226
throw createError({ statusCode: 500, statusMessage: 'Failed to load TDEI project group roles.', data: error });
227227
});
228228
229229
const { canCreateProject } = useWorkspaceProjectPermissions(
230230
() => workspace.role,
231-
myTdeiRoles,
231+
myTdeiRoles
232232
);
233233
234234
if (!canCreateProject.value) {
@@ -310,7 +310,7 @@ const hasAreaOfInterest = computed(() => draft.area.aoi !== null);
310310
const aoiAreaSquareKilometers = computed(() =>
311311
draft.area.aoi
312312
? calculateProjectWizardAoiAreaSquareKilometers(draft.area.aoi)
313-
: 0,
313+
: 0
314314
);
315315
const {
316316
addValidator,
@@ -334,8 +334,8 @@ const reviewSummary = computed(() =>
334334
buildProjectWizardReviewSummary(
335335
draft,
336336
selectedValidators.value,
337-
areaUnit.value,
338-
),
337+
areaUnit.value
338+
)
339339
);
340340
341341
const detailsStepComplete = computed(() =>

services/project-wizard-review.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { sanitizeRichTextHtml } from '~/util/rich-text';
44

55
import type {
66
ProjectWizardDraft,
7-
ProjectWizardWorkspaceUser,
7+
ProjectWizardWorkspaceUser
88
} from '~/types/project-wizard';
99

1010
export interface ProjectWizardReviewSummary {
@@ -24,7 +24,7 @@ export interface ProjectWizardReviewSummary {
2424
export function buildProjectWizardReviewSummary(
2525
draft: ProjectWizardDraft,
2626
selectedValidators: ProjectWizardWorkspaceUser[],
27-
areaDisplayUnit: AreaDisplayUnit = 'square_kilometers',
27+
areaDisplayUnit: AreaDisplayUnit = 'square_kilometers'
2828
): ProjectWizardReviewSummary {
2929
const hasImageryUrl = draft.details.imageryUrl.trim().length > 0;
3030
const instructionsHtml = sanitizeRichTextHtml(draft.settings.instructions);
@@ -43,8 +43,8 @@ export function buildProjectWizardReviewSummary(
4343
aoiAreaLabel: draft.area.aoi
4444
? formatArea(
4545
calculateProjectWizardAoiAreaSquareKilometers(draft.area.aoi),
46-
areaDisplayUnit,
46+
areaDisplayUnit
4747
)
48-
: formatArea(0, areaDisplayUnit),
48+
: formatArea(0, areaDisplayUnit)
4949
};
5050
}

0 commit comments

Comments
 (0)