Invite to team modal
This commit is contained in:
parent
585138aeee
commit
998e2f81d2
@ -1559,6 +1559,7 @@ define([
|
|||||||
|
|
||||||
var module = config.module || common.makeUniversal('team');
|
var module = config.module || common.makeUniversal('team');
|
||||||
|
|
||||||
|
// Invite contacts
|
||||||
var $div;
|
var $div;
|
||||||
var refreshButton = function () {
|
var refreshButton = function () {
|
||||||
if (!$div) { return; }
|
if (!$div) { return; }
|
||||||
@ -1572,48 +1573,87 @@ define([
|
|||||||
$btn.prop('disabled', 'disabled');
|
$btn.prop('disabled', 'disabled');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var list = UIElements.getUserGrid(Messages.team_pickFriends, {
|
var getContacts = function () {
|
||||||
common: common,
|
var list = UIElements.getUserGrid(Messages.team_pickFriends, {
|
||||||
data: config.friends,
|
common: common,
|
||||||
large: true
|
data: config.friends,
|
||||||
}, refreshButton);
|
large: true
|
||||||
$div = $(list.div);
|
}, refreshButton);
|
||||||
refreshButton();
|
var div = h('div.contains-nav');
|
||||||
|
var $div = $(div);
|
||||||
|
$div.append(list.div);
|
||||||
|
var contactsButtons = [{
|
||||||
|
className: 'primary',
|
||||||
|
name: Messages.team_inviteModalButton,
|
||||||
|
onClick: function () {
|
||||||
|
var $sel = $div.find('.cp-usergrid-user.cp-selected');
|
||||||
|
var sel = $sel.toArray();
|
||||||
|
if (!sel.length) { return; }
|
||||||
|
|
||||||
var buttons = [{
|
sel.forEach(function (el) {
|
||||||
|
var curve = $(el).attr('data-curve');
|
||||||
|
module.execCommand('INVITE_TO_TEAM', {
|
||||||
|
teamId: config.teamId,
|
||||||
|
user: config.friends[curve]
|
||||||
|
}, function (obj) {
|
||||||
|
if (obj && obj.error) {
|
||||||
|
console.error(obj.error);
|
||||||
|
return UI.warn(Messages.error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
keys: [13]
|
||||||
|
}];
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: div,
|
||||||
|
buttons: contactsButtons
|
||||||
|
};
|
||||||
|
};
|
||||||
|
hasFriends = false;
|
||||||
|
var friendsObject = hasFriends ? getContacts() : noContactsMessage(common);
|
||||||
|
console.log(friendsObject);
|
||||||
|
var friendsList = friendsObject.content;
|
||||||
|
var contactsButtons = friendsObject.buttons;
|
||||||
|
contactsButtons.unshift({
|
||||||
className: 'cancel',
|
className: 'cancel',
|
||||||
name: Messages.cancel,
|
name: Messages.cancel,
|
||||||
onClick: function () {},
|
onClick: function () {},
|
||||||
keys: [27]
|
keys: [27]
|
||||||
}, {
|
});
|
||||||
className: 'primary',
|
|
||||||
name: Messages.team_inviteModalButton,
|
|
||||||
onClick: function () {
|
|
||||||
var $sel = $div.find('.cp-usergrid-user.cp-selected');
|
|
||||||
var sel = $sel.toArray();
|
|
||||||
if (!sel.length) { return; }
|
|
||||||
|
|
||||||
sel.forEach(function (el) {
|
var contactsContent = h('div.cp-share-modal', [
|
||||||
var curve = $(el).attr('data-curve');
|
friendsList
|
||||||
module.execCommand('INVITE_TO_TEAM', {
|
|
||||||
teamId: config.teamId,
|
|
||||||
user: config.friends[curve]
|
|
||||||
}, function (obj) {
|
|
||||||
if (obj && obj.error) {
|
|
||||||
console.error(obj.error);
|
|
||||||
return UI.warn(Messages.error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
},
|
|
||||||
keys: [13]
|
|
||||||
}];
|
|
||||||
|
|
||||||
var content = h('div', [
|
|
||||||
list.div
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var modal = UI.dialog.customModal(content, {buttons: buttons});
|
var frameContacts = UI.dialog.customModal(contactsContent, {
|
||||||
|
buttons: contactsButtons,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Invite from link
|
||||||
|
var linkContent = h('div.cp-share-modal', [
|
||||||
|
]);
|
||||||
|
var linkButtons = [];
|
||||||
|
|
||||||
|
var frameLink = UI.dialog.customModal(linkContent, {
|
||||||
|
buttons: linkButtons,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create modal
|
||||||
|
var tabs = [{
|
||||||
|
title: Messages.share_contactCategory,
|
||||||
|
icon: "fa fa-address-book",
|
||||||
|
content: frameContacts,
|
||||||
|
active: hasFriends
|
||||||
|
}, {
|
||||||
|
title: Messages.share_linkCategory,
|
||||||
|
icon: "fa fa-link",
|
||||||
|
content: frameLink,
|
||||||
|
active: !hasFriends
|
||||||
|
}];
|
||||||
|
|
||||||
|
var modal = UI.dialog.tabs(tabs);
|
||||||
UI.openCustomModal(modal);
|
UI.openCustomModal(modal);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user