-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rough out scheme list #122
Changes from all commits
4d369be
6fbd28c
383174c
0db42eb
3f770f2
e8f41be
9e71d84
f04058e
4b042a5
5a16a36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<script setup lang="ts"> | ||
import { inject } from "vue"; | ||
import { systemLanguageKey } from "@/arches_lingo/constants.ts"; | ||
import { routeNames } from "@/arches_lingo/routes.ts"; | ||
|
||
import type { Language } from "@/arches_vue_utils/types"; | ||
import type { SchemeResource, ResourceDescriptor } from "@/arches_lingo/types"; | ||
|
||
const systemLanguage = inject(systemLanguageKey) as Language; | ||
|
||
const { scheme } = defineProps<{ scheme: SchemeResource }>(); | ||
const schemeURL = { | ||
name: routeNames.scheme, | ||
params: { id: scheme.resourceinstanceid }, | ||
}; | ||
|
||
const descriptors = scheme.descriptors; | ||
let schemeDescriptor: ResourceDescriptor = { | ||
name: "", | ||
description: "", | ||
}; | ||
if (descriptors) { | ||
const descriptor = | ||
descriptors[systemLanguage.code] ?? Object.values(descriptors)[0]; | ||
schemeDescriptor.name = descriptor.name ?? ""; | ||
schemeDescriptor.description = descriptor.description ?? ""; | ||
} | ||
</script> | ||
|
||
<template> | ||
<RouterLink | ||
:to="schemeURL" | ||
class="scheme-card" | ||
> | ||
<p>{{ schemeDescriptor.name }}</p> | ||
<p>{{ schemeDescriptor.description }}</p> | ||
</RouterLink> | ||
</template> | ||
|
||
<style scoped> | ||
p { | ||
text-align: center; | ||
} | ||
.scheme-card { | ||
text-decoration: none; | ||
color: var(--p-text-color); | ||
width: 15rem; | ||
height: 15rem; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
margin: 0.5rem; | ||
border: 1px solid var(--p-menubar-border-color); | ||
background-color: var(--p-primary-400); | ||
} | ||
.scheme-card:hover { | ||
background-color: var(--p-button-primary-hover-background); | ||
cursor: pointer; | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,64 @@ | ||
<template>Schemes list placeholder</template> | ||
<script setup lang="ts"> | ||
import { onMounted, ref } from "vue"; | ||
import { useGettext } from "vue3-gettext"; | ||
|
||
import { useToast } from "primevue/usetoast"; | ||
import { | ||
DEFAULT_ERROR_TOAST_LIFE, | ||
ERROR, | ||
} from "@/arches_references/constants.ts"; | ||
|
||
import SchemeCard from "@/arches_lingo/components/scheme/SchemeCard.vue"; | ||
import { fetchSchemes } from "@/arches_lingo/api.ts"; | ||
|
||
import type { SchemeResource } from "@/arches_lingo/types"; | ||
|
||
const toast = useToast(); | ||
const { $gettext } = useGettext(); | ||
|
||
const schemes = ref<SchemeResource[]>([]); | ||
|
||
onMounted(async () => { | ||
try { | ||
schemes.value = await fetchSchemes(); | ||
} catch (error) { | ||
toast.add({ | ||
severity: ERROR, | ||
life: DEFAULT_ERROR_TOAST_LIFE, | ||
summary: $gettext("Unable to fetch schemes"), | ||
detail: error instanceof Error ? error.message : undefined, | ||
}); | ||
} | ||
schemes.value.unshift({ | ||
resourceinstanceid: "placeholder-id", | ||
descriptors: { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clicking this populates the front-end route with /placeholder-id, and then refreshing issues a request for that route which fails because placeholder-id is not a uuid. We should harden for this somehow, but maybe without necessarily creating dummy data on the backend that we have to filter out everywhere else (which is what I like about what you're doing here!) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't exactly sure what to do, which is why I ended up punting with As you point out, it's probably not desirable to have a dummy uuid in lieu of string Alternatively, I could mint the new scheme resourceid here - but I see that as less desirable since it would create a new uuid each time All that to say, I'm not exactly sure what to do about this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, got it. If we're about to swap in a new route for the scheme editor then all is good 👍 |
||
en: { | ||
name: "Create a new scheme", | ||
description: "This is a placeholder to create a new scheme", | ||
}, | ||
}, | ||
}); | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<ul class="scheme-cards"> | ||
<li | ||
v-for="scheme in schemes" | ||
:key="scheme.resourceinstanceid" | ||
> | ||
<SchemeCard :scheme="scheme" /> | ||
</li> | ||
</ul> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
.scheme-cards { | ||
display: flex; | ||
flex-wrap: wrap; | ||
list-style-type: none; | ||
padding: 0; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting pattern. An equally valid pattern would be to manually create a list item for this entry. However I like this just fine 👍