|
26 | 26 | <!-- Editor --> |
27 | 27 | <Comment v-bind="editorData" |
28 | 28 | :auto-complete="autoComplete" |
| 29 | + :user-data="userData" |
29 | 30 | :editor="true" |
30 | 31 | :ressource-id="ressourceId" |
31 | 32 | class="comments__writer" |
@@ -91,9 +92,9 @@ import RefreshIcon from 'vue-material-design-icons/Refresh' |
91 | 92 | import MessageReplyTextIcon from 'vue-material-design-icons/MessageReplyText' |
92 | 93 | import AlertCircleOutlineIcon from 'vue-material-design-icons/AlertCircleOutline' |
93 | 94 |
|
94 | | -import Comment from '../components/Comment' |
95 | | -import getComments, { DEFAULT_LIMIT } from '../services/GetComments' |
96 | | -import cancelableRequest from '../utils/cancelableRequest' |
| 95 | +import Comment from '../components/Comment.vue' |
| 96 | +import getComments, { DEFAULT_LIMIT } from '../services/GetComments.js' |
| 97 | +import cancelableRequest from '../utils/cancelableRequest.js' |
97 | 98 |
|
98 | 99 | Vue.use(VTooltip) |
99 | 100 |
|
@@ -129,6 +130,7 @@ export default { |
129 | 130 | }, |
130 | 131 |
|
131 | 132 | Comment, |
| 133 | + userData: {}, |
132 | 134 | } |
133 | 135 | }, |
134 | 136 |
|
@@ -173,21 +175,22 @@ export default { |
173 | 175 | * Make sure we have all mentions as Array of objects |
174 | 176 | * |
175 | 177 | * @param {Array} mentions the mentions list |
176 | | - * @return {object[]} |
| 178 | + * @return {Object<string, object>} |
177 | 179 | */ |
178 | 180 | genMentionsData(mentions) { |
179 | | - const list = Object.values(mentions).flat() |
180 | | - return list.reduce((mentions, mention) => { |
181 | | - mentions[mention.mentionId] = { |
182 | | - // TODO: support groups |
183 | | - icon: 'icon-user', |
184 | | - id: mention.mentionId, |
185 | | - label: mention.mentionDisplayName, |
186 | | - source: 'users', |
187 | | - primary: getCurrentUser().uid === mention.mentionId, |
188 | | - } |
189 | | - return mentions |
190 | | - }, {}) |
| 181 | + Object.values(mentions) |
| 182 | + .flat() |
| 183 | + .forEach(mention => { |
| 184 | + this.userData[mention.mentionId] = { |
| 185 | + // TODO: support groups |
| 186 | + icon: 'icon-user', |
| 187 | + id: mention.mentionId, |
| 188 | + label: mention.mentionDisplayName, |
| 189 | + source: 'users', |
| 190 | + primary: getCurrentUser().uid === mention.mentionId, |
| 191 | + } |
| 192 | + }) |
| 193 | + return this.userData |
191 | 194 | }, |
192 | 195 |
|
193 | 196 | /** |
@@ -251,7 +254,9 @@ export default { |
251 | 254 | limit: loadState('comments', 'maxAutoCompleteResults'), |
252 | 255 | }, |
253 | 256 | }) |
254 | | - return callback(results.data.ocs.data) |
| 257 | + // Save user data so it can be used by the editor to replace mentions |
| 258 | + results.data.ocs.data.forEach(user => { this.userData[user.id] = user }) |
| 259 | + return callback(Object.values(this.userData)) |
255 | 260 | }, |
256 | 261 |
|
257 | 262 | /** |
|
0 commit comments