Skip to content

Commit

Permalink
Merge pull request #3789 from manuelmeister/bugfix/popover-activator
Browse files Browse the repository at this point in the history
Fix strange popover positioning
  • Loading branch information
manuelmeister committed Sep 22, 2023
2 parents e240d16 + 036eb3d commit 2d16f29
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 56 deletions.
24 changes: 11 additions & 13 deletions frontend/src/components/collaborator/CollaboratorEdit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
:cancel-action="close"
>
<template #moreActions>
<PromptEntityDelete v-if="inactive" :entity="collaborator" x="left" y="top">
<template #activator="{ on, attrs }">
<ButtonDelete
class="v-btn--has-bg"
:disabled="disabled"
v-bind="attrs"
v-on="on"
/>
</template>
<PromptEntityDelete
v-if="inactive"
:entity="collaborator"
align="left"
position="top"
:btn-attrs="{
class: 'v-btn--has-bg',
disabled,
}"
>
{{
$tc('components.collaborator.collaboratorEdit.delete', 0, {
name: name,
})
}}
<br />
</PromptEntityDelete>
<IconButton
v-if="collaborator.status === 'invited'"
Expand Down Expand Up @@ -76,7 +76,7 @@
>
<template #activator="{ on, attrs }">
<div v-bind="attrs" v-on="on">
<PromptCollaboratorDeactivate :entity="collaborator" x="left" y="bottom">
<PromptCollaboratorDeactivate :entity="collaborator">
<template #activator="{ on: onDialog, attrs: attrsDialog }">
<IconButton
color="secondary"
Expand Down Expand Up @@ -125,7 +125,6 @@ import DialogBase from '@/components/dialog/DialogBase.vue'
import CollaboratorForm from '@/components/collaborator/CollaboratorForm.vue'
import { campRoleMixin } from '@/mixins/campRoleMixin.js'
import IconButton from '@/components/buttons/IconButton.vue'
import ButtonDelete from '@/components/buttons/ButtonDelete.vue'
import PromptCollaboratorDeactivate from '@/components/collaborator/PromptCollaboratorDeactivate.vue'
import { errorToMultiLineToast } from '@/components/toast/toasts.js'
import CollaboratorListItem from '@/components/collaborator/CollaboratorListItem.vue'
Expand All @@ -136,7 +135,6 @@ export default {
name: 'CollaboratorEdit',
components: {
PromptEntityDelete,
ButtonDelete,
CollaboratorListItem,
DetailPane,
CollaboratorForm,
Expand Down
64 changes: 30 additions & 34 deletions frontend/src/components/prompt/PopoverPrompt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
offset-y
:close-on-content-click="false"
:close-on-click="true"
nudge-left="1"
allow-overflow
v-bind="{ ...$attrs, ...positions }"
@input="onInput"
>
Expand All @@ -16,15 +16,15 @@
<slot name="activator" />
</div>
<v-alert
:border="y === 'top' ? 'bottom' : 'bottom'"
border="bottom"
colored-border
type="error"
class="mb-0"
class="mb-0 pb-5"
:class="{
'pb-5 rounded-tr-0': y === 'bottom' && x === 'left',
'pb-5 rounded-tl-0': y === 'bottom' && x === 'right',
'pb-5 rounded-br-0': y === 'top' && x === 'left',
'pb-5 rounded-bl-0': y === 'top' && x === 'right',
'rounded-tr-0': position === 'bottom' && align === 'right',
'rounded-tl-0': position === 'bottom' && align === 'left',
'rounded-br-0': position === 'top' && align === 'right',
'rounded-bl-0': position === 'top' && align === 'left',
}"
>
<slot />
Expand Down Expand Up @@ -67,13 +67,13 @@ export default {
name: 'PopoverPrompt',
extends: DialogUiBase,
props: {
x: {
position: {
type: String,
default: 'right',
default: 'bottom',
},
y: {
align: {
type: String,
default: 'top',
default: 'right',
},
},
data: () => ({
Expand All @@ -82,30 +82,21 @@ export default {
computed: {
positions() {
const positions = {}
if (this.x === 'left') {
positions.left = true
} else if (this.x === 'right') {
if (this.align === 'left') {
positions.right = true
} else if (this.align === 'right') {
positions.left = true
}
if (this.y === 'top') {
positions.top = true
if (this.position === 'top') {
positions.nudgeBottom = 10
} else if (this.y === 'bottom') {
positions.top = true
} else if (this.position === 'bottom') {
positions.bottom = true
}
return positions
},
contentClass() {
return (
'ec-popover-prompt ' +
(this.x === 'left'
? this.y === 'bottom'
? 'ec-popover-prompt--topright'
: 'ec-popover-prompt--bottomright'
: this.y === 'bottom'
? 'ec-popover-prompt--topleft'
: 'ec-popover-prompt--bottomleft')
)
return `ec-popover-prompt ec-popover-prompt--position-${this.position} ec-popover-prompt--align-${this.align}`
},
},
methods: {
Expand Down Expand Up @@ -158,27 +149,32 @@ export default {
opacity: 0;
}
.ec-popover-prompt--topleft ::v-deep .ec-activator .v-btn {
.ec-popover-prompt--align-left ::v-deep .ec-activator .v-btn {
left: 0;
}
.ec-popover-prompt--topright ::v-deep .ec-activator .v-btn {
.ec-popover-prompt--align-right ::v-deep .ec-activator .v-btn {
right: 0;
}
.ec-popover-prompt--topleft ::v-deep .ec-activator .v-btn,
.ec-popover-prompt--topright ::v-deep .ec-activator .v-btn {
.ec-popover-prompt--positon-bottom ::v-deep .ec-activator .v-btn {
bottom: 100%;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
box-shadow:
0 5px 5px -3px rgba(0, 0, 0, 0.2),
0 8px 10px 1px rgba(0, 0, 0, 0.14),
0 3px 14px 2px rgba(0, 0, 0, 0.12);
}
.ec-popover-prompt--bottomleft ::v-deep .ec-activator .v-btn,
.ec-popover-prompt--bottomright ::v-deep .ec-activator .v-btn {
.ec-popover-prompt--positon-top ::v-deep .ec-activator .v-btn {
top: calc(100% - 10px);
z-index: 10;
left: 0;
border-top-right-radius: 0;
border-top-left-radius: 0;
box-shadow:
0 5px 5px -3px rgba(0, 0, 0, 0.2),
0 10px 10px 1px rgba(0, 0, 0, 0.14),
0 14px 14px 0 rgba(0, 0, 0, 0.12);
}
</style>
21 changes: 16 additions & 5 deletions frontend/src/components/prompt/PromptEntityDelete.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@
:submit-icon="icon"
cancel-icon=""
:cancel-action="close"
v-bind="$attrs"
>
<template #activator="scope">
<slot name="activator" v-bind="scope" />
<slot name="activator" v-bind="scope">
<ButtonDelete v-bind="{ ...scope.attrs, ...btnAttrs }" v-on="scope.on" />
</slot>
</template>
<slot>{{ $tc('components.prompt.promptEntityDelete.warningText') }}</slot>
<slot>{{
$tc('components.prompt.promptEntityDelete.warningText', warningTextEntity ? 2 : 0, {
entity: warningTextEntity,
})
}}</slot>
<template v-if="$slots.error || error" #error>
<slot name="error">
{{ error }}
Expand All @@ -27,18 +34,22 @@
<script>
import DialogBase from '../dialog/DialogBase.vue'
import PopoverPrompt from '@/components/prompt/PopoverPrompt.vue'
import ButtonDelete from '@/components/buttons/ButtonDelete.vue'
export default {
name: 'PromptEntityDelete',
components: { PopoverPrompt },
components: { ButtonDelete, PopoverPrompt },
extends: DialogBase,
props: {
entity: { type: Object, required: true },
entity: { type: [Object, String], required: true },
submitEnabled: { type: Boolean, required: false, default: true },
icon: { type: String, required: false, default: 'mdi-delete' },
warningTextEntity: { type: String, required: false, default: '' },
btnAttrs: { type: Object, required: false, default: () => {} },
},
created() {
this.entityUri = this.entity._meta.self
this.entityUri =
typeof this.entity === 'string' ? this.entity : this.entity._meta.self
},
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"prompt": {
"promptEntityDelete": {
"title": "Wirklich löschen?",
"warningText": "Möchtest du das wirklich löschen?"
"warningText": "Möchtest du das wirklich löschen? | Möchtest du \"{entity}\" wirklich löschen?"
}
},
"toast": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"prompt": {
"promptEntityDelete": {
"title": "Really delete?",
"warningText": "Do you really want to delete this?"
"warningText": "Do you really want to delete this? | Do you really want to delete \"{entity}\"?"
}
},
"toast": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"prompt": {
"promptEntityDelete": {
"title": "Confirmation de suppression",
"warningText": "Veux-tu vraiment le supprimer ?"
"warningText": "Veux-tu vraiment le supprimer ? | Veux-tu vraiment supprimer \"{entity}\" ?"
}
},
"toast": {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/locales/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
"prompt": {
"promptEntityDelete": {
"title": "Davvero cancellare?",
"warningText": "Volete davvero cancellarlo?"
"warningText": "Volete davvero cancellarlo? | Volete davvero cancellarlo \"{entity}\"?"
}
},
"toast": {
Expand Down

0 comments on commit 2d16f29

Please sign in to comment.