Skip to content

Commit

Permalink
type new config values and fix raised errors
Browse files Browse the repository at this point in the history
  • Loading branch information
abulte committed Aug 12, 2024
1 parent e215e8b commit dc67535
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 73 deletions.
8 changes: 4 additions & 4 deletions src/components/HomeThemes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ import { useTopicStore } from '@/store/TopicStore'
import Tile from './Tile.vue'
const topicStore = useTopicStore()
const extrasToProcess = config.website.topics.extras_to_process
const extrasToProcess = config.website.topics.extras_to_process as string
const topicName = config.website.topics.topic_name.name as string
const topicSlug = config.website.topics.topic_name.slug as string
const getCustomBoxShadow = (color: string) => {
return `box-shadow: rgb(221, 221, 221) 0px 0px 0px 1px inset, #${color} 0px -4px 0px 0px inset`
}
const topicName = config.website.topics.topic_name.name
const topicSlug = config.website.topics.topic_name.slug
const getThemeDescription = (theme: Theme) => {
const nbBouquets = topicStore.data.filter((topic) => {
return !topic.private && topic.extras[extrasToProcess].theme === theme.name
Expand Down
8 changes: 3 additions & 5 deletions src/components/bouquets/BouquetCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import { useExtras } from '@/utils/bouquet'
import { useSpatialCoverage } from '@/utils/spatial'
import { getThemeColor, getThemeTextColor } from '@/utils/theme'
const topicName = config.website.topics.topic_name.name
const topicSlug = config.website.topics.topic_name.slug
const topicSlug = config.website.topics.topic_name.slug as string
const extrasToProcess = config.website.topics.extras_to_process as string
const props = defineProps({
bouquet: {
Expand All @@ -27,9 +27,7 @@ const props = defineProps({
}
})
const extrasToProcess = config.website.topics.extras_to_process
const bouquetRef = toRef(props, topicName)
const bouquetRef = toRef(props, 'bouquet')
const spatialCoverage = useSpatialCoverage(bouquetRef)
const ownerName = useOwnerName(props.bouquet)
Expand Down
4 changes: 2 additions & 2 deletions src/components/bouquets/BouquetDatasetList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const expandStore: Ref<{ [key: string]: string | null }> = ref({})
// make a copy for local reordering before save
const originalDatasets = ref([...datasets.value])
const topicName = config.website.topics.topic_name.name
const topicName = config.website.topics.topic_name.name as string
const expandedIds = computed(() => {
return Object.keys(expandStore.value).filter((k) => !!expandStore.value[k])
Expand All @@ -60,7 +60,7 @@ const getAccordeonId = (index: number): string => {
const removeDataset = (index: number) => {
if (
window.confirm(
`Etes-vous sûr de vouloir supprimer ce jeu de données du ${topicName.value} ?`
`Etes-vous sûr de vouloir supprimer ce jeu de données du ${topicName} ?`
)
) {
delete expandStore.value[getAccordeonId(index)]
Expand Down
8 changes: 4 additions & 4 deletions src/components/bouquets/BouquetSearch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ const selectedSpatialCoverage: Ref<SpatialCoverage | undefined> = ref(undefined)
const themeNameRef = toRef(props, 'themeName')
const { themeOptions, subthemeOptions } = useThemeOptions(themeNameRef)
const topicName = config.website.topics.topic_name.slug
const useThemes = config.website.topics.themes.usage
const mainTheme = config.website.topics.themes.main_name
const secondaryTheme = config.website.topics.themes.secondary_name
const topicName = config.website.topics.topic_name.slug as string
const useThemes = config.website.topics.themes.usage as boolean
const mainTheme = config.website.topics.themes.main_name as string
const secondaryTheme = config.website.topics.themes.secondary_name as string
const localShowDrafts = ref(false)
const computeQueryArgs = (
Expand Down
13 changes: 5 additions & 8 deletions src/components/datasets/DatasetAddToBouquetModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const datasetEditorialization = ref(
config.website.topics.dataset_editorialization
)
const topicName = config.website.topics.topic_name.name
const topicName = config.website.topics.topic_name.name as string
const bouquets = topicStore.myTopics
const datasetProperties = ref<DatasetProperties>({
Expand Down Expand Up @@ -103,12 +103,9 @@ const submit = async () => {
tags: bouquet.tags,
extras: bouquet.extras
})
toast(
`Jeu de données ajouté avec succès au ${topicName.value} "${bouquet.name}"`,
{
type: 'success'
}
)
toast(`Jeu de données ajouté avec succès au ${topicName} "${bouquet.name}"`, {
type: 'success'
})
closeModal()
}
Expand Down Expand Up @@ -151,8 +148,8 @@ onMounted(() => {
</DsfrSelect>

<DatasetPropertiesTextFields
v-model:dataset-properties="datasetProperties"
v-if="datasetEditorialization"
v-model:dataset-properties="datasetProperties"
/>
</DsfrModal>
</template>
16 changes: 8 additions & 8 deletions src/components/forms/bouquet/BouquetForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ const emits = defineEmits(['updateValidation'])
const spatialCoverage = useSpatialCoverage(topic)
const extrasToProcess = config.website.topics.extras_to_process
const useThemes = config.website.topics.themes.usage
const mainTheme = config.website.topics.themes.main_name
const secondaryTheme = config.website.topics.themes.secondary_name
const extrasToProcess = config.website.topics.extras_to_process as string
const useThemes = config.website.topics.themes.usage as boolean
const mainTheme = config.website.topics.themes.main_name as string
const secondaryTheme = config.website.topics.themes.secondary_name as string
const topicName = config.website.topics.topic_name.name
const topicSlug = config.website.topics.topic_name.slug
const topicName = config.website.topics.topic_name.name as string
const topicSlug = config.website.topics.topic_name.slug as string
const theme = ref(NoOptionSelected)
const subtheme = ref(NoOptionSelected)
const isValid = computed(() => {
if (useThemes.value) {
if (useThemes) {
return (
topic.value.name &&
topic.value.name.trim() !== '' &&
Expand Down Expand Up @@ -132,7 +132,7 @@ onMounted(() => {
/>
</div>
<!-- Theme -->
<div class="fr-select-group fr-mt-1w" v-if="useThemes">
<div v-if="useThemes" class="fr-select-group fr-mt-1w">
<label class="fr-label" for="select_theme"
>{{ mainTheme }} <span class="required">&nbsp;*</span></label
>
Expand Down
2 changes: 1 addition & 1 deletion src/components/forms/bouquet/BouquetOwnerForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const choice: Ref<'organization' | 'owner'> = ref(
)
const organizations = computed(() => userStore.data?.organizations || [])
const topicName = config.website.topics.topic_name.name
const topicName = config.website.topics.topic_name.name as string
const onSelectOrganization = (value: string) => {
const idx = parseInt(value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const props = defineProps({
}
})
const topicName = config.website.topics.topic_name.name
const topicName = config.website.topics.topic_name.name as string
const emit = defineEmits(['update:datasetProperties'])
Expand Down
8 changes: 5 additions & 3 deletions src/components/topics/TopicDataTile.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<script setup>
<script setup lang="ts">
import config from '@/config'
defineProps(['topicsData', 'urlHighlightedTopics'])
const goToPage = (page) => {
const goToPage = (page: string) => {
window.location.href = page
}
const mainTheme = config.website.topics.themes.main_name
const mainTheme = config.website.topics.themes.main_name as string
</script>

<template>
Expand Down
10 changes: 5 additions & 5 deletions src/utils/bouquet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const updateTopicPropertiesExtras = (
*/
export const cloneTopic = (
topic: Topic,
extrasToProcess: Ref<string>
extrasToProcess: string
): TopicPostData => {
const { id, slug, ...data } = topic
return {
Expand All @@ -56,7 +56,7 @@ export const cloneTopic = (
{
cloned_from: topic.id,
datasets_properties: topic.extras[
extrasToProcess.value
extrasToProcess
].datasets_properties.map((dp: any) => {
return {
...dp,
Expand All @@ -66,7 +66,7 @@ export const cloneTopic = (
}
})
},
extrasToProcess.value
extrasToProcess
)
}
}
Expand All @@ -75,11 +75,11 @@ export function useBreadcrumbLinksForTopic(
theme: Ref<string | undefined>,
subtheme: Ref<string | undefined>,
topic: Ref<Topic | null>,
pageAllTopics: Ref<boolean | null>
pageAllTopics: boolean | null
): ComputedRef<BreadcrumbItem[]> {
return computed(() => {
const breadcrumbs = [{ to: '/', text: 'Accueil' }]
if (pageAllTopics.value === true) {
if (pageAllTopics === true) {
breadcrumbs.push({ to: `/${topicSlug}`, text: `${topicName}s` })
}

Expand Down
25 changes: 13 additions & 12 deletions src/views/bouquets/BouquetDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,14 @@ let subtheme = ref<string | undefined>(undefined)
let datasetsProperties = ref<DatasetProperties[]>([])
let clonedFrom = ref<Topic | null>(null)
const extrasToProcess = config.website.topics.extras_to_process
const useThemes = config.website.topics.themes.usage
const pageAllTopics = config.website.topics.page_all_topics
const displayMetadata = config.website.topics.display_metadata
const activateReadMore = config.website.topics.activate_read_more
const datasetEditorialization = config.website.topics.dataset_editorialization
const topicSlug = config.website.topics.topic_name.slug
const extrasToProcess = config.website.topics.extras_to_process as string
const useThemes = config.website.topics.themes.usage as boolean
const pageAllTopics = config.website.topics.page_all_topics as boolean
const displayMetadata = config.website.topics.display_metadata as boolean
const activateReadMore = config.website.topics.activate_read_more as boolean
const datasetEditorialization = config.website.topics
.dataset_editorialization as boolean
const topicSlug = config.website.topics.topic_name.slug as string
let extras = useExtras(topic, extrasToProcess)
datasetsProperties = extras.datasetsProperties
Expand All @@ -84,14 +85,14 @@ const breadcrumbLinks = useBreadcrumbLinksForTopic(
const goToEdit = () => {
router.push({
name: `${topicSlug.value}_edit`,
name: `${topicSlug}_edit`,
params: { bid: topic.value?.id }
})
}
const goToClone = () => {
router.push({
name: `${topicSlug.value}_add`,
name: `${topicSlug}_add`,
query: { clone: topic.value?.id }
})
}
Expand Down Expand Up @@ -127,7 +128,7 @@ const onUpdateDatasets = () => {
({ remoteDeleted, ...data }) => data
)
},
extrasToProcess.value
extrasToProcess
)
})
.finally(() => loader.hide())
Expand All @@ -143,7 +144,7 @@ const metaTitle = (): string => {
const metaLink = (): string => {
const resolved = router.resolve({
name: `${topicSlug.value}_detail`,
name: `${topicSlug}_detail`,
params: { bid: topic.value?.slug }
})
return `${window.location.origin}${resolved.href}`
Expand All @@ -169,7 +170,7 @@ watch(
topic.value = res
if (topic.value.slug !== props.bouquetId) {
router.push({
name: `${topicSlug.value}_detail`,
name: `${topicSlug}_detail`,
params: { bid: topic.value.slug }
})
}
Expand Down
25 changes: 11 additions & 14 deletions src/views/bouquets/BouquetFormView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ const showAddBouquet = ref(computed(() => userStore.updateShowAddBouquet()))
const router = useRouter()
const routeParams = useRouteParamsAsString().params
const routeQuery = useRouteQueryAsString().query
const extrasToProcess = config.website.topics.extras_to_process
const topicName = config.website.topics.topic_name.name
const topicSlug = config.website.topics.topic_name.slug
const extrasToProcess = config.website.topics.extras_to_process as string
const topicName = config.website.topics.topic_name.name as string
const topicSlug = config.website.topics.topic_name.slug as string
const topic: Ref<Partial<TopicPostData>> = ref({
private: true,
tags: [extrasToProcess.value],
tags: [extrasToProcess],
spatial: routeQuery.geozone ? { zones: [routeQuery.geozone] } : undefined,
extras: {
[extrasToProcess.value]: {
[extrasToProcess]: {
theme: routeQuery.theme || NoOptionSelected,
subtheme: routeQuery.subtheme || NoOptionSelected,
datasets_properties: []
Expand All @@ -46,8 +46,7 @@ const errorMsg = ref('')
const canSave = ref(false)
const isReadyForForm = computed(() => {
const extrasProperty = extrasToProcess.value
const extras = topic.value?.extras?.[extrasProperty] as
const extras = topic.value?.extras?.[extrasToProcess] as
| TopicExtrasToProcess
| undefined
return (
Expand All @@ -62,7 +61,7 @@ const handleTopicOperation = (operation: (...args: any[]) => Promise<any>) => {
operation()
.then((response) => {
router.push({
name: `${topicSlug.value}_detail`,
name: `${topicSlug}_detail`,
params: { bid: response.slug }
})
})
Expand Down Expand Up @@ -97,12 +96,10 @@ const destroy = async () => {
if (topic.value?.id === undefined) {
throw Error('Trying to delete topic without topic id')
}
if (
window.confirm(`Etes-vous sûr de vouloir supprimer ce ${topicName.value} ?`)
) {
if (window.confirm(`Etes-vous sûr de vouloir supprimer ce ${topicName} ?`)) {
useTopicStore()
.delete(topic.value.id)
.then(() => router.push({ name: topicSlug.value }))
.then(() => router.push({ name: topicSlug }))
.catch((error) => {
errorMsg.value = `Quelque chose s'est mal passé, merci de réessayer. (${error.code})`
})
Expand All @@ -112,13 +109,13 @@ const destroy = async () => {
const cancel = () => {
if (props.isCreate) {
if (routeQuery.clone == null) {
router.push({ name: topicSlug.value })
router.push({ name: topicSlug })
} else {
router.go(-1)
}
} else {
router.push({
name: `${topicSlug.value}_detail`,
name: `${topicSlug}_detail`,
params: {
bid: topic.value.slug
}
Expand Down
6 changes: 3 additions & 3 deletions src/views/datasets/DatasetDetailView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const selectedTabIndex = ref(0)
const license = ref<License>()
const showAddToBouquetModal = ref(false)
const pageSize = config.website.pagination_sizes.files_list
const showDiscussions = config.website.discussions.dataset.display
const topicName = config.website.topics.topic_name.name
const pageSize = config.website.pagination_sizes.files_list as number
const showDiscussions = config.website.discussions.dataset.display as boolean
const topicName = config.website.topics.topic_name.name as string
const updateQuery = (q: string, typeId: string) => {
resources.value[typeId].query = q
Expand Down
7 changes: 4 additions & 3 deletions src/views/datasets/DatasetsListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ const selectedOrganizationId: Ref<string | null> = ref(null)
const datasets = computed(() => store.datasets)
const pages = computed(() => store.pagination)
const title = config.website.title
const title = config.website.title as string
const topicsConf = config.website.list_search_topics as TopicConf[]
const hasOrganizationFilter = config.website.datasets.organization_filter
const hasOrganizationFilter = config.website.datasets
.organization_filter as boolean
const mainTheme = config.website.topics.themes.main_name
const mainTheme = config.website.topics.themes.main_name as string
const topicOptions = computed(() => {
if (!topicsConf?.length) return
Expand Down

0 comments on commit dc67535

Please sign in to comment.