Skip to content

Commit

Permalink
Merge pull request #49568 from nextcloud/template-picker-ux-improvement
Browse files Browse the repository at this point in the history
feat(templates): make second click as confirmation on templates picker
  • Loading branch information
juliusknorr authored Dec 2, 2024
2 parents 9fcf5a5 + 376313a commit aba4d94
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 8 deletions.
7 changes: 6 additions & 1 deletion apps/files/src/components/TemplatePreview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
name="template-picker"
@change="onCheck">

<label :for="id" class="template-picker__label">
<label :for="id" class="template-picker__label" @click="onClick">
<div class="template-picker__preview"
:class="failedPreview ? 'template-picker__preview--failed' : ''">
<img class="template-picker__image"
Expand Down Expand Up @@ -128,6 +128,11 @@ export default {
focus() {
this.$refs.input?.focus()
},
onClick() {
if (this.checked) {
this.$emit('confirm-click', this.fileid)
}
},
},
}
</script>
Expand Down
8 changes: 8 additions & 0 deletions apps/files/src/views/TemplatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
<TemplatePreview v-bind="emptyTemplate"
ref="emptyTemplatePreview"
:checked="checked === emptyTemplate.fileid"
@confirm-click="onConfirmClick"
@check="onCheck" />

<TemplatePreview v-for="template in provider.templates"
:key="template.fileid"
v-bind="template"
:checked="checked === template.fileid"
:ratio="provider.ratio"
@confirm-click="onConfirmClick"
@check="onCheck" />
</ul>

Expand Down Expand Up @@ -207,6 +209,12 @@ export default defineComponent({
this.checked = fileid
},
onConfirmClick(fileid: number) {
if (fileid === this.checked) {
this.onSubmit()
}
},
async createFile(templateFields) {
const currentDirectory = new URL(window.location.href).searchParams.get('dir') || '/'
Expand Down
2 changes: 2 additions & 0 deletions dist/5421-5421.js

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions dist/5421-5421.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/5421-5421.js.map.license
2 changes: 0 additions & 2 deletions dist/694-694.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/694-694.js.map

This file was deleted.

1 change: 0 additions & 1 deletion dist/694-694.js.map.license

This file was deleted.

4 changes: 2 additions & 2 deletions dist/files-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-init.js.map

Large diffs are not rendered by default.

0 comments on commit aba4d94

Please sign in to comment.