Skip to content

Commit

Permalink
feat: Add Portlets Portlet - MEED-6902 - Meeds-io/MIPs#139
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker committed May 23, 2024
1 parent 1d6f2c9 commit 9d35c81
Show file tree
Hide file tree
Showing 44 changed files with 1,408 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,36 @@ pageTemplate.label.confirmDeleteTitle=Delete page template?
pageTemplate.label.confirmDeleteMessage=Would you like to delete page template: {0}
pageTemplate.label.confirm=Confirm
pageTemplate.label.cancel=Cancel
portlets=Portlets
portlets.instances=instances
portlets.filter.placeholder=Filter by name, description
portlets.label.disableInstance=Disable instance
portlets.label.enableInstance=Enable instance
portlets.status.update.success=Template status successfully updated
portlets.status.update.error=An unknown error occurred while updating instance. Please contact the administrator or try agan later.
portlets.layout.update.success=Template layout successfully updated
portlets.layout.update.error=An unknown error occurred while updating instance. Please contact the administrator or try agan later.
portlets.delete.success=Template successfully deleted
portlets.delete.error=An unknown error occurred while deleting instance. Please contact the administrator or try agan later.
portlets.label.confirmDeleteTitle=Delete page template?
portlets.label.confirmDeleteMessage=Would you like to delete page template: {0}
portlets.label.confirm=Confirm
portlets.label.cancel=Cancel
portlets.label.name=Name
portlets.label.instances=Instances
portlets.label.description=Description
portlets.label.status=Status
portlets.label.actions=Actions
portlets.menu.open=Open Menu
portlets.label.instanceMenu={0}
portlets.label.menu={0}
portlets.label.closeMenu=Close Menu
portlets.label.editLayout=Edit Layout
portlets.label.system.noEditLayout=This portlet instance's layout cannot be updated
portlets.label.editProperties=Edit Properties
portlets.label.duplicate=Duplicate
portlets.label.delete=Delete
portlets.label.system.noDelete=This portlet instance cannot be deleted
portlets.label.preview=Preview of {0}
portlets.label.openIllustrationPreview=Open illustration Preview
31 changes: 31 additions & 0 deletions layout-webapp/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,5 +266,36 @@
</module>
</portlet>

<portlet>
<name>Portlets</name>
<module>
<script>
<minify>false</minify>
<path>/js/portlets.bundle.js</path>
</script>
<depends>
<module>commonVueComponents</module>
</depends>
<depends>
<module>commonLayoutComponents</module>
</depends>
<depends>
<module>attachImage</module>
</depends>
<depends>
<module>translationField</module>
</depends>
<depends>
<module>applicationToolbarComponent</module>
</depends>
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>eXoVueI18n</module>
</depends>
</module>
</portlet>

</gatein-resources>

23 changes: 23 additions & 0 deletions layout-webapp/src/main/webapp/WEB-INF/portlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
<name>portlet-view-dispatched-file-path</name>
<value>/html/pageTemplatesManagement.html</value>
</init-param>
<expiration-cache>-1</expiration-cache>
<cache-scope>PUBLIC</cache-scope>
<supports>
<mime-type>text/html</mime-type>
</supports>
Expand All @@ -97,4 +99,25 @@
</portlet-info>
</portlet>

<portlet>
<portlet-name>Portlets</portlet-name>
<display-name>Portlets</display-name>
<portlet-class>org.exoplatform.commons.api.portlet.GenericDispatchedViewPortlet</portlet-class>
<init-param>
<name>portlet-view-dispatched-file-path</name>
<value>/html/portlets.html</value>
</init-param>
<expiration-cache>-1</expiration-cache>
<cache-scope>PUBLIC</cache-scope>
<supports>
<mime-type>text/html</mime-type>
</supports>
<supported-locale>en</supported-locale>
<resource-bundle>locale.portlet.LayoutEditor</resource-bundle>
<portlet-info>
<title>Portlets</title>
<keywords>Portlets</keywords>
</portlet-info>
</portlet>

</portlet-app>
7 changes: 7 additions & 0 deletions layout-webapp/src/main/webapp/html/portlets.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="VuetifyApp">
<div id="portletsManagement">
<script type="text/javascript">
require(['PORTLET/layout/Portlets'], app => app.init());
</script>
</div>
</div>
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<template>
<v-hover v-model="hover" :disabled="!illustrationId">
<div
:aria-label="$t('pageTemplate.label.preview', {0: name})"
:aria-label="$t(`${objectType}.label.preview`, {0: name})"
class="position-relative full-height full-width d-flex align-center justify-center">
<v-expand-transition>
<v-card
v-if="hover"
:aria-label="$t('pageTemplate.label.openIllustrationPreview')"
:aria-label="$t(`${objectType}.label.openIllustrationPreview`)"
class="d-flex absolute-full-size z-index-one align-center justify-center transition-fast-in-fast-out grey opacity-5"
flat
@click="openIllustration">
Expand All @@ -43,31 +43,39 @@
<script>
export default {
props: {
pageTemplate: {
value: {
type: Object,
default: null,
},
objectType: {
type: String,
default: null,
},
defaultSrc: {
type: String,
default: null,
},
},
data: () => ({
hover: false,
}),
computed: {
pageTemplateId() {
return this.pageTemplate?.id;
id() {
return this.value?.id;
},
name() {
return this.$te(this.pageTemplate?.name) ? this.$t(this.pageTemplate?.name) : this.pageTemplate?.name;
return this.$te(this.value?.name) ? this.$t(this.value?.name) : this.value?.name;
},
illustrationId() {
return this.pageTemplate?.illustrationId;
return this.value?.illustrationId;
},
illustrationSrc() {
return this.illustrationId && `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/attachments/pageTemplate/${this.pageTemplateId}/${this.illustrationId}` || '/layout/images/page-templates/DefaultPreview.webp';
return this.illustrationId && `${eXo.env.portal.context}/${eXo.env.portal.rest}/v1/social/attachments/${this.objectType}/${this.id}/${this.illustrationId}` || this.defaultSrc;
},
},
methods: {
openIllustration() {
this.$root.$emit('page-templates-illustration-preview', this.illustrationSrc);
this.$root.$emit('layout-illustration-preview', this.illustrationSrc);
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
}
},
created() {
this.$root.$on('page-templates-illustration-preview', this.open);
this.$root.$on('layout-illustration-preview', this.open);
},
methods: {
open(illustrationSrc) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import Illustration from './components/Illustration.vue';
import IllustrationPreviewDialog from './components/IllustrationPreviewDialog.vue';

const components = {
'layout-image-illustration': Illustration,
'layout-image-illustration-preview': IllustrationPreviewDialog,
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import SiteNavigationExistingPageElement from './components/site-navigation/Site
import SiteNavigationPageSuggester from './components/site-navigation/SiteNavigationPageSuggester.vue';
import SiteNavigationSiteSuggester from './components/site-navigation/SiteNavigationSiteSuggester.vue';
import NodeIconPickerDrawer from './components/site-navigation/NodeIconPickerDrawer.vue';
import SectionMobileColumnMenu from './components/layout/SectionMobileColumnMenu.vue';

const components = {
'manage-permissions-drawer': ManagePermissionsDrawer,
Expand All @@ -56,7 +55,6 @@ const components = {
'site-navigation-page-suggester': SiteNavigationPageSuggester,
'site-navigation-site-suggester': SiteNavigationSiteSuggester,
'node-icon-picker-drawer': NodeIconPickerDrawer,
'layout-section-mobile-column-menu-drawer': SectionMobileColumnMenu,
};

for (const key in components) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import SectionMobileColumnMenu from './components/layout/SectionMobileColumnMenu.vue';

const components = {
'layout-section-mobile-column-menu-drawer': SectionMobileColumnMenu,
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

import PageTemplateDrawer from './components/PageTemplateDrawer.vue';
import PageTemplatePreview from './components/PageTemplatePreview.vue';

const components = {
'layout-editor-page-template-drawer': PageTemplateDrawer,
'layout-editor-page-template-preview': PageTemplatePreview,
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

const components = {
};

for (const key in components) {
Vue.component(key, components[key]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function updatePageTemplate(pageTemplate) {
body: JSON.stringify(pageTemplate),
}).then((resp) => {
if (!resp?.ok) {
throw new Error('Error when creating page template');
throw new Error('Error when updating page template');
}
});
}
Expand All @@ -84,7 +84,7 @@ export function deletePageTemplate(id) {
method: 'DELETE',
}).then((resp) => {
if (!resp?.ok) {
throw new Error('Error when creating page template');
throw new Error('Error when deleting page template');
}
});
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the Meeds project (https://meeds.io/).
*
* Copyright (C) 2020 - 2024 Meeds Association [email protected]
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/

export function getPortletInstances() {
return Promise.resolve();
}

export function getPortletInstance() {
return Promise.resolve();
}

export function createPortletInstance() {
return Promise.resolve();
}

export function updatePortletInstance() {
return Promise.resolve();
}

export function deletePortletInstance() {
return Promise.resolve();
}
Loading

0 comments on commit 9d35c81

Please sign in to comment.