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

How to send user_id on mention #120

Open
gamenic-sandip opened this issue May 4, 2020 · 6 comments
Open

How to send user_id on mention #120

gamenic-sandip opened this issue May 4, 2020 · 6 comments
Labels

Comments

@gamenic-sandip
Copy link

Hello @4ver @goldsteinr
Screen Shot 2020-04-27 at 9 45 14 AM
Here i have list of user on mention and when i select user its sending user_name
I want to send user_id also

For example
If i have two user with same name
User1
User1
and when i send message in my backend i receive two users with same and and its difficult to found which user_id which

Screen Shot 2020-04-27 at 9 45 30 AM
So i want to pass here user_id also but not showing here
Here user_name -> OK

Here :-
name-key="displayName" -> Name display on tag option
-> Name send to backend

I want to send user_id to backend without affecting above two

@fritx fritx added the question label May 6, 2020
@fritx
Copy link
Owner

fritx commented May 6, 2020

@gamenic-sandip If you are using textarea, it can be hard to achieve.
And if you are using contenteditable, you can use customized tags like

<!-- with Vue 2.6+ 'v-slot' directive -->
<!-- note at least two '<span>' wrapper are required to work -->
<template v-slot:embeddedItem="s">
  <span><span class="tag"><img class="avatar" :src="s.current.avatar">{{ s.current.name }}</span></span>
</template>

and put a data-user-id onto the <span>,
and try to

let mentionedUserIds = []
editor.querySelectorAll('[data-user-id]').forEach(el => {
  mentionedUserIds.push(el.getAttribute('data-user-id'))
})

when sending messages

@gamenic-sandip
Copy link
Author

Thanks for you reply @fritx
Let me try to change text-are to editor

@zhonghao23
Copy link

may i know what do you mean by putting data-user-id onto span? @fritx

@fritx
Copy link
Owner

fritx commented May 15, 2020

@zhonghao23 there are two <span> below.

<template v-slot:embeddedItem="s">
  <span><span class="tag"><img class="avatar" :src="s.current.avatar">{{ s.current.name }}</span></span>
</template>

We can choose either one of them to be <span :data-user-id="s.userId">

@zhonghao23
Copy link

zhonghao23 commented May 15, 2020

thank you for your quick reply @fritx
let mentionedUserIds = []
editor.querySelectorAll('[data-user-id]').forEach(el => {
mentionedUserIds.push(el.getAttribute('data-user-id'))
})
May i know is the editor the class of div contenteditable?

@jggj21
Copy link

jggj21 commented Aug 3, 2021

Thank you very much for the help.

I am using Element UI's textarea and basically I want to obtain only the members that have been selected and thus be able to send them to my backend, I am using v-model in the component but I do not get the expected result.

It is similar to this problem but in my case I am using textarea

<at-ta
     :hoverSelect="true"
     :members="members"
     v-model="usersMentioned"
     name-key="name"
  >
     <template slot="item" slot-scope="s">
        <span v-text="s.item.name"></span>
      </template>

       <el-input
          type="textarea"
          placeholder="Add to Conversation"
          v-model="replyData.message"
         ></el-input>
</at-ta>

reply(){
 console.log(this.usersMentioned) //Show only those mentioned, the array of selected objects.
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants