Social: Allow post in friend wall

pull/4020/head^2
Angel Fernando Quiroz Campos 3 years ago
parent 33d7ac6ed1
commit fd48f5f483
  1. 3
      assets/vue/components/message/msgType.js
  2. 33
      assets/vue/components/socialnetwork/Form.vue
  3. 2
      assets/vue/views/socialnetwork/Home.vue

@ -9,3 +9,6 @@ export const MESSAGE_TYPE_WALL = 4;
export const MESSAGE_TYPE_GROUP = 5;
export const MESSAGE_TYPE_INVITATION = 6;
export const MESSAGE_TYPE_CONVERSATION = 7;
export const MESSAGE_REL_USER_TYPE_TO = 1;
export const MESSAGE_REL_USER_TYPE_CC = 2;

@ -7,7 +7,7 @@
<q-input
v-model="content"
:error="v$.content.$error"
:label="$t('What are you thinking about?')"
:label="textPlaceholder"
autogrow
/>
@ -37,24 +37,39 @@
</template>
<script>
import {reactive, toRefs} from "vue";
import {reactive, toRefs, watch} from "vue";
import {useStore} from "vuex";
import {MESSAGE_TYPE_WALL} from "../message/msgType";
import {MESSAGE_REL_USER_TYPE_TO, MESSAGE_TYPE_WALL} from "../message/msgType";
import useVuelidate from "@vuelidate/core";
import {required} from "@vuelidate/validators";
import {useI18n} from "vue-i18n";
export default {
name: "SocialNetworkForm",
setup() {
props: {
user: {
type: Object,
required: true
}
},
setup(props) {
const store = useStore();
const {t} = useI18n();
const currentUser = store.getters['security/getUser'];
const postState = reactive({
content: '',
attachment: null,
textPlaceholder: '',
});
function setTextPlaceholder(user) {
postState.textPlaceholder = currentUser['@id'] === user['@id']
? t('What are you thinking about?')
: t('Write something to {0}', [user.fullName]);
}
const v$ = useVuelidate({
content: {required},
}, postState);
@ -70,11 +85,11 @@ export default {
title: 'Post',
content: postState.content,
msgType: MESSAGE_TYPE_WALL,
sender: `/api/users/${currentUser.id}`,
sender: currentUser['@id'],
receivers: [
{
receiver: `/api/users/${currentUser.id}`,
receiverType: 1
receiver: props.user['@id'],
receiverType: MESSAGE_REL_USER_TYPE_TO
}
]
};
@ -95,6 +110,10 @@ export default {
postState.attachment = null;
}
watch(() => props.user, (current) => {setTextPlaceholder(current)});
setTextPlaceholder(props.user);
return {
...toRefs(postState),
sendPost,

@ -1,6 +1,6 @@
<template>
<div>
<SocialNetworkForm />
<SocialNetworkForm :user="user" />
<SocialNetworkPostList :user="user" />
</div>

Loading…
Cancel
Save