Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a button from Portlet instance preview dialog - MEED-6924 - Meeds-io/MIPs#139 #97

Merged
merged 1 commit into from
Jun 3, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export default {
type: String,
default: () => '60',
},
previewAction: {
type: String,
default: null,
},
},
data: () => ({
hover: false,
Expand All @@ -88,7 +92,7 @@ export default {
},
methods: {
openIllustration() {
this.$root.$emit('layout-illustration-preview', this.illustrationSrc);
this.$root.$emit('layout-illustration-preview', this.illustrationSrc, this.previewAction);
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@
content-class="overflow-y-initial full-height full-width pa-5">
<template v-if="dialog">
<div class="d-flex justify-end">
<v-btn
v-if="actionClick"
:aria-label="actionLabel"
class="btn btn-primary my-4"
@click="clickOnAction">
<v-icon v-if="actionIcon" color="white">{{ actionIcon }}</v-icon>
<span>{{ actionLabel }}</span>
</v-btn>
<v-btn
:aria-label="$t('pageTemplate.label.close')"
class="ma-4"
Expand All @@ -56,7 +64,11 @@
export default {
data: () => ({
dialog: false,
illustrationSrc: null,
illustrationSrc: null,
actionLabel: null,
actionIcon: null,
actionClick: null,
actionCloseOnClick: null,
}),
watch: {
dialog() {
Expand All @@ -71,10 +83,22 @@ export default {
this.$root.$on('layout-illustration-preview', this.open);
},
methods: {
open(illustrationSrc) {
open(illustrationSrc, action) {
this.illustrationSrc = illustrationSrc;
this.actionIcon = action?.icon;
this.actionLabel = action?.label;
this.actionClick = action?.click;
this.actionCloseOnClick = action?.closeOnClick;
this.dialog = true;
},
clickOnAction() {
if (this.actionCloseOnClick) {
this.dialog = false;
}
if (this.actionClick) {
this.actionClick();
}
},
}
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<layout-image-illustration
ref="illustration"
:value="application"
:preview-action="illustrationAction"
object-type="portletInstance"
max-height="110"
max-width="100%"
Expand Down Expand Up @@ -98,6 +99,13 @@ export default {
illustrationSrc() {
return this.illustrationId && `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/attachments/portletInstance/${this.instanceId}/${this.illustrationId}` || this.defaultImageSrc;
},
illustrationAction() {
return {
label: this.$t('layout.add'),
closeOnClick: true,
click: () => this.$emit('add'),
};
},
},
methods: {
preview() {
Expand Down
Loading