Fix team creation UI issue

pull/1/head
yflory 5 years ago
parent 8d99e811f1
commit 50d0abd193

@ -649,8 +649,8 @@ define([
if (err) { console.error(err); } if (err) { console.error(err); }
})); }));
}).nThen(function () { }).nThen(function () {
cb();
closeTeam(ctx, teamId); closeTeam(ctx, teamId);
cb();
}); });
}; };

@ -367,7 +367,7 @@ define([
refreshList(common, cb); refreshList(common, cb);
}); });
makeBlock('create', function (common, cb) { var refreshCreate = function (common, cb) {
var metadataMgr = common.getMetadataMgr(); var metadataMgr = common.getMetadataMgr();
var privateData = metadataMgr.getPrivateData(); var privateData = metadataMgr.getPrivateData();
var content = []; var content = [];
@ -395,17 +395,21 @@ define([
content.push(h('br')); content.push(h('br'));
content.push(h('br')); content.push(h('br'));
content.push(button); content.push(button);
var $spinner = $('<span>', {'class': 'fa fa-spinner fa-pulse'}).hide();
content.push($spinner[0]);
var state = false; var state = false;
$(button).click(function () { $(button).click(function () {
if (state) { return; } if (state) { return; }
var name = $(input).val(); var name = $(input).val();
if (!name.trim()) { return; } if (!name.trim()) { return; }
state = true; state = true;
$spinner.show();
APP.module.execCommand('CREATE_TEAM', { APP.module.execCommand('CREATE_TEAM', {
name: name name: name
}, function (obj) { }, function (obj) {
if (obj && obj.error) { if (obj && obj.error) {
console.error(obj.error); console.error(obj.error);
$spinner.hide();
return void UI.warn(Messages.error); return void UI.warn(Messages.error);
} }
// Redraw the create block // Redraw the create block
@ -417,15 +421,15 @@ define([
refreshList(common, function (content) { refreshList(common, function (content) {
state = false; state = false;
$div.append(content); $div.append(content);
$spinner.hide();
$('div.cp-team-cat-list').click(); $('div.cp-team-cat-list').click();
}); });
}); });
}); });
cb(content); cb(content);
}); };
makeBlock('create', function (common, cb) {
makeBlock('back', function (common, cb) { refreshCreate(common, cb);
refreshList(common, cb);
}); });
makeBlock('drive', function (common, cb) { makeBlock('drive', function (common, cb) {
@ -956,10 +960,17 @@ define([
metadataMgr.onChange(function () { metadataMgr.onChange(function () {
var $div = $('div.cp-team-list'); var $div = $('div.cp-team-list');
if (!$div.length) { return; } if ($div.length) {
refreshList(common, function (content) { refreshList(common, function (content) {
$div.empty().append(content); $div.empty().append(content);
}); });
}
var $divCreate = $('div.cp-team-create');
if ($divCreate.length) {
refreshCreate(common, function (content) {
$divCreate.empty().append(content);
});
}
}); });
var onDisconnect = function (noAlert) { var onDisconnect = function (noAlert) {

Loading…
Cancel
Save