Skip to content

Commit

Permalink
Merge Space Public Site - Meeds-io/MIPs#151 (#1746)
Browse files Browse the repository at this point in the history
  • Loading branch information
boubaker authored Oct 7, 2024
2 parents 1419f49 + 5259dc0 commit 41a796b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 99 deletions.
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/WEB-INF/jsp/badgesOverview.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@page import="org.exoplatform.services.security.ConversationState"%>
<%
/**
* This file is part of the Meeds project (https://meeds.io/).
Expand Down Expand Up @@ -35,7 +36,7 @@
String showName = request.getAttribute("showName") == null ? "false" : ((String[]) request.getAttribute("showName"))[0];
String sortBy = request.getAttribute("badgesSortBy") == null ? "" : ((String[]) request.getAttribute("badgesSortBy"))[0];
Page currentPage = PortalRequestContext.getCurrentInstance().getPage();
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage);
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage, ConversationState.getCurrent().getIdentity());
String pageRef = currentPage.getPageKey().format();
%>
<div class="VuetifyApp">
Expand Down
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/WEB-INF/jsp/myContributions.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@page import="org.exoplatform.services.security.ConversationState"%>
<%
/**
* This file is part of the Meeds project (https://meeds.io/).
Expand Down Expand Up @@ -29,7 +30,7 @@
String myContributionsProgramLimit = request.getAttribute("myContributionsProgramLimit") == null ? "5" : ((String[]) request.getAttribute("myContributionsProgramLimit"))[0];
String myContributionsDisplayLegend = request.getAttribute("myContributionsDisplayLegend") == null ? "true" : ((String[]) request.getAttribute("myContributionsDisplayLegend"))[0];
Page currentPage = PortalRequestContext.getCurrentInstance().getPage();
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage);
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage, ConversationState.getCurrent().getIdentity());
String pageRef = currentPage.getPageKey().format();
%>
<div class="VuetifyApp">
Expand Down
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/WEB-INF/jsp/programsOverview.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@page import="org.exoplatform.services.security.ConversationState"%>
<%@ page import="io.meeds.gamification.utils.Utils"%>
<%@ page import="org.exoplatform.portal.config.model.Page"%>
<%@ page import="org.exoplatform.portal.application.PortalRequestContext"%>
Expand All @@ -11,7 +12,7 @@
String limit = request.getAttribute("limit") == null ? "4" : ((String[]) request.getAttribute("limit"))[0];
String sortBy = request.getAttribute("programsSortBy") == null ? "" : ((String[]) request.getAttribute("programsSortBy"))[0];
Page currentPage = PortalRequestContext.getCurrentInstance().getPage();
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage);
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage, ConversationState.getCurrent().getIdentity());
String pageRef = currentPage.getPageKey().format();
%>
<script type="text/javascript">
Expand Down
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/WEB-INF/jsp/rulesOverview.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@page import="org.exoplatform.services.security.ConversationState"%>
<%
/**
* This file is part of the Meeds project (https://meeds.io/).
Expand Down Expand Up @@ -34,7 +35,7 @@
String availableRulesLimit = request.getAttribute("availableRulesLimit") == null ? "4" : ((String[]) request.getAttribute("availableRulesLimit"))[0];
String upcomingRulesLimit = request.getAttribute("upcomingRulesLimit") == null ? "2" : ((String[]) request.getAttribute("upcomingRulesLimit"))[0];
Page currentPage = PortalRequestContext.getCurrentInstance().getPage();
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage);
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage, ConversationState.getCurrent().getIdentity());
String pageRef = currentPage.getPageKey().format();
%>
<script type="text/javascript">
Expand Down
3 changes: 2 additions & 1 deletion portlets/src/main/webapp/WEB-INF/jsp/topChallengers.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<%@page import="org.exoplatform.services.security.ConversationState"%>
<%
/**
* This file is part of the Meeds project (https://meeds.io/).
Expand Down Expand Up @@ -31,7 +32,7 @@
String topChallengersPeriod = request.getAttribute("topChallengersPeriod") == null ? "week" : ((String[]) request.getAttribute("topChallengersPeriod"))[0];
String topChallengersCurrentPosition = request.getAttribute("topChallengersCurrentPosition") == null ? "false" : ((String[]) request.getAttribute("topChallengersCurrentPosition"))[0];
Page currentPage = PortalRequestContext.getCurrentInstance().getPage();
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage);
boolean canEdit = ExoContainerContext.getService(UserACL.class).hasEditPermission(currentPage, ConversationState.getCurrent().getIdentity());
String pageRef = currentPage.getPageKey().format();
%>
<script type="text/javascript">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export default {
originalLimitToFetch: 0,
term: '',
spacesURL: `${eXo.env.portal.context}/${eXo.env.portal.metaPortalName}/spaces/`,
isExternal: eXo.env.portal.isExternal === 'true',
isExternal: eXo.env.portal.isExternal === true,
};
},
computed: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,14 @@
</div>
</v-card>
<gamification-rules-overview-widget
:rules="rules"
:page-size="rulesLimit"
:loading="loading > 0"
v-if="drawer"
:program-id="programId"
class="mb-4 mx-1"
hide-empty-placeholder
go-back-button
class="mb-4 mx-1">
load-size
@rules-size="rulesSize = $event"
@has-more="hasMore = $event">
<template #title>
<div class="text-header text-truncate">
{{ $t('programs.label.programActions') }}
Expand All @@ -130,7 +132,7 @@
</template>
</gamification-rules-overview-widget>
<gamification-rules-overview-list-drawer
v-if="rules.length"
v-if="hasMore"
ref="listDrawer"
:program-id="programId" />
</template>
Expand All @@ -148,12 +150,8 @@ export default {
data: () => ({
drawer: false,
program: null,
loading: 0,
goBackButton: false,
rulesLimit: 10,
upcomingRules: [],
activeRules: [],
endingRules: [],
hasMore: false,
rulesSize: 0,
}),
computed: {
Expand Down Expand Up @@ -192,102 +190,24 @@ export default {
ownersCount() {
return this.owners?.length;
},
rules() {
return [...this.upcomingRules, ...this.endingRules, ...this.activeRules]
.filter((v, i, array) => array.findIndex(v2 => v?.id === v2?.id) === i);
},
hasMore() {
return this.rulesSize > this.rules.length;
},
},
watch: {
loading() {
if (this.loading) {
this.$refs.drawer.startLoading();
} else {
this.$refs.drawer.endLoading();
}
},
},
created() {
this.$root.$on('program-detail-drawer', this.open);
this.$root.$on('announcement-added', this.retrieveRules);
this.$root.$on('rule-updated', this.retrieveRules);
this.$root.$on('rule-deleted', this.retrieveRules);
},
methods: {
open(program, goBackButton) {
this.program = program;
this.goBackButton = goBackButton || false;
this.rules = [];
this.hasMore = false;
this.rulesSize = 0;
this.$refs.drawer.open();
this.$nextTick()
.then(() => {
this.$nextTick().then(() => this.retrieveRules());
this.collectProgramVisit();
});
.then(() => this.collectProgramVisit());
},
close() {
this.$refs.drawer.close();
this.$nextTick().then(() => this.program = null);
},
retrieveRules() {
if (!this.drawer) {
return;
}
this.loading = 3;
this.retrieveEndingRules().finally(() => this.loading--);
this.retrieveActiveRules().finally(() => this.loading--);
this.retrieveUpcomingRules().finally(() => this.loading--);
},
retrieveEndingRules() {
return this.$ruleService.getRules({
status: 'ENABLED',
programId: this.programId,
programStatus: 'ENABLED',
dateFilter: 'STARTED_WITH_END',
offset: 0,
limit: 2,
sortBy: 'endDate',
sortDescending: false,
expand: 'countRealizations',
lang: eXo.env.portal.language,
returnSize: false,
}).then(result => this.endingRules = result?.rules || []);
},
retrieveActiveRules() {
return this.$ruleService.getRules({
status: 'ENABLED',
programId: this.programId,
programStatus: 'ENABLED',
dateFilter: 'STARTED',
offset: 0,
limit: this.rulesLimit,
sortBy: 'createdDate',
sortDescending: true,
expand: 'countRealizations,expandPrerequisites',
lang: eXo.env.portal.language,
returnSize: true,
}).then(result => {
this.activeRules = result?.rules || [];
this.rulesSize = result?.size || 0;
});
},
retrieveUpcomingRules() {
return this.$ruleService.getRules({
status: 'ENABLED',
programId: this.programId,
programStatus: 'ENABLED',
dateFilter: 'UPCOMING',
offset: 0,
limit: 2,
sortBy: 'startDate',
sortDescending: false,
expand: 'countRealizations',
lang: eXo.env.portal.language,
returnSize: false,
}).then(result => this.upcomingRules = result?.rules || []);
},
collectProgramVisit() {
if (this.programId) {
document.dispatchEvent(new CustomEvent('exo-statistic-message', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@
<script>
export default {
props: {
programId: {
type: String,
default: null,
},
hideEmptyPlaceholder: {
type: Boolean,
default: false,
Expand All @@ -158,6 +162,10 @@ export default {
type: Boolean,
default: false,
},
loadSize: {
type: Boolean,
default: false,
},
},
data: () => ({
actionsPageURL: `${eXo.env.portal.context}/${eXo.env.portal.engagementSiteName}/contributions/actions`,
Expand Down Expand Up @@ -385,6 +393,7 @@ export default {
programStatus: 'ENABLED',
dateFilter: 'STARTED_WITH_END',
spaceId: this.spaceId?.length && [this.spaceId] || null,
programId: this.programId,
offset: 0,
limit: this.endingRulesLimit,
sortBy: 'endDate',
Expand All @@ -396,17 +405,22 @@ export default {
|| Promise.resolve();
},
retrieveActiveRulesSize() {
return this.spaceId?.length
return (this.spaceId?.length || this.loadSize)
&& this.$ruleService.getRules({
status: 'ENABLED',
programStatus: 'ENABLED',
dateFilter: 'STARTED',
spaceId: this.spaceId?.length && [this.spaceId] || null,
programId: this.programId,
offset: 0,
limit: 1,
lang: eXo.env.portal.language,
returnSize: true,
}).then(result => this.activeRulesSize = result?.size || 0)
}).then(result => {
this.activeRulesSize = result?.size || 0;
this.$emit('rules-size', this.activeRulesSize);
this.$emit('has-more', this.activeRulesSize > this.availableRulesLimit);
})
|| Promise.resolve();
},
retrieveActiveRules() {
Expand All @@ -416,6 +430,7 @@ export default {
programStatus: 'ENABLED',
dateFilter: this.spaceId?.length && 'ACTIVE' || 'STARTED',
spaceId: this.spaceId?.length && [this.spaceId] || null,
programId: this.programId,
offset: 0,
limit: this.activeRulesLimit,
sortBy: this.sortBy,
Expand All @@ -433,6 +448,7 @@ export default {
programStatus: 'ENABLED',
dateFilter: 'UPCOMING',
spaceId: this.spaceId?.length && [this.spaceId] || null,
programId: this.programId,
offset: 0,
limit: this.upcomingRulesLimit,
sortBy: 'startDate',
Expand Down

0 comments on commit 41a796b

Please sign in to comment.