Skip to content

Commit 48934ba

Browse files
committed
🎨 Add prefix to task name in table cells (#1956)
1 parent 2947c61 commit 48934ba

File tree

5 files changed

+19
-5
lines changed

5 files changed

+19
-5
lines changed

src/lib/components/TaskTables/TaskTable.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
108108
function getBodyCellClasses(taskResult: TaskResult, totalColumns: number): string {
109109
const baseClasses = 'w-1/2 xs:w-1/3 sm:w-1/4 md:w-1/5 lg:w-1/6 px-1 py-1';
110-
const additionalClasses = totalColumns > 8 ? 'lg:w-1/7 2xl:w-1/8 py-2' : '';
110+
const additionalClasses = totalColumns > 8 ? '2xl:w-1/7 py-2' : '';
111111
const backgroundColor = getBackgroundColor(taskResult);
112112
113113
return `${baseClasses} ${additionalClasses} ${backgroundColor}`;
@@ -241,6 +241,7 @@
241241
<TaskTableBodyCell
242242
{taskResult}
243243
{isLoggedIn}
244+
isShownTaskIndex={contestTable.displayConfig.isShownTaskIndex}
244245
onupdate={(updatedTask: TaskResult) => handleUpdateTaskResult(updatedTask)}
245246
/>
246247
{/if}

src/lib/components/TaskTables/TaskTableBodyCell.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
interface Props {
1313
taskResult: TaskResult;
1414
isLoggedIn: boolean;
15+
isShownTaskIndex: boolean;
1516
onupdate?: (updatedTask: TaskResult) => void; // Ensure to update task result in parent component.
1617
}
1718
18-
let { taskResult, isLoggedIn, onupdate = () => {} }: Props = $props();
19+
let { taskResult, isLoggedIn, isShownTaskIndex, onupdate = () => {} }: Props = $props();
1920
2021
let updatingDropdown: UpdatingDropdown;
2122
</script>
@@ -26,7 +27,7 @@
2627
{@render taskGradeLabel(taskResult)}
2728

2829
<div class="flex items-center justify-between w-full min-w-0">
29-
{@render taskTitleAndExternalLink(taskResult)}
30+
{@render taskTitleAndExternalLink(taskResult, isShownTaskIndex)}
3031
{@render submissionUpdaterAndLinksOfTaskDetailPage(taskResult)}
3132
</div>
3233
</div>
@@ -42,11 +43,13 @@
4243
</div>
4344
{/snippet}
4445

45-
{#snippet taskTitleAndExternalLink(taskResult: TaskResult)}
46+
{#snippet taskTitleAndExternalLink(taskResult: TaskResult, isShownTaskIndex: boolean)}
4647
<div class="max-w-[calc(100%-1rem)] truncate">
4748
<ExternalLinkWrapper
4849
url={getTaskUrl(taskResult.contest_id, taskResult.task_id)}
49-
description={removeTaskIndexFromTitle(taskResult.title, taskResult.task_table_index)}
50+
description={isShownTaskIndex
51+
? taskResult.title
52+
: removeTaskIndexFromTitle(taskResult.title, taskResult.task_table_index)}
5053
textSize="xs:text-md"
5154
textColorInDarkMode="dark:text-gray-300"
5255
iconSize={0}

src/lib/types/contest_table_provider.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,10 @@ export type ContestTablesMetaData = {
125125
* @interface ContestTableDisplayConfig
126126
* @property {boolean} isShownHeader - Whether to display the table header
127127
* @property {boolean} isShownRoundLabel - Whether to display round labels in the contest table
128+
* @property {boolean} isShownTaskIndex - Whether to display task index in the contest table cells
128129
*/
129130
export interface ContestTableDisplayConfig {
130131
isShownHeader: boolean;
131132
isShownRoundLabel: boolean;
133+
isShownTaskIndex: boolean;
132134
}

src/lib/utils/contest_table_provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export abstract class ContestTableProviderBase implements ContestTableProvider {
9898
return {
9999
isShownHeader: true,
100100
isShownRoundLabel: true,
101+
isShownTaskIndex: false,
101102
};
102103
}
103104

@@ -229,6 +230,7 @@ export class EDPCProvider extends ContestTableProviderBase {
229230
return {
230231
isShownHeader: false,
231232
isShownRoundLabel: false,
233+
isShownTaskIndex: true,
232234
};
233235
}
234236

@@ -259,6 +261,7 @@ export class TDPCProvider extends ContestTableProviderBase {
259261
return {
260262
isShownHeader: false,
261263
isShownRoundLabel: false,
264+
isShownTaskIndex: true,
262265
};
263266
}
264267

src/test/lib/utils/contest_table_provider.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ describe('ContestTableProviderBase and implementations', () => {
126126

127127
expect(displayConfig.isShownHeader).toBe(true);
128128
expect(displayConfig.isShownRoundLabel).toBe(true);
129+
expect(displayConfig.isShownTaskIndex).toBe(false);
129130
});
130131
});
131132

@@ -164,6 +165,7 @@ describe('ContestTableProviderBase and implementations', () => {
164165

165166
expect(displayConfig.isShownHeader).toBe(true);
166167
expect(displayConfig.isShownRoundLabel).toBe(true);
168+
expect(displayConfig.isShownTaskIndex).toBe(false);
167169
});
168170
});
169171

@@ -202,6 +204,7 @@ describe('ContestTableProviderBase and implementations', () => {
202204

203205
expect(displayConfig.isShownHeader).toBe(true);
204206
expect(displayConfig.isShownRoundLabel).toBe(true);
207+
expect(displayConfig.isShownTaskIndex).toBe(false);
205208
});
206209
});
207210

@@ -220,6 +223,7 @@ describe('ContestTableProviderBase and implementations', () => {
220223

221224
expect(displayConfig.isShownHeader).toBe(false);
222225
expect(displayConfig.isShownRoundLabel).toBe(false);
226+
expect(displayConfig.isShownTaskIndex).toBe(true);
223227
});
224228

225229
test('expects to format contest round label correctly', () => {
@@ -245,6 +249,7 @@ describe('ContestTableProviderBase and implementations', () => {
245249

246250
expect(displayConfig.isShownHeader).toBe(false);
247251
expect(displayConfig.isShownRoundLabel).toBe(false);
252+
expect(displayConfig.isShownTaskIndex).toBe(true);
248253
});
249254

250255
test('expects to format contest round label correctly', () => {

0 commit comments

Comments
 (0)