aboutsummaryrefslogtreecommitdiffstats
path: root/core/src/components/LegacyDialogPrompt.vue
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-04-09 19:33:06 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-04-10 13:51:36 +0200
commit46e78d1b8bfc59d767a3c92c924b3cbb112d14ab (patch)
tree8cfd5ee052a345879888cd3d577a9857b1efa92d /core/src/components/LegacyDialogPrompt.vue
parente70cf9c14b2fd53ad47452f1b95ad46fce90155b (diff)
downloadnextcloud-server-46e78d1b8bfc59d767a3c92c924b3cbb112d14ab.tar.gz
nextcloud-server-46e78d1b8bfc59d767a3c92c924b3cbb112d14ab.zip
feat: Deprecate `OC.dialogs.prompt` an replace with Vue implementation
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'core/src/components/LegacyDialogPrompt.vue')
-rw-r--r--core/src/components/LegacyDialogPrompt.vue107
1 files changed, 107 insertions, 0 deletions
diff --git a/core/src/components/LegacyDialogPrompt.vue b/core/src/components/LegacyDialogPrompt.vue
new file mode 100644
index 00000000000..ddaa5f5ffdb
--- /dev/null
+++ b/core/src/components/LegacyDialogPrompt.vue
@@ -0,0 +1,107 @@
+<template>
+ <NcDialog dialog-classes="legacy-prompt__dialog"
+ :buttons="buttons"
+ :name="name"
+ @update:open="$emit('close', false, inputValue)">
+ <p class="legacy-prompt__text" v-text="text" />
+ <NcPasswordField v-if="isPassword"
+ ref="input"
+ autocomplete="new-password"
+ class="legacy-prompt__input"
+ :label="name"
+ :name="inputName"
+ :value.sync="inputValue" />
+ <NcTextField v-else
+ ref="input"
+ class="legacy-prompt__input"
+ :label="name"
+ :name="inputName"
+ :value.sync="inputValue" />
+ </NcDialog>
+</template>
+
+<script lang="ts">
+import { translate as t } from '@nextcloud/l10n'
+import { defineComponent } from 'vue'
+
+import NcDialog from '@nextcloud/vue/dist/Components/NcDialog.js'
+import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
+import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
+
+export default defineComponent({
+ name: 'LegacyDialogPrompt',
+
+ components: {
+ NcDialog,
+ NcTextField,
+ NcPasswordField,
+ },
+
+ props: {
+ name: {
+ type: String,
+ required: true,
+ },
+
+ text: {
+ type: String,
+ required: true,
+ },
+
+ isPassword: {
+ type: Boolean,
+ required: true,
+ },
+
+ inputName: {
+ type: String,
+ default: 'prompt-input',
+ },
+ },
+
+ emits: ['close'],
+
+ data() {
+ return {
+ inputValue: '',
+ }
+ },
+
+ computed: {
+ buttons() {
+ return [
+ {
+ label: t('core', 'No'),
+ callback: () => this.$emit('close', false, this.inputValue),
+ },
+ {
+ label: t('core', 'Yes'),
+ type: 'primary',
+ callback: () => this.$emit('close', true, this.inputValue),
+ },
+ ]
+ },
+ },
+
+ mounted() {
+ this.$nextTick(() => this.$refs.input?.focus?.())
+ },
+})
+</script>
+
+<style scoped lang="scss">
+.legacy-prompt {
+ &__text {
+ margin-block: 0 .75em;
+ }
+
+ &__input {
+ margin-block: 0 1em;
+ }
+}
+
+:deep(.legacy-prompt__dialog .dialog__actions) {
+ min-width: calc(100% - 12px);
+ justify-content: space-between;
+}
+</style>