|
|
|
@ -83,97 +83,25 @@ define([
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
var teamCategories = {
|
|
|
|
|
'back': [
|
|
|
|
|
],
|
|
|
|
|
'back': {
|
|
|
|
|
onClick: function (common) {
|
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
|
sframeChan.query('Q_SET_TEAM', null, function (err) {
|
|
|
|
|
if (err) { return void console.error(err); }
|
|
|
|
|
APP.buildUI(common);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'drive': [
|
|
|
|
|
'cp-team-drive'
|
|
|
|
|
],
|
|
|
|
|
'members': [
|
|
|
|
|
'cp-team-roster'
|
|
|
|
|
],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var create = {};
|
|
|
|
|
|
|
|
|
|
var makeBlock = function (key, getter) {
|
|
|
|
|
create[key] = function (common) {
|
|
|
|
|
var $div = $('<div>', {'class': 'cp-team-' + key + ' cp-sidebarlayout-element'});
|
|
|
|
|
getter(common, function (content) {
|
|
|
|
|
$div.append(content);
|
|
|
|
|
}, $div);
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
makeBlock('info', function (common, cb) {
|
|
|
|
|
cb([
|
|
|
|
|
h('h3', 'Team application'), // XXX
|
|
|
|
|
h('p', 'From here you can ...') // XXX
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var refreshList = function (common, cb) {
|
|
|
|
|
var content = [];
|
|
|
|
|
content.push(h('h3', 'Your teams'));
|
|
|
|
|
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
|
|
|
|
|
if (!obj) { return; }
|
|
|
|
|
if (obj.error) { return void console.error(obj.error); }
|
|
|
|
|
var lis = [];
|
|
|
|
|
Object.keys(obj).forEach(function (id) {
|
|
|
|
|
var team = obj[id];
|
|
|
|
|
var a = h('a', 'Open');
|
|
|
|
|
lis.push(h('li', h('ul', [
|
|
|
|
|
h('li', 'Name: ' + team.name), // XXX
|
|
|
|
|
h('li', 'ID: ' + id), // XXX
|
|
|
|
|
h('li', a) // XXX
|
|
|
|
|
])));
|
|
|
|
|
$(a).click(function () {
|
|
|
|
|
console.log('okok'); // XXX
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
content.push(h('ul', lis));
|
|
|
|
|
cb(content);
|
|
|
|
|
});
|
|
|
|
|
return content;
|
|
|
|
|
};
|
|
|
|
|
makeBlock('list', function (common, cb) {
|
|
|
|
|
refreshList(common, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
makeBlock('create', function (common, cb) {
|
|
|
|
|
var content = [];
|
|
|
|
|
content.push(h('h3', 'Create a team')); // XXX
|
|
|
|
|
content.push(h('label', 'Team name')); // XXX
|
|
|
|
|
var input = h('input', {type:'text'});
|
|
|
|
|
content.push(input);
|
|
|
|
|
var button = h('button.btn.btn-success', 'Create'); // XXX
|
|
|
|
|
content.push(h('br'));
|
|
|
|
|
content.push(h('br'));
|
|
|
|
|
content.push(button);
|
|
|
|
|
var state = false;
|
|
|
|
|
$(button).click(function () {
|
|
|
|
|
if (state) { return; }
|
|
|
|
|
var name = $(input).val();
|
|
|
|
|
if (!name.trim()) { return; }
|
|
|
|
|
state = true;
|
|
|
|
|
UI.confirm('Are you sure?', function (yes) {
|
|
|
|
|
if (!yes) {
|
|
|
|
|
state = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
APP.module.execCommand('CREATE_TEAM', {
|
|
|
|
|
name: name
|
|
|
|
|
}, function () {
|
|
|
|
|
var $div = $('div.cp-team-list').empty();
|
|
|
|
|
refreshList(common, function (content) {
|
|
|
|
|
state = false;
|
|
|
|
|
$div.append(content);
|
|
|
|
|
$('div.cp-team-cat-list').click();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
cb(content);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Sidebar layout
|
|
|
|
|
|
|
|
|
|
var hideCategories = function () {
|
|
|
|
@ -185,13 +113,13 @@ define([
|
|
|
|
|
APP.$rightside.find('.'+c).show();
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
var createLeftside = function (team) {
|
|
|
|
|
var createLeftSide = APP.createLeftSide = function (common, team) {
|
|
|
|
|
APP.$leftside.empty();
|
|
|
|
|
var $categories = $('<div>', {'class': 'cp-sidebarlayout-categories'})
|
|
|
|
|
.appendTo(APP.$leftside);
|
|
|
|
|
|
|
|
|
|
var categories = team ? teamCategories : mainCategories;
|
|
|
|
|
var active = team ? 'drive' : 'general';
|
|
|
|
|
var active = team ? 'drive' : 'list';
|
|
|
|
|
|
|
|
|
|
Object.keys(categories).forEach(function (key) {
|
|
|
|
|
var $category = $('<div>', {'class': 'cp-sidebarlayout-category cp-team-cat-'+key}).appendTo($categories);
|
|
|
|
@ -208,9 +136,17 @@ define([
|
|
|
|
|
|
|
|
|
|
$category.click(function () {
|
|
|
|
|
if (!Array.isArray(categories[key]) && categories[key].onClick) {
|
|
|
|
|
categories[key].onClick();
|
|
|
|
|
categories[key].onClick(common);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (active === key) { return; }
|
|
|
|
|
active = key;
|
|
|
|
|
if (key === 'drive') {
|
|
|
|
|
APP.$rightside.addClass('cp-rightside-drive');
|
|
|
|
|
} else {
|
|
|
|
|
APP.$rightside.removeClass('cp-rightside-drive');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$categories.find('.cp-leftside-active').removeClass('cp-leftside-active');
|
|
|
|
|
$category.addClass('cp-leftside-active');
|
|
|
|
|
showCategories(categories[key]);
|
|
|
|
@ -218,10 +154,13 @@ define([
|
|
|
|
|
|
|
|
|
|
$category.append(Messages['team_cat_'+key] || key); // XXX
|
|
|
|
|
});
|
|
|
|
|
if (active === 'drive') {
|
|
|
|
|
APP.$rightside.addClass('cp-rightside-drive');
|
|
|
|
|
}
|
|
|
|
|
showCategories(categories[active]);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var buildUI = function (common, team) {
|
|
|
|
|
var buildUI = APP.buildUI = function (common, team) {
|
|
|
|
|
var $rightside = APP.$rightside;
|
|
|
|
|
$rightside.empty();
|
|
|
|
|
var addItem = function (cssClass) {
|
|
|
|
@ -236,15 +175,18 @@ define([
|
|
|
|
|
categories[cat].forEach(addItem);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
createLeftside(team);
|
|
|
|
|
createLeftSide(common, team);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Team APP
|
|
|
|
|
|
|
|
|
|
var loadTeam = function (common) {
|
|
|
|
|
var loadTeam = function (common, firstLoad) {
|
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
|
var proxy = {};
|
|
|
|
|
var folders = {};
|
|
|
|
|
if (firstLoad) {
|
|
|
|
|
buildUI(common, true);
|
|
|
|
|
}
|
|
|
|
|
nThen(function (waitFor) {
|
|
|
|
|
updateObject(sframeChan, proxy, waitFor(function () {
|
|
|
|
|
updateSharedFolders(sframeChan, null, proxy.drive, folders, waitFor());
|
|
|
|
@ -262,7 +204,6 @@ define([
|
|
|
|
|
});
|
|
|
|
|
driveAPP.refresh = drive.refresh;
|
|
|
|
|
});
|
|
|
|
|
buildUI(common, true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var loadMain = function (common) {
|
|
|
|
@ -270,6 +211,115 @@ define([
|
|
|
|
|
UI.removeLoadingScreen();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Rightside elements
|
|
|
|
|
|
|
|
|
|
var makeBlock = function (key, getter) {
|
|
|
|
|
create[key] = function (common) {
|
|
|
|
|
var $div = $('<div>', {'class': 'cp-team-' + key + ' cp-sidebarlayout-element'});
|
|
|
|
|
getter(common, function (content) {
|
|
|
|
|
$div.append(content);
|
|
|
|
|
}, $div);
|
|
|
|
|
return $div;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
makeBlock('info', function (common, cb) {
|
|
|
|
|
cb([
|
|
|
|
|
h('h3', 'Team application'), // XXX
|
|
|
|
|
h('p', 'From here you can ...') // XXX
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var refreshList = function (common, cb) {
|
|
|
|
|
var sframeChan = common.getSframeChannel();
|
|
|
|
|
var content = [];
|
|
|
|
|
content.push(h('h3', 'Your teams'));
|
|
|
|
|
APP.module.execCommand('LIST_TEAMS', null, function (obj) {
|
|
|
|
|
if (!obj) { return; }
|
|
|
|
|
if (obj.error) { return void console.error(obj.error); }
|
|
|
|
|
var lis = [];
|
|
|
|
|
Object.keys(obj).forEach(function (id) {
|
|
|
|
|
var team = obj[id];
|
|
|
|
|
var a = h('a', 'Open');
|
|
|
|
|
lis.push(h('li', h('ul', [
|
|
|
|
|
h('li', 'Name: ' + team.name), // XXX
|
|
|
|
|
h('li', 'ID: ' + id), // XXX
|
|
|
|
|
h('li', a) // XXX
|
|
|
|
|
])));
|
|
|
|
|
$(a).click(function () {
|
|
|
|
|
sframeChan.query('Q_SET_TEAM', id, function (err) {
|
|
|
|
|
if (err) { return void console.error(err); }
|
|
|
|
|
buildUI(common, true);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
content.push(h('ul', lis));
|
|
|
|
|
cb(content);
|
|
|
|
|
});
|
|
|
|
|
return content;
|
|
|
|
|
};
|
|
|
|
|
makeBlock('list', function (common, cb) {
|
|
|
|
|
refreshList(common, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
makeBlock('create', function (common, cb) {
|
|
|
|
|
var content = [];
|
|
|
|
|
content.push(h('h3', 'Create a team')); // XXX
|
|
|
|
|
content.push(h('label', 'Team name')); // XXX
|
|
|
|
|
var input = h('input', {type:'text'});
|
|
|
|
|
content.push(input);
|
|
|
|
|
var button = h('button.btn.btn-success', 'Create'); // XXX
|
|
|
|
|
content.push(h('br'));
|
|
|
|
|
content.push(h('br'));
|
|
|
|
|
content.push(button);
|
|
|
|
|
var state = false;
|
|
|
|
|
$(button).click(function () {
|
|
|
|
|
if (state) { return; }
|
|
|
|
|
var name = $(input).val();
|
|
|
|
|
if (!name.trim()) { return; }
|
|
|
|
|
state = true;
|
|
|
|
|
UI.confirm('Are you sure?', function (yes) {
|
|
|
|
|
if (!yes) {
|
|
|
|
|
state = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
APP.module.execCommand('CREATE_TEAM', {
|
|
|
|
|
name: name
|
|
|
|
|
}, function () {
|
|
|
|
|
var $div = $('div.cp-team-list').empty();
|
|
|
|
|
refreshList(common, function (content) {
|
|
|
|
|
state = false;
|
|
|
|
|
$div.append(content);
|
|
|
|
|
$('div.cp-team-cat-list').click();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
cb(content);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
makeBlock('back', function (common, cb) {
|
|
|
|
|
refreshList(common, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
makeBlock('drive', function (common, cb) {
|
|
|
|
|
var $div = $('div.cp-team-drive').empty();
|
|
|
|
|
var content = [
|
|
|
|
|
h('div.cp-app-drive-container', {tabindex:0}, [
|
|
|
|
|
h('div#cp-app-drive-tree'),
|
|
|
|
|
h('div#cp-app-drive-content-container', [
|
|
|
|
|
h('div#cp-app-drive-toolbar'),
|
|
|
|
|
h('div#cp-app-drive-content', {tabindex:2})
|
|
|
|
|
])
|
|
|
|
|
])
|
|
|
|
|
];
|
|
|
|
|
UI.addLoadingScreen();
|
|
|
|
|
cb(content);
|
|
|
|
|
loadTeam(common, false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var onEvent = function (obj) {
|
|
|
|
|
var ev = obj.ev;
|
|
|
|
|
var data = obj.data;
|
|
|
|
@ -351,7 +401,7 @@ define([
|
|
|
|
|
|
|
|
|
|
$('body').css('display', '');
|
|
|
|
|
if (privateData.teamId) {
|
|
|
|
|
loadTeam(common, privateData.teamId);
|
|
|
|
|
loadTeam(common, privateData.teamId, true);
|
|
|
|
|
} else {
|
|
|
|
|
loadMain(common);
|
|
|
|
|
}
|
|
|
|
|