Skip to content

Commit 68401b1

Browse files
committed
feat: show project type on project cards
- add project type tag to cards in ProjectsView - make project card images cover their container - rename "LocateFeatures" project type to "Locate Objects" - sort answer options inside LocateFeaturesProject instead of ProjectView
1 parent 473b7ef commit 68401b1

4 files changed

Lines changed: 35 additions & 14 deletions

File tree

src/components/LocateFeaturesProject.vue

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import type {
1111
TileTask,
1212
} from '@/utils/types'
1313
import { computed, inject, onMounted, ref, shallowRef, useTemplateRef, watchEffect } from 'vue'
14-
import { isDefined, isNotDefined, listToMap } from '@togglecorp/fujs'
14+
import { compareNumber, isDefined, isNotDefined, listToMap } from '@togglecorp/fujs'
1515
1616
import createInformationPages from '@/utils/createInformationPages'
1717
import { createFallbackInformationPages } from '@/utils/domain'
@@ -42,6 +42,8 @@ const projectInfoRef = useTemplateRef('projectInfo')
4242
const props = defineProps<Props>()
4343
const taskContainer = shallowRef<VContainer | null>(null)
4444
45+
const options = computed(() => [...props.options ?? []].sort((a, b) => compareNumber(a.value, b.value)))
46+
4547
const logMappingStarted = inject<(projectType: string) => void>('logMappingStarted')
4648
const saveResults =
4749
inject<(results: Record<string, number[]>, startTime: string) => void>('saveResults')
@@ -92,7 +94,7 @@ watchEffect(() => {
9294
processedTasks.value,
9395
({ taskId }) => taskId,
9496
() => Array.from(new Array(numSubGridElements.value).keys()).map(
95-
() => props.options[0].value,
97+
() => options.value[0].value,
9698
),
9799
)
98100
@@ -107,20 +109,20 @@ watchEffect(() => {
107109
108110
const optionMapping = computed(() =>
109111
listToMap(
110-
props.options,
112+
options.value,
111113
({ value }) => value,
112114
)
113115
)
114116
const nextOptionMapping = computed(() =>
115117
listToMap(
116-
props.options,
118+
options.value,
117119
({ value }) => value,
118120
(_, __, index) => {
119-
if (index === props.options.length - 1) {
120-
return props.options[0].value
121+
if (index === options.value.length - 1) {
122+
return options.value[0].value
121123
}
122124
123-
return props.options[index + 1].value
125+
return options.value[index + 1].value
124126
},
125127
),
126128
)
@@ -223,7 +225,7 @@ function handleSelectAll() {
223225
<template #instructions>
224226
<LocateFeaturesProjectInstructions
225227
:instruction="instruction"
226-
:options="props.options"
228+
:options="options"
227229
:exampleTileUrl="processedTasks[0].url"
228230
/>
229231
</template>

src/config/projectTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const projectTypes = {
2828
component: 'streetProject',
2929
},
3030
'9': {
31-
name: 'LocateFeatures',
31+
name: 'Locate Objects',
3232
component: 'locateFeaturesProject',
3333
},
3434
'10': {

src/views/ProjectView.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import ValidateImageProject from '@/components/ValidateImageProject.vue'
2727
import LocateFeaturesProject from '@/components/LocateFeaturesProject.vue'
2828
import projectTypes from '@/config/projectTypes'
2929
import { decompressTasks } from '@/utils/tasks'
30-
import { compareNumber } from '@togglecorp/fujs'
3130
3231
export default defineComponent({
3332
components: {
@@ -118,10 +117,7 @@ export default defineComponent({
118117
computed: {
119118
...mapStores(useCurrentUserStore),
120119
options() {
121-
const optionsTemp = this.project?.customOptions ?? this.project?.answerLabels;
122-
const options = optionsTemp
123-
? [...optionsTemp].sort((a, b) => compareNumber(a.value, b.value))
124-
: undefined;
120+
const options = this.project?.customOptions ?? this.project?.answerLabels;
125121
const completedOptions = options?.map(this.completeOptions)
126122
return completedOptions
127123
},

src/views/ProjectsView.vue

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default defineComponent({
2121
currentProject: null,
2222
selectedItems: projectFilters.map((f) => f.defaultItems),
2323
showFilterCard: false,
24+
projectTypes: projectTypes,
2425
}),
2526
computed: {
2627
...mapStores(useCurrentUserStore),
@@ -210,10 +211,15 @@ export default defineComponent({
210211
width="350"
211212
tile
212213
>
214+
<div class="project-type-tag">
215+
{{ projectTypes[project.projectType].name }}
216+
</div>
213217
<v-img
218+
class="cover-image"
214219
height="250"
215220
:src="project.image"
216221
@error="() => (project.image = fallbackImage)"
222+
cover
217223
/>
218224
<v-card-title class="text-wrap">{{ project.projectTopic }}</v-card-title>
219225
<v-card-text>
@@ -257,3 +263,20 @@ export default defineComponent({
257263
</v-row>
258264
</basic-page>
259265
</template>
266+
<style scoped>
267+
.project-type-tag {
268+
position: absolute;
269+
left: 0.5rem;
270+
top: 0.5rem;
271+
background-color: white;
272+
z-index: 1;
273+
font-size: 0.75rem;
274+
padding: 0.125rem 0.75rem;
275+
border-radius: 0.75rem;
276+
border: 1px solid rgba(0, 0, 0, .1);
277+
}
278+
279+
.cover-image {
280+
background-color: #999;
281+
}
282+
</style>

0 commit comments

Comments
 (0)