Skip to content
Snippets Groups Projects
Commit 9c9efe1f authored by Marcus Eibrink-Lunzenauer's avatar Marcus Eibrink-Lunzenauer Committed by Jan-Hendrik Willms
Browse files

Use `modelValue` in StudipFileChooser when using vue3.

Closes #5053

Merge request !3781
parent 659202bf
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,7 @@ export default { ...@@ -14,7 +14,7 @@ export default {
components: { components: {
FileChooserDialog, FileChooserDialog,
}, },
emits: ['select'], emits: ['update:modelValue'],
props: { props: {
selectable: { selectable: {
type: String, type: String,
...@@ -23,7 +23,7 @@ export default { ...@@ -23,7 +23,7 @@ export default {
return ['file', 'folder'].includes(value); return ['file', 'folder'].includes(value);
}, },
}, },
selectedId: { modelValue: {
type: String, type: String,
required: false, required: false,
}, },
...@@ -48,10 +48,6 @@ export default { ...@@ -48,10 +48,6 @@ export default {
excludedCourseFolderTypes: { type: Array, default: () => [] }, excludedCourseFolderTypes: { type: Array, default: () => [] },
excludedUserFolderTypes: { type: Array, default: () => [] }, excludedUserFolderTypes: { type: Array, default: () => [] },
}, },
model: {
prop: 'selectedId',
event: 'select',
},
data() { data() {
return { return {
showDialog: false, showDialog: false,
...@@ -73,22 +69,22 @@ export default { ...@@ -73,22 +69,22 @@ export default {
}, },
selectedName() { selectedName() {
if (this.selectable === 'folder') { if (this.selectable === 'folder') {
if (this.selectedId === '') { if (this.modelValue === '') {
return this.$gettext('Kein Ordner ausgewählt'); return this.$gettext('Kein Ordner ausgewählt');
} }
return this.$gettext( return this.$gettext(
'Ordner "%{folderName}" ausgewählt' 'Ordner "%{folderName}" ausgewählt'
, ,
{ folderName: this.folderById({ id: this.selectedId })?.attributes?.name ?? '-' } { folderName: this.folderById({ id: this.modelValue })?.attributes?.name ?? '-' }
); );
} }
if (this.selectedId === '') { if (this.modelValue === '') {
return this.$gettext('Keine Datei ausgewählt'); return this.$gettext('Keine Datei ausgewählt');
} }
return this.$gettext( return this.$gettext(
'Datei "%{fileName}" ausgewählt', 'Datei "%{fileName}" ausgewählt',
{ fileName: this.fileById({ id: this.selectedId })?.attributes?.name ?? '-' } { fileName: this.fileById({ id: this.modelValue })?.attributes?.name ?? '-' }
); );
}, },
}, },
...@@ -105,16 +101,16 @@ export default { ...@@ -105,16 +101,16 @@ export default {
}, },
select(id) { select(id) {
this.closeDialog(); this.closeDialog();
this.$emit('select', id); this.$emit('update:modelValue', id);
}, },
loadSelection() { loadSelection() {
if (this.selectable === 'folder') { if (this.selectable === 'folder') {
if (this.selectedId !== '') { if (this.modelValue !== '') {
this.loadFolder({ id: this.selectedId }); this.loadFolder({ id: this.modelValue });
} }
} else { } else {
if (this.selectedId !== '') { if (this.modelValue !== '') {
this.loadFile({ id: this.selectedId }); this.loadFile({ id: this.modelValue });
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment