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

Merge Attach images - Meeds-io/MIPs#53 #380

Merged
merged 2 commits into from
Oct 4, 2023
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 @@ -2,6 +2,8 @@

import static org.exoplatform.kudos.service.utils.Utils.KUDOS_ACTIVITY_COMMENT_TYPE;

import org.apache.commons.lang.StringUtils;

import org.exoplatform.commons.exception.ObjectNotFoundException;
import org.exoplatform.kudos.model.Kudos;
import org.exoplatform.kudos.service.KudosService;
Expand Down Expand Up @@ -39,7 +41,7 @@ public void saveActivity(ActivityLifeCycleEvent activityLifeCycleEvent) {
@Override
public void updateActivity(ActivityLifeCycleEvent activityLifeCycleEvent) {
ExoSocialActivity activity = activityLifeCycleEvent.getSource();
if (activity.getType().equals(KUDOS_ACTIVITY_COMMENT_TYPE)) {
if (activity != null && StringUtils.equals(activity.getType(), KUDOS_ACTIVITY_COMMENT_TYPE)) {
long activityId = org.exoplatform.kudos.service.utils.Utils.getActivityId(activity.getId());
Kudos kudos = kudosService.getKudosByActivityId(activityId);
if (kudos != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public Kudos createKudos(Kudos kudos, String currentUser) throws Exception {

listenerService.broadcast(KUDOS_SENT_EVENT, this, createdKudos);

return createdKudos;
return kudosStorage.getKudoById(createdKudos.getTechnicalId());
}

/**
Expand Down
3 changes: 3 additions & 0 deletions kudos-webapps/src/main/webapp/WEB-INF/gatein-resources.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
<depends>
<module>extensionRegistry</module>
</depends>
<depends>
<module>attachImage</module>
</depends>
</module>

<module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<exo-drawer
ref="activityKudosDrawer"
v-draggable="enabled"
width="500px"
hide-actions
id="activityKudosDrawer"
Expand Down Expand Up @@ -177,11 +178,15 @@
:key="spaceURL"
v-model="kudosMessage"
:max-length="MESSAGE_MAX_LENGTH"
:ck-editor-type="ckEditorId"
:ck-editor-type="ckEditorType"
:ck-editor-id="ckEditorId"
:placeholder="$t('exoplatform.kudos.label.kudosMessagePlaceholder')"
:suggestor-type-of-relation="typeOfRelation"
:suggester-space-u-r-l="spaceURL"
class="flex" />
:object-id="metadataObjectId"
:object-type="objectType"
class="flex"
autofocus />
</div>
<div v-if="kudosMessageValidityLabel" class="d-flex flex-row pt-3">
<span class="text-sm-caption error--text">
Expand Down Expand Up @@ -246,6 +251,7 @@ export default {
entityOwner: '',
receiverType: null,
receiverId: null,
metadataObjectId: null,
error: null,
drawer: false,
MESSAGE_MAX_LENGTH: 1300,
Expand All @@ -262,6 +268,7 @@ export default {
selectedReceiver: null,
spaceURL: null,
audience: '',
objectType: 'activity',
readOnlySpace: false,
username: eXo.env.portal.userName,
spaceId: eXo.env.portal.spaceId,
Expand Down Expand Up @@ -388,6 +395,12 @@ export default {
typeOfRelation() {
return this.isLinkedKudos ? 'mention_comment' : 'mention_activity_stream';
},
ckEditorType() {
return this.isLinkedKudos ? 'activityComment' : 'activityContent';
},
enabled() {
return eXo.env.portal.editorAttachImageEnabled && eXo.env.portal.attachmentObjectTypes?.indexOf(this.objectType) >= 0;
},
postInYourSpacesChoice() {
return this.audienceChoice === 'oneOfYourSpaces';
},
Expand Down Expand Up @@ -434,7 +447,7 @@ export default {
resetEditor() {
this.$refs[this.ckEditorId].destroyCKEditor();
},
initDrawer () {
initDrawer() {
this.kudosMessage = '';
this.kudosToSend = null;
this.error = null;
Expand Down Expand Up @@ -533,18 +546,20 @@ export default {
this.readOnlySpace = event?.detail?.readOnlySpace;
this.entityType = event && event.detail && event.detail.type;
this.entityId = event && event.detail && event.detail.id;
this.metadataObjectId = null;
this.entityOwner = event && event.detail && event.detail.owner;
this.parentEntityId = event && event.detail && event.detail.parentId;
this.ignoreRefresh = event && event.detail && event.detail.ignoreRefresh;
this.spaceURL = event && event.detail && event.detail.spaceURL || null;
this.$refs.activityKudosDrawer.open();
this.$refs.activityKudosDrawer.startLoading();
this.initDrawer().then(() => {
this.$refs[this.ckEditorId].initCKEditor();
}).finally( () => {
this.loading = false;
this.$refs.activityKudosDrawer.endLoading();
});
this.initDrawer()
.then(() => this.$nextTick())
.then(() => this.$refs[this.ckEditorId].initCKEditor())
.finally( () => {
this.loading = false;
this.$refs.activityKudosDrawer.endLoading();
});
});
}
else {
Expand Down Expand Up @@ -573,7 +588,12 @@ export default {
if (!kudosSent) {
throw new Error(this.$t('exoplatform.kudos.error.errorSendingKudos'));
}
this.metadataObjectId = this.isLinkedKudos && `comment${kudosSent.activityId}` || `${kudosSent.activityId}`;
document.dispatchEvent(new CustomEvent('exo-kudos-sent', {detail: kudosSent}));
return this.$nextTick();
})
.then(() => this.$refs[this.ckEditorId].saveAttachments())
.then(() => {
return this.init()
.catch(e => {
console.error('Error refreshing allowed number of kudos for current user', e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
<v-icon
:class="kudosColorClass"
class="baseline-vertical-align"
size="14">
:size="isMobile && '20' || '14'">
fa-award
</v-icon>
<span class="mx-auto mt-1 mt-lg-0 ms-lg-2">
<span v-if="!isMobile" class="mx-auto mt-1 mt-lg-0 ms-lg-2">
{{ $t('exoplatform.kudos.label.kudos') }}
</span>
</div>
Expand Down