Skip to content

Commit b706130

Browse files
authored
Merge pull request #292 from dnum-mi/develop
RC7
2 parents cd451e2 + bde96f5 commit b706130

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

src/components/DsfrFileUpload/DsfrFileUpload.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ export default defineComponent({
2222
type: String,
2323
default: undefined,
2424
},
25+
modelValue: {
26+
type: String,
27+
default: undefined,
28+
},
29+
},
30+
31+
emits: ['update:modelValue', 'change'],
32+
33+
methods: {
34+
onChange ($event) {
35+
this.$emit('update:modelValue', $event.target.value)
36+
this.$emit('change', $event.target.files)
37+
},
2538
},
2639
})
2740
</script>
@@ -48,6 +61,8 @@ export default defineComponent({
4861
type="file"
4962
:aria-describedby="`${id}-desc`"
5063
v-bind="$attrs"
64+
:value="modelValue"
65+
@change="onChange($event)"
5166
>
5267
<p
5368
v-if="error"

src/demo-app/App.vue

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import DsfrHeader from '../components/DsfrHeader/DsfrHeader.vue'
77
import DsfrNavigation from '../components/DsfrNavigation/DsfrNavigation.vue'
88
import DsfrSkipLinks from '../components/DsfrSkipLinks/DsfrSkipLinks.vue'
99
import DsfrModal from '../components/DsfrModal/DsfrModal.vue'
10+
import DsfrFileUpload from '../components/DsfrFileUpload/DsfrFileUpload.vue'
1011
1112
const isModalOpen = ref(false)
1213
const displayAlert = ref(false)
@@ -19,6 +20,16 @@ const close = () => {
1920
}
2021
2122
const inputValue = ref('')
23+
const filesToUpload = ref(undefined)
24+
25+
const updateFiles = (files) => {
26+
console.log(files)
27+
}
28+
29+
const sendFile = () => {
30+
console.log('inputValue:', inputValue.value)
31+
console.log('filesToUpload:', filesToUpload.value)
32+
}
2233
2334
// eslint-disable-next-line no-unused-vars
2435
const actions = [
@@ -148,11 +159,23 @@ const navItems = [
148159
</DsfrAccordion>
149160
</li>
150161
</DsfrAccordionsGroup>
151-
<DsfrInput
152-
v-model="inputValue"
153-
label="Test"
154-
label-visible
155-
/>
162+
<form @submit.prevent="sendFile()">
163+
<DsfrInput
164+
v-model="inputValue"
165+
label="Test"
166+
label-visible
167+
/>
168+
<DsfrFileUpload
169+
v-model="filesToUpload"
170+
label="Test"
171+
label-visible
172+
@change="updateFiles($event)"
173+
/>
174+
<input
175+
type="submit"
176+
value="OK"
177+
>
178+
</form>
156179
</div>
157180

158181
<DsfrModal

0 commit comments

Comments
 (0)