-
Notifications
You must be signed in to change notification settings - Fork 3
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
Changes from all commits
c472f43
15d411b
ee1c438
8181439
300557e
57c5078
0bbe683
36c88fb
1a6e31e
c56096f
343f6f1
cf57fe6
7a298b6
8100d0a
795437b
fecf7de
5e4c70f
3413be2
1d15c33
e7fc28d
335ff6d
b5a30b4
142d721
687ba81
919bd6c
c7772db
1f54c9e
e510e9f
72a66b6
5955f7f
1d7fbba
424effe
3be93d9
e266bad
e9d2c7a
3c3813d
111ed02
cc9cb6e
7b57422
b273a5f
ee691aa
aad57bb
806d455
db4f505
4e8d844
77bf7a5
a8782eb
a493f4e
0710ac6
93c8122
dc83095
687e984
5f9a099
26a330d
4d00aa4
10c4879
a71bd8d
b115fe9
9efd091
9f20dbe
d9d6b04
17c3df3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ | |
|
||
.multiselect { | ||
--ms-bg: var(--background-contrast-grey); | ||
margin: 8px 0; | ||
} | ||
|
||
.fr-col-sm-45 { | ||
|
@@ -87,6 +88,15 @@ | |
} | ||
} | ||
|
||
.fr-fieldset { | ||
margin: 30px 0; | ||
} | ||
|
||
.dsfr_alert { | ||
margin: 20px 0; | ||
} | ||
|
||
textarea { | ||
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. A scoper dans un composant ? Ca me parait un peu dangereux en style global. 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. dans le cas du fichier main.css et model.ts, j'ai volontairement fait le choix de centraliser sans structurer dans un premier temps. Le but est de voir d'abord comment grossissent ces fichiers pour creer une structure pertinente et eviter d'optimiser/specialiser trop tot. Le comportement decrit ici (avoir une marge autour du champs pour la lisibilite et le definir par defaut plus grand pour inciter les utilisateurs a ecrire du texte markdown et non une phrase) me semble suffisament pertinent pour servir de base par defaut. Je serai donc pour le laisser. Le danger est faible et la source facilement identifiable si l'on veut changer le comportement dans des cas specifiques (et reduire le scope s'il s'avere moins generique que prevu). |
||
margin: 20px 0; | ||
height: 250px; | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import config from '@siteConfig/config.yaml' | ||
|
||
import type { SelectOption, Theme } from '@/model' | ||
|
||
class ConfigUtils { | ||
config = config | ||
|
||
public static getThemeOptions() { | ||
const options: SelectOption[] = [] | ||
for (const theme of config.themes) { | ||
options.push({ | ||
value: theme.name, | ||
text: theme.name | ||
}) | ||
} | ||
return options | ||
} | ||
|
||
public static getSubthemeOptions(theme: Theme) { | ||
const options: SelectOption[] = [] | ||
if (theme) { | ||
for (const subtheme of theme.subthemes) { | ||
options.push({ | ||
value: subtheme.name, | ||
text: subtheme.name | ||
}) | ||
} | ||
} | ||
return options | ||
} | ||
|
||
public static getThemeByName(name: string): Theme | null { | ||
for (const theme of config.themes) { | ||
if (theme.name === name) { | ||
return theme | ||
} | ||
} | ||
return null | ||
} | ||
} | ||
Comment on lines
+5
to
+40
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. A mettre dans un fichier 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. Je pense qu'il faudrait faire une nouvelle PR pour organiser proprement les custom vs generic car cela sort du scope de celle ci qui visait uniquement la decomposition. 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. |
||
|
||
export default config | ||
export { ConfigUtils } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<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, | ||
isAvailable as isAvailableTest | ||
} 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: 'BouquetDatasetList', | ||
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 isAvailableTest(dataset.availability) | ||
} | ||
} | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,13 +39,13 @@ | |
import { onMounted } from 'vue' | ||
import { useLoading } from 'vue-loading-overlay' | ||
|
||
import type { Topic } from '../model' | ||
import { NoOptionSelected } from '../model' | ||
import { useTopicStore } from '../store/TopicStore' | ||
import Tile from './Tile.vue' | ||
import Tile from '@/components/Tile.vue' | ||
import type { Topic } from '@/model' | ||
import { NoOptionSelected } from '@/model' | ||
import { useTopicStore } from '@/store/TopicStore' | ||
|
||
export default { | ||
name: 'TopicList', | ||
name: 'BouquetList', | ||
components: { | ||
Tile: Tile | ||
}, | ||
|
@@ -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'] | ||
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. En profiter pour utiliser 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. |
||
if (topicInformations) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<template> | ||
<h4>{{ getDatasetListTitle() }}</h4> | ||
<BouquetDatasetList | ||
class="fr-mt-4w fr-mb-4w" | ||
@removeDataset="removeDataset" | ||
:datasets="datasets" | ||
/> | ||
<DatasetPropertiesForm | ||
@addDataset="addDataset" | ||
:alreadySelectedDatasets="datasets" | ||
/> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import BouquetDatasetList from '@/custom/ecospheres/components/BouquetDatasetList.vue' | ||
import DatasetPropertiesForm from '@/custom/ecospheres/components/forms/dataset/DatasetPropertiesForm.vue' | ||
import type { DatasetProperties } from '@/model' | ||
|
||
import { getDatasetListTitle } from '../../BouquetDatasetList.vue' | ||
|
||
export default { | ||
name: 'BouquetContentFieldGroup', | ||
components: { | ||
DatasetPropertiesForm: DatasetPropertiesForm, | ||
BouquetDatasetList: BouquetDatasetList | ||
}, | ||
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> |
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.
A scoper dans un composant ? Ca me parait un peu dangereux en style global.
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.
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