Skip to content

Commit

Permalink
feat: Add Attach images integration to Kudos - MEED-2034 - Meeds-io/M…
Browse files Browse the repository at this point in the history
…IPs#53 (#313)

This change will allow to attach images to kudos activity and comment.
  • Loading branch information
boubaker committed Aug 21, 2023
1 parent ec34abf commit 40d3a38
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
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
34 changes: 24 additions & 10 deletions kudos-webapps/src/main/webapp/vue-app/kudos/components/KudosApp.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,18 @@
<span class="text-header-title">{{ $t('exoplatform.kudos.title.message') }} </span>
</div>
<div class="d-flex flex-row pt-3">
<exo-activity-rich-editor
<rich-editor
:ref="ckEditorId"
: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"
:object-id="metadataObjectId"
object-type="activity"
class="flex"
autofocus />
</div>
Expand Down Expand Up @@ -147,6 +150,7 @@ export default {
entityOwner: '',
receiverType: null,
receiverId: null,
metadataObjectId: null,
error: null,
drawer: false,
MESSAGE_MAX_LENGTH: 1300,
Expand Down Expand Up @@ -275,7 +279,10 @@ export default {
},
typeOfRelation() {
return this.isLinkedKudos ? 'mention_comment' : 'mention_activity_stream';
}
},
ckEditorType() {
return this.isLinkedKudos ? 'activityComment' : 'activityContent';
},
},
methods: {
init() {
Expand Down Expand Up @@ -304,7 +311,7 @@ export default {
resetEditor() {
this.$refs[this.ckEditorId].destroyCKEditor();
},
initDrawer () {
initDrawer() {
this.kudosMessage = '';
this.kudosToSend = null;
this.error = null;
Expand Down Expand Up @@ -401,18 +408,20 @@ export default {
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 @@ -441,7 +450,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

0 comments on commit 40d3a38

Please sign in to comment.