Skip to content
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

Feature/form decomposition #223

Merged
merged 62 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c472f43
add step 1 - subcomponent
edelagnier Nov 8, 2023
15d411b
add step 3 - (component + form inside component)
edelagnier Nov 8, 2023
ee1c438
add step 4 - with data from sub-component
edelagnier Nov 8, 2023
8181439
Merge branch 'spike/divide_editBouquetCmpt' into feature/form_decompo…
edelagnier Nov 22, 2023
300557e
rename item -> properties
edelagnier Nov 22, 2023
57c5078
set new form in form page
edelagnier Nov 22, 2023
0bbe683
Merge branch 'feature/search_by_subtheme' into feature/form_decomposi…
edelagnier Nov 22, 2023
36c88fb
clean import
edelagnier Nov 22, 2023
1a6e31e
remove step 1 from bigform
edelagnier Nov 22, 2023
c56096f
handle step validation
edelagnier Nov 24, 2023
343f6f1
extract options to configUtils
edelagnier Nov 24, 2023
cf57fe6
distinct Topic and BetaTopic
edelagnier Nov 24, 2023
7a298b6
add step 2
edelagnier Nov 24, 2023
8100d0a
create DatasetList vue
edelagnier Nov 24, 2023
795437b
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 1, 2023
fecf7de
Handle availability and source URL
edelagnier Dec 1, 2023
5e4c70f
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 1, 2023
3413be2
handle accordeon
edelagnier Dec 1, 2023
1d15c33
clarify validation is true by default
edelagnier Dec 6, 2023
e7fc28d
remove warning id is a number
edelagnier Dec 6, 2023
335ff6d
handle remove added dataset
edelagnier Dec 6, 2023
b5a30b4
step 2 and 3 don't need validation
edelagnier Dec 6, 2023
142d721
only display current step
edelagnier Dec 6, 2023
687ba81
title of dataset list
edelagnier Dec 6, 2023
919bd6c
standardize grid
edelagnier Dec 6, 2023
c7772db
declare emits
edelagnier Dec 6, 2023
1f54c9e
standardize size of the stepper
edelagnier Dec 6, 2023
e510e9f
set uri of ecosphere dataset
edelagnier Dec 6, 2023
72a66b6
clean up structure
edelagnier Dec 6, 2023
5955f7f
use local vs eco id
edelagnier Dec 8, 2023
1d7fbba
create topic
edelagnier Dec 8, 2023
424effe
remove warning
edelagnier Dec 8, 2023
3be93d9
add validation for step 2
edelagnier Dec 8, 2023
e266bad
handle validation for step 3 + global
edelagnier Dec 8, 2023
e9d2c7a
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 8, 2023
3c3813d
update to fix vulnerabilities
edelagnier Dec 8, 2023
111ed02
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 8, 2023
cc9cb6e
typo
edelagnier Dec 8, 2023
7b57422
use topicform as bouquet edit view
edelagnier Dec 8, 2023
b273a5f
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 8, 2023
ee691aa
prevent reload !
edelagnier Dec 8, 2023
aad57bb
redirect
edelagnier Dec 8, 2023
806d455
improve layout
edelagnier Dec 8, 2023
db4f505
url is available
edelagnier Dec 8, 2023
4e8d844
dataset form display
edelagnier Dec 8, 2023
77bf7a5
add type
edelagnier Dec 8, 2023
a8782eb
disable subtheme if no theme
edelagnier Dec 8, 2023
a493f4e
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 8, 2023
0710ac6
fix markdown
edelagnier Dec 11, 2023
93c8122
renaming
edelagnier Dec 11, 2023
dc83095
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 12, 2023
687e984
remove unused/duplicate
edelagnier Dec 18, 2023
5f9a099
fix null label
edelagnier Dec 18, 2023
26a330d
move bouquet to custom
edelagnier Dec 18, 2023
4d00aa4
make tooltip info more accessible
edelagnier Dec 18, 2023
10c4879
fix display of available tag
edelagnier Dec 18, 2023
a71bd8d
availability as enum
edelagnier Dec 18, 2023
b115fe9
Merge branch 'main' into feature/form_decomposition
edelagnier Dec 18, 2023
9efd091
fix import
edelagnier Dec 18, 2023
9f20dbe
markdown
edelagnier Dec 19, 2023
d9d6b04
fix behavior after merge
edelagnier Dec 19, 2023
17c3df3
Merge branch 'main' into feature/form_decomposition
abulte Dec 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,098 changes: 1,973 additions & 1,125 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

.multiselect {
--ms-bg: var(--background-contrast-grey);
margin: 8px 0;
}

.fr-col-sm-45 {
Expand Down Expand Up @@ -77,6 +78,10 @@
}
}

.fr-fieldset {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A scoper dans un composant ? Ca me parait un peu dangereux en style global.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf #223 (comment) , le comportement decrit (avoir une marge autour des champs) me parait suffisament generique pour etre mis par defaut au moins dans un premier temps et eviter que l'on ajoute la marge dans chaque composant

margin: 30px 0;
}

.dsfr_alert {
margin: 20px 0;
}
103 changes: 103 additions & 0 deletions src/components/DatasetList.vue
edelagnier marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<template>
<div v-if="numberOfDatasets < 1" class="no-dataset">
<p>Ce bouquet ne contient pas encore de jeux de données</p>
</div>
<div v-else>
<DsfrAccordionsGroup>
<li v-for="(dataset, index) in datasets">
<DsfrAccordion
:title="dataset.title"
:id="getAccordeonId(index)"
:expanded-id="isExpanded[getAccordeonId(index)]"
@expand="isExpanded[getAccordeonId(index)] = $event"
>
<DsfrTag
v-if="!isAvailable(dataset)"
class="fr-mb-2w uppercase bold"
:label="`${dataset.availability}`"
/>
<div>
{{ dataset.purpose }}
</div>
<div class="button__wrapper">
<DsfrButton
icon="ri-delete-bin-line"
label="Retirer de la section"
class="fr-mr-2w"
@click.prevent="this.$emit('removeDataset', index)"
/>
<a
v-if="!isAvailable(dataset)"
class="fr-btn fr-btn--secondary inline-flex"
:href="`mailto:${email}`"
>
Aidez-nous à trouver la donnée</a
>
<a
v-if="dataset.uri"
class="fr-btn fr-btn--secondary inline-flex"
:href="dataset.uri"
target="_blank"
>Accéder au catalogue</a
>
</div>
</DsfrAccordion>
</li>
</DsfrAccordionsGroup>
</div>
</template>

<script lang="ts">
import config from '@/config'
import { type DatasetProperties, Availability } from '@/model'

export const getDatasetListTitle = function (
datasets: DatasetProperties[]
): string {
const title = 'Composition du bouquet '
const numberOfDatasets = datasets.length
switch (numberOfDatasets) {
case 0: {
return title
}
case 1: {
return title + '( 1 jeu de données )'
}
default: {
return title + `( ${numberOfDatasets} jeux de données )`
}
}
}

export default {
name: 'DatasetList',
emits: ['removeDataset'],
props: {
datasets: {
type: Array<DatasetProperties>,
default: []
}
},
data() {
return {
isExpanded: {}
}
},
computed: {
email() {
return config.website.contact_email
},
numberOfDatasets(): number {
return this.datasets.length
}
},
methods: {
getAccordeonId(index: number): string {
return `accordion_${index}`
},
isAvailable(dataset: DatasetProperties): boolean {
return Availability.isAvailable(dataset.availability)
}
}
}
</script>
2 changes: 1 addition & 1 deletion src/components/TopicList.vue
edelagnier marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export default {
}
},
methods: {
isRelevant(topic: Topic, property: string, value): Boolean {
isRelevant(topic: Topic, property: string, value: string): Boolean {
const topicInformations: { subtheme: string; theme: string }[] =
topic.extras['ecospheres:informations']
if (topicInformations) {
Expand Down
59 changes: 16 additions & 43 deletions src/components/TopicSearch.vue
edelagnier marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<label class="fr-label" for="select_theme"> Thématiques </label>
<select class="fr-select" id="select_theme" @change="switchTheme($event)">
<option
:value="this.NoOptionSelected"
:selected="themeName == this.NoOptionSelected"
:value="NoOptionSelected"
:selected="themeName == NoOptionSelected"
>
Choisir une thématique
</option>
Expand All @@ -27,8 +27,8 @@
@change="switchSubtheme($event)"
>
<option
:value="this.NoOptionSelected"
:selected="subthemeName == this.NoOptionSelected"
:value="NoOptionSelected"
:selected="subthemeName == NoOptionSelected"
>
Choisir un chantier
</option>
Expand All @@ -47,20 +47,12 @@
<script lang="ts">
import { defineComponent } from 'vue'

import type { SelectOption } from '@/model'

import config from '../config'
import { NoOptionSelected } from '../model'
import Tile from './Tile.vue'
import { ConfigUtils } from '@/config'
import { NoOptionSelected } from '@/model'
import type { SelectOption, Theme } from '@/model'

export default defineComponent({
name: 'TopicSearch',
components: {
Tile: Tile
},
created() {
this.NoOptionSelected = NoOptionSelected
},
props: {
themeName: {
type: String,
Expand All @@ -72,38 +64,19 @@ export default defineComponent({
}
},
computed: {
selectedTheme() {
for (const theme of this.themeList) {
if (theme.name === this.themeName) {
return theme
}
}
return null
},
themeList() {
return config.themes
selectedTheme(): Theme | null {
return ConfigUtils.getThemeByName(this.themeName)
},
themeOptions(): SelectOption[] {
const options: SelectOption[] = []
for (const theme of this.themeList) {
options.push({
value: theme.name,
text: theme.name
})
}
return options
return ConfigUtils.getThemeOptions()
},
subthemeOptions(): SelectOption[] {
const options: SelectOption[] = []
if (this.selectedTheme) {
for (const subtheme of this.selectedTheme.subthemes) {
options.push({
value: subtheme.name,
text: subtheme.name
})
}
}
return options
return this.selectedTheme
? ConfigUtils.getSubthemeOptions(this.selectedTheme)
: []
},
NoOptionSelected() {
return NoOptionSelected
}
},
methods: {
Expand Down
62 changes: 62 additions & 0 deletions src/components/forms/bouquet/BouquetContentFieldGroup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<template>
<h4>{{ getDatasetListTitle() }}</h4>
<DatasetList
class="fr-mt-4w fr-mb-4w"
@removeDataset="removeDataset"
:datasets="datasets"
/>
<DatasetPropertiesForm
@addDataset="addDataset"
:alreadySelectedDatasets="datasets"
/>
</template>

<script lang="ts">
import DatasetList from '@/components/DatasetList.vue'
import DatasetPropertiesForm from '@/components/forms/dataset/DatasetPropertiesForm.vue'
import type { DatasetProperties } from '@/model'

import { getDatasetListTitle } from '../../DatasetList.vue'

export default {
name: 'BouquetContentFieldGroup',
components: {
DatasetPropertiesForm: DatasetPropertiesForm,
DatasetList: DatasetList
},
props: {
currentDatasets: {
type: Array<DatasetProperties>,
default: []
}
},
data() {
return {
datasets: this.currentDatasets
}
},
watch: {
isValid(newValue) {
this.$emit('updateValidation', newValue)
}
},
computed: {
isValid(): boolean {
return this.datasets.length > 0
}
},
methods: {
addDataset(datasetProperties: DatasetProperties) {
this.datasets.push(datasetProperties)
this.$emit('update:datasets', this.datasets)
},
removeDataset(index: number) {
this.datasets.splice(index, 1)
this.$emit('update:datasets', this.datasets)
},
getDatasetListTitle() {
return getDatasetListTitle(this.datasets)
}
}
}
</script>
98 changes: 98 additions & 0 deletions src/components/forms/bouquet/BouquetFormRecap.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<template>
<h4>
Description du bouquet de données
<DsfrButton
:icon-only="true"
size="sm"
icon="ri-pencil-line"
title="Editer Étape 1"
:tertiary="true"
:no-outline="true"
@click.prevent="goToStep(1)"
/>
</h4>

<p class="fr-mb-0"><strong>Sujet du bouquet</strong></p>
<p v-html="bouquet.name" />
<p class="fr-mb-0"><strong>Objectif du bouquet</strong></p>
<p v-html="markdown(bouquet.description)" />
<hr />

<h4>
Information du bouquet de données
<DsfrButton
:icon-only="true"
size="sm"
icon="ri-pencil-line"
title="Editer Étape 2"
:tertiary="true"
:no-outline="true"
@click.prevent="goToStep(2)"
/>
</h4>
<p class="fr-mb-0"><strong>Thématique</strong></p>
<p v-html="bouquet.theme" />
<p class="fr-mb-0"><strong>Chantier</strong></p>
<p v-html="bouquet.subtheme" />
<hr />

<h4>
{{ getDatasetListTitle() }}
<DsfrButton
:icon-only="true"
size="sm"
icon="ri-pencil-line"
title="Editer Étape 3"
:tertiary="true"
:no-outline="true"
@click.prevent="goToStep(3)"
/>
</h4>
<DatasetList :datasets="bouquet.datasetsProperties" />
</template>

<script lang="ts">
import MarkdownIt from 'markdown-it'
import type { PropType } from 'vue'

import type { Bouquet } from '@/model'

import DatasetList from '../../DatasetList.vue'
import { getDatasetListTitle } from '../../DatasetList.vue'

export default {
name: 'BouquetFormRecap',
emits: ['updateStep'],
components: {
DatasetList: DatasetList
},
props: {
bouquet: {
type: Object as PropType<Partial<Bouquet>>,
default: ''
}
},
computed: {
numberOfDatasets(): number {
return this.datasets.length
},
compositionTitle(): string {
const title = ' Composition du bouquet'
return this.numberOfDatasets < 1
? title
: title + `( ${this.numberOfDatasets} )`
}
},
methods: {
goToStep(step: number) {
this.$emit('updateStep', step)
},
getDatasetListTitle() {
return getDatasetListTitle(this.bouquet.datasetsProperties)
},
markdown(text: string) {
return MarkdownIt().render(text)
}
}
}
</script>
Loading