2 * Adds participants to an existing conversation.
4 * @author Alexander Ebert
5 * @copyright 2001-2016 WoltLab GmbH
6 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
7 * @module WoltLab/Conversation/Ui/Participant/Add
9 define(['Ajax', 'Language', 'Ui/Dialog', 'Ui/Notification', 'WoltLab/WCF/Ui/ItemList/User'], function(Ajax
, Language
, UiDialog
, UiNotification
, UiItemListUser
) {
14 * @param {int} conversationId conversation id
16 function UiParticipantAdd(conversationId
) { this.init(conversationId
); }
17 UiParticipantAdd
.prototype = {
19 * Manages the form to add one or more participants to an existing conversation.
21 * @param {int} conversationId conversation id
23 init: function(conversationId
) {
24 this._conversationId
= conversationId
;
27 actionName
: 'getAddParticipantsForm'
31 _ajaxSetup: function() {
34 className
: 'wcf\\data\\conversation\\ConversationAction',
35 objectIDs
: [ this._conversationId
]
41 * Handles successful Ajax requests.
43 * @param {Object} data response data
45 _ajaxSuccess: function(data
) {
46 switch (data
.actionName
) {
47 case 'addParticipants':
48 this._handleResponse(data
);
51 case 'getAddParticipantsForm':
58 * Shows the success message and closes the dialog overlay.
60 * @param {Object} data response data
62 _handleResponse: function(data
) {
63 //noinspection JSUnresolvedVariable
64 if (data
.returnValues
.count
) {
65 //noinspection JSUnresolvedVariable
66 UiNotification
.show(data
.returnValues
.successMessage
);
73 * Renders the dialog to add participants.
75 * @param {object} data response data
77 _render: function(data
) {
78 //noinspection JSUnresolvedVariable
79 UiDialog
.open(this, data
.returnValues
.template
);
81 var buttonSubmit
= document
.getElementById('addParticipants');
82 buttonSubmit
.disabled
= true;
84 //noinspection JSUnresolvedVariable
85 UiItemListUser
.init('participantsInput', {
86 callbackChange: function(elementId
, values
) { buttonSubmit
.disabled
= (values
.length
=== 0); },
87 excludedSearchValues
: data
.returnValues
.excludedSearchValues
,
88 maxItems
: data
.returnValues
.maxItems
91 buttonSubmit
.addEventListener('click', this._submit
.bind(this));
95 * Sends a request to add participants.
98 var values
= UiItemListUser
.getValues('participantsInput'), participants
= [];
99 for (var i
= 0, length
= values
.length
; i
< length
; i
++) {
100 participants
.push(values
[i
].value
);
104 actionName
: 'addParticipants',
106 participants
: participants
111 _dialogSetup: function() {
113 id
: 'conversationAddParticipants',
115 title
: Language
.get('wcf.conversation.edit.addParticipants')
122 return UiParticipantAdd
;