Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions apps/files_sharing/src/components/NewFileRequestDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
data-cy-file-request-dialog
:close-on-click-outside="false"
:name="currentStep !== STEP.LAST ? t('files_sharing', 'Create a file request') : t('files_sharing', 'File request created')"
:set-return-focus="returnFocusTarget"
size="normal"
@closing="onCancel">
<!-- Header -->
Expand Down Expand Up @@ -226,6 +227,10 @@ export default defineComponent({
},

methods: {
returnFocusTarget(): HTMLElement | null {
return document.querySelector<HTMLElement>('[data-cy-upload-picker] button')
},

onPageNext() {
const form = this.$refs.form as HTMLFormElement

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
v-if="expirationDate !== null"
id="file-request-dialog-expirationDate"
:disabled="disabled"
:hide-label="true"
:label="t('files_sharing', 'Expiration date')"
:max="maxDate"
:min="minDate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,27 @@
@focusout.native="addNewEmail" />

<!-- Email list -->
<div v-if="emails.length > 0" class="file-request-dialog__emails">
<NcChip
v-for="mail in emails"
:key="mail"
:aria-label-close="t('files_sharing', 'Remove email')"
:text="mail"
@close="$emit('remove-email', mail)">
<template #icon>
<NcAvatar
disable-menu
disable-tooltip
:display-name="mail"
is-no-user
hide-status
:size="24" />
</template>
</NcChip>
</div>
<ul
v-if="emails.length > 0"
class="file-request-dialog__emails"
:aria-label="t('files_sharing', 'Recipient emails')">
<li v-for="mail in emails" :key="mail">
<NcChip
:aria-label-close="t('files_sharing', 'Remove email: {email}', { email: mail })"
:text="mail"
@close="$emit('remove-email', mail)">
<template #icon>
<NcAvatar
disable-menu
disable-tooltip
:display-name="mail"
is-no-user
hide-status
:size="24" />
</template>
</NcChip>
</li>
</ul>
</template>
</div>
</template>
Expand Down Expand Up @@ -229,14 +232,16 @@ export default defineComponent({
</script>

<style scoped>
.input-field,
.file-request-dialog__emails {
.input-field {
margin-top: var(--margin);
}

.file-request-dialog__emails {
display: flex;
gap: var(--default-grid-baseline);
flex-wrap: wrap;
gap: var(--default-grid-baseline);
list-style: none;
margin-block: var(--margin) 0;
padding-inline: 0;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
<!-- Request label -->
<fieldset class="file-request-dialog__label" data-cy-file-request-dialog-fieldset="label">
<legend>
{{ t('files_sharing', 'What are you requesting?') }}
<label class="file-request-dialog__legend-label" for="file-request-dialog-label">
{{ t('files_sharing', 'What are you requesting?') }}
</label>
</legend>
<NcTextField
id="file-request-dialog-label"
:model-value="label"
:disabled="disabled"
:label="t('files_sharing', 'Request subject')"
Expand All @@ -23,9 +26,12 @@
<!-- Request destination -->
<fieldset class="file-request-dialog__destination" data-cy-file-request-dialog-fieldset="destination">
<legend>
{{ t('files_sharing', 'Where should these files go?') }}
<label class="file-request-dialog__legend-label" for="file-request-dialog-destination">
{{ t('files_sharing', 'Where should these files go?') }}
</label>
</legend>
<NcTextField
id="file-request-dialog-destination"
:model-value="destination"
:disabled="disabled"
:label="t('files_sharing', 'Upload destination')"
Expand All @@ -37,9 +43,10 @@
trailing-button-icon="undo"
:trailing-button-label="t('files_sharing', 'Revert to default')"
name="destination"
aria-haspopup="dialog"
@click="onPickDestination"
@keypress.prevent.stop="/* prevent typing in the input, we use the picker */"
@paste.prevent.stop="/* prevent pasting in the input, we use the picker */"
@keydown="onDestinationKeydown"
@paste.prevent.stop
@trailing-button-click="$emit('update:destination', '')">
<IconFolder :size="18" />
</NcTextField>
Expand All @@ -53,9 +60,12 @@
<!-- Request note -->
<fieldset class="file-request-dialog__note" data-cy-file-request-dialog-fieldset="note">
<legend>
{{ t('files_sharing', 'Add a note') }}
<label class="file-request-dialog__legend-label" for="file-request-dialog-note">
{{ t('files_sharing', 'Add a note') }}
</label>
</legend>
<NcTextArea
id="file-request-dialog-note"
:model-value="note"
:disabled="disabled"
:label="t('files_sharing', 'Note for recipient')"
Expand Down Expand Up @@ -138,6 +148,22 @@ export default defineComponent({
},

methods: {
onDestinationKeydown(event: KeyboardEvent) {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
this.onPickDestination()
return
}

// Destination is chosen in the picker, not by editing this field
if (event.ctrlKey || event.metaKey || event.altKey) {
return
}
if (event.key.length === 1 || event.key === 'Backspace' || event.key === 'Delete') {
event.preventDefault()
}
},

onPickDestination() {
const filepicker = getFilePickerBuilder(t('files_sharing', 'Select a destination'))
.addMimeTypeFilter('httpd/unix-directory')
Expand Down Expand Up @@ -168,6 +194,16 @@ export default defineComponent({
</script>

<style scoped>
.file-request-dialog__legend-label {
font: inherit;
color: inherit;
cursor: pointer;
}

.file-request-dialog__destination :deep(.input-field__input) {
cursor: pointer;
}

.file-request-dialog__note :deep(textarea) {
width: 100% !important;
min-height: 80px;
Expand Down
4 changes: 3 additions & 1 deletion apps/files_sharing/src/files_newMenu/newFileRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ export const entry: NewMenuEntry = {
return sharingConfig.isPublicShareAllowed
},
async handler(context: Folder, content: Node[]) {
spawnDialog(NewFileRequestDialogVue, {
await spawnDialog(NewFileRequestDialogVue, {
context,
content,
})
// The menu item that opened the dialog is gone; send focus back to New
document.querySelector<HTMLElement>('[data-cy-upload-picker] button')?.focus()
},
}
Loading