|
|
@ -6,6 +6,7 @@ define([
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/common/common-interface.js',
|
|
|
|
'/common/common-ui-elements.js',
|
|
|
|
'/common/common-ui-elements.js',
|
|
|
|
'/common/common-feedback.js',
|
|
|
|
'/common/common-feedback.js',
|
|
|
|
|
|
|
|
'/common/common-constants.js',
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
'/bower_components/nthen/index.js',
|
|
|
|
'/common/sframe-common.js',
|
|
|
|
'/common/sframe-common.js',
|
|
|
|
'/common/proxy-manager.js',
|
|
|
|
'/common/proxy-manager.js',
|
|
|
@ -25,6 +26,7 @@ define([
|
|
|
|
UI,
|
|
|
|
UI,
|
|
|
|
UIElements,
|
|
|
|
UIElements,
|
|
|
|
Feedback,
|
|
|
|
Feedback,
|
|
|
|
|
|
|
|
Constants,
|
|
|
|
nThen,
|
|
|
|
nThen,
|
|
|
|
SFCommon,
|
|
|
|
SFCommon,
|
|
|
|
ProxyManager,
|
|
|
|
ProxyManager,
|
|
|
@ -177,6 +179,8 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (active === 'drive') {
|
|
|
|
if (active === 'drive') {
|
|
|
|
APP.$rightside.addClass('cp-rightside-drive');
|
|
|
|
APP.$rightside.addClass('cp-rightside-drive');
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
APP.$rightside.removeClass('cp-rightside-drive');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
showCategories(categories[active]);
|
|
|
|
showCategories(categories[active]);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -264,25 +268,44 @@ define([
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var MAX_TEAMS_SLOTS = Constants.MAX_TEAMS_SLOTS;
|
|
|
|
var refreshList = function (common, cb) {
|
|
|
|
var refreshList = function (common, cb) {
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
var content = [];
|
|
|
|
var content = [];
|
|
|
|
content.push(h('h3', 'Your teams'));
|
|
|
|
|
|
|
|
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
|
|
|
|
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
|
|
|
|
if (!obj) { return; }
|
|
|
|
if (!obj) { return; }
|
|
|
|
if (obj.error) { return void console.error(obj.error); }
|
|
|
|
if (obj.error) { return void console.error(obj.error); }
|
|
|
|
var lis = [];
|
|
|
|
var list = [];
|
|
|
|
Object.keys(obj).forEach(function (id) {
|
|
|
|
var keys = Object.keys(obj).slice(0,3);
|
|
|
|
|
|
|
|
var slots = '('+Math.min(keys.length, MAX_TEAMS_SLOTS)+'/'+MAX_TEAMS_SLOTS+')';
|
|
|
|
|
|
|
|
for (var i = keys.length; i < MAX_TEAMS_SLOTS; i++) {
|
|
|
|
|
|
|
|
obj[i] = {
|
|
|
|
|
|
|
|
empty: true
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
keys.push(i);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
content.push(h('h3', Messages.team_listTitle + ' ' + slots));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
keys.forEach(function (id) {
|
|
|
|
var team = obj[id];
|
|
|
|
var team = obj[id];
|
|
|
|
var a = h('a', Messages.team_listLoad);
|
|
|
|
if (team.empty) {
|
|
|
|
var avatar = h('span.cp-avatar.cp-team-list-avatar');
|
|
|
|
list.push(h('div.cp-team-list-team.empty', [
|
|
|
|
lis.push(h('li', h('ul', [ // XXX UI
|
|
|
|
h('span.cp-team-list-name.empty', Messages.team_listSlot)
|
|
|
|
h('li', avatar),
|
|
|
|
]));
|
|
|
|
h('li', team.metadata.name),
|
|
|
|
return;
|
|
|
|
h('li', a)
|
|
|
|
}
|
|
|
|
])));
|
|
|
|
var btn;
|
|
|
|
|
|
|
|
var avatar = h('span.cp-avatar');
|
|
|
|
|
|
|
|
list.push(h('div.cp-team-list-team', [
|
|
|
|
|
|
|
|
h('span.cp-team-list-avatar', avatar),
|
|
|
|
|
|
|
|
h('span.cp-team-list-name', {
|
|
|
|
|
|
|
|
title: team.metadata.name
|
|
|
|
|
|
|
|
}, team.metadata.name),
|
|
|
|
|
|
|
|
btn = h('button.cp-team-list-open.btn.btn-primary', Messages.team_listLoad)
|
|
|
|
|
|
|
|
]));
|
|
|
|
common.displayAvatar($(avatar), team.metadata.avatar, team.metadata.name);
|
|
|
|
common.displayAvatar($(avatar), team.metadata.avatar, team.metadata.name);
|
|
|
|
$(a).click(function () {
|
|
|
|
$(btn).click(function () {
|
|
|
|
APP.module.execCommand('SUBSCRIBE', id, function () {
|
|
|
|
APP.module.execCommand('SUBSCRIBE', id, function () {
|
|
|
|
sframeChan.query('Q_SET_TEAM', id, function (err) {
|
|
|
|
sframeChan.query('Q_SET_TEAM', id, function (err) {
|
|
|
|
if (err) { return void console.error(err); }
|
|
|
|
if (err) { return void console.error(err); }
|
|
|
@ -293,7 +316,7 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
content.push(h('ul', lis));
|
|
|
|
content.push(h('div.cp-team-list-container', list));
|
|
|
|
cb(content);
|
|
|
|
cb(content);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
return content;
|
|
|
|
return content;
|
|
|
@ -303,7 +326,20 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
makeBlock('create', function (common, cb) {
|
|
|
|
makeBlock('create', function (common, cb) {
|
|
|
|
|
|
|
|
var metadataMgr = common.getMetadataMgr();
|
|
|
|
|
|
|
|
var privateData = metadataMgr.getPrivateData();
|
|
|
|
var content = [];
|
|
|
|
var content = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var isOwner = Object.keys(privateData.teams || {}).some(function (id) {
|
|
|
|
|
|
|
|
return privateData.teams[id].owner;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
if (Object.keys(privateData.teams || {}).length >= 3 || isOwner) {
|
|
|
|
|
|
|
|
content.push(h('div.alert.alert-warning', {
|
|
|
|
|
|
|
|
role:'alert'
|
|
|
|
|
|
|
|
}, isOwner ? Messages.team_maxOwner : Messages._getKey('team_maxTeams', [MAX_TEAMS_SLOTS])));
|
|
|
|
|
|
|
|
return void cb(content);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
content.push(h('h3', Messages.team_createLabel));
|
|
|
|
content.push(h('h3', Messages.team_createLabel));
|
|
|
|
content.push(h('label', Messages.team_createName));
|
|
|
|
content.push(h('label', Messages.team_createName));
|
|
|
|
var input = h('input', {type:'text'});
|
|
|
|
var input = h('input', {type:'text'});
|
|
|
@ -393,6 +429,8 @@ define([
|
|
|
|
common.displayAvatar($(avatar), data.avatar, data.displayName);
|
|
|
|
common.displayAvatar($(avatar), data.avatar, data.displayName);
|
|
|
|
// Name
|
|
|
|
// Name
|
|
|
|
var name = h('span.cp-team-member-name', data.displayName);
|
|
|
|
var name = h('span.cp-team-member-name', data.displayName);
|
|
|
|
|
|
|
|
// Status
|
|
|
|
|
|
|
|
var status = h('span.cp-team-member-status'+(data.online ? '.online' : ''));
|
|
|
|
// Actions
|
|
|
|
// Actions
|
|
|
|
var actions = h('span.cp-team-member-actions');
|
|
|
|
var actions = h('span.cp-team-member-actions');
|
|
|
|
var $actions = $(actions);
|
|
|
|
var $actions = $(actions);
|
|
|
@ -400,7 +438,7 @@ define([
|
|
|
|
var myRole = me ? (ROLES.indexOf(me.role) || 0) : -1;
|
|
|
|
var myRole = me ? (ROLES.indexOf(me.role) || 0) : -1;
|
|
|
|
var theirRole = ROLES.indexOf(data.role) || 0;
|
|
|
|
var theirRole = ROLES.indexOf(data.role) || 0;
|
|
|
|
// If they're a member and I have a higher role than them, I can promote them to admin
|
|
|
|
// If they're a member and I have a higher role than them, I can promote them to admin
|
|
|
|
if (!isMe && myRole > theirRole && theirRole === 0) {
|
|
|
|
if (!isMe && myRole > theirRole && theirRole === 0 && !data.pending) {
|
|
|
|
var promote = h('span.fa.fa-angle-double-up', {
|
|
|
|
var promote = h('span.fa.fa-angle-double-up', {
|
|
|
|
title: Messages.team_rosterPromote
|
|
|
|
title: Messages.team_rosterPromote
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -413,7 +451,7 @@ define([
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If I'm not a member and I have an equal or higher role than them, I can demote them
|
|
|
|
// If I'm not a member and I have an equal or higher role than them, I can demote them
|
|
|
|
// (if they're not already a MEMBER)
|
|
|
|
// (if they're not already a MEMBER)
|
|
|
|
if (!isMe && myRole >= theirRole && theirRole > 0) {
|
|
|
|
if (!isMe && myRole >= theirRole && theirRole > 0 && !data.pending) {
|
|
|
|
var demote = h('span.fa.fa-angle-double-down', {
|
|
|
|
var demote = h('span.fa.fa-angle-double-down', {
|
|
|
|
title: Messages.team_rosterDemote
|
|
|
|
title: Messages.team_rosterDemote
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -432,6 +470,7 @@ define([
|
|
|
|
$(remove).click(function () {
|
|
|
|
$(remove).click(function () {
|
|
|
|
$(remove).hide();
|
|
|
|
$(remove).hide();
|
|
|
|
APP.module.execCommand('REMOVE_USER', {
|
|
|
|
APP.module.execCommand('REMOVE_USER', {
|
|
|
|
|
|
|
|
pending: data.pending,
|
|
|
|
teamId: APP.team,
|
|
|
|
teamId: APP.team,
|
|
|
|
curvePublic: data.curvePublic,
|
|
|
|
curvePublic: data.curvePublic,
|
|
|
|
}, function (obj) {
|
|
|
|
}, function (obj) {
|
|
|
@ -449,7 +488,8 @@ define([
|
|
|
|
var content = [
|
|
|
|
var content = [
|
|
|
|
avatar,
|
|
|
|
avatar,
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
actions
|
|
|
|
actions,
|
|
|
|
|
|
|
|
status,
|
|
|
|
];
|
|
|
|
];
|
|
|
|
var div = h('div.cp-team-roster-member', {
|
|
|
|
var div = h('div.cp-team-roster-member', {
|
|
|
|
title: data.displayName
|
|
|
|
title: data.displayName
|
|
|
@ -486,6 +526,12 @@ define([
|
|
|
|
}).map(function (k) {
|
|
|
|
}).map(function (k) {
|
|
|
|
return makeMember(common, roster[k], me);
|
|
|
|
return makeMember(common, roster[k], me);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var pending = Object.keys(roster).filter(function (k) {
|
|
|
|
|
|
|
|
if (!roster[k].pending) { return; }
|
|
|
|
|
|
|
|
return roster[k].role === "MEMBER" || !roster[k].role;
|
|
|
|
|
|
|
|
}).map(function (k) {
|
|
|
|
|
|
|
|
return makeMember(common, roster[k], me);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var header = h('div.cp-app-team-roster-header');
|
|
|
|
var header = h('div.cp-app-team-roster-header');
|
|
|
|
var $header = $(header);
|
|
|
|
var $header = $(header);
|
|
|
@ -538,7 +584,9 @@ define([
|
|
|
|
h('h3', Messages.team_admins),
|
|
|
|
h('h3', Messages.team_admins),
|
|
|
|
h('div', admins),
|
|
|
|
h('div', admins),
|
|
|
|
h('h3', Messages.team_members),
|
|
|
|
h('h3', Messages.team_members),
|
|
|
|
h('div', members)
|
|
|
|
h('div', members),
|
|
|
|
|
|
|
|
h('h3', Messages.team_pending || 'PENDING'), // XXX
|
|
|
|
|
|
|
|
h('div', pending)
|
|
|
|
];
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
makeBlock('roster', function (common, cb) {
|
|
|
|
makeBlock('roster', function (common, cb) {
|
|
|
@ -576,6 +624,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var todo = function () {
|
|
|
|
var todo = function () {
|
|
|
|
var newName = $input.val();
|
|
|
|
var newName = $input.val();
|
|
|
|
|
|
|
|
if (!newName.trim()) { return; }
|
|
|
|
$spinner.show();
|
|
|
|
$spinner.show();
|
|
|
|
APP.module.execCommand('GET_TEAM_METADATA', {
|
|
|
|
APP.module.execCommand('GET_TEAM_METADATA', {
|
|
|
|
teamId: APP.team
|
|
|
|
teamId: APP.team
|
|
|
|