-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from opendatateam/feat/bouquet-draft
feat: bouquet en mode brouillon (private)
- Loading branch information
Showing
9 changed files
with
258 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<script setup lang="ts"> | ||
import type { Ref, ComputedRef } from 'vue' | ||
import { ref, computed } from 'vue' | ||
import { useRouter } from 'vue-router' | ||
import config from '@/config' | ||
import BouquetPropertiesFieldGroup from '@/custom/ecospheres/components/forms/bouquet/BouquetPropertiesFieldGroup.vue' | ||
import type { Bouquet, BouquetCreationData } from '@/model' | ||
import { useTopicStore } from '@/store/TopicStore' | ||
const router = useRouter() | ||
const bouquet: Ref<Partial<Bouquet>> = ref({}) | ||
const isStepValid: Ref<boolean> = ref(false) | ||
const errorMsg: Ref<string | null> = ref(null) | ||
const steps = config.bouquets.steps | ||
const bouquetCreationData: ComputedRef<BouquetCreationData> = computed(() => { | ||
return { | ||
name: bouquet.value.name ?? '', | ||
description: bouquet.value.description ?? '', | ||
tags: [config.universe.name], | ||
private: true | ||
} | ||
}) | ||
const createTopic = async () => { | ||
return useTopicStore().create(bouquetCreationData.value) | ||
} | ||
const submit = () => { | ||
createTopic() | ||
.then((response) => { | ||
router.push({ | ||
name: 'bouquet_edit', | ||
params: { bid: response.id } | ||
}) | ||
}) | ||
.catch((error) => { | ||
errorMsg.value = `Quelque chose s'est mal passé, merci de réessayer. (${error.code})` | ||
}) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="fr-container fr-mt-4w fr-mb-4w"> | ||
<form class="fr-col-12 fr-col-lg-7"> | ||
<div class="fr-grid-row"> | ||
<DsfrStepper :steps="steps" :current-step="1" /> | ||
</div> | ||
<div class="fr-mt-4v"> | ||
<DsfrAlert v-if="errorMsg" type="warning" :title="errorMsg" /> | ||
</div> | ||
<BouquetPropertiesFieldGroup | ||
v-model:bouquetName="bouquet.name" | ||
v-model:bouquetDescription="bouquet.description" | ||
@update-validation="(isValid: boolean) => isStepValid = isValid" | ||
/> | ||
<div class="fit fr-mt-3w fr-ml-auto"> | ||
<DsfrButton | ||
type="button" | ||
class="fr-mt-2w" | ||
label="Suivant" | ||
:disabled="!isStepValid" | ||
@click.prevent="submit()" | ||
/> | ||
</div> | ||
</form> | ||
</div> | ||
</template> |
Oops, something went wrong.