From 50d0abd1937a6fb8086892ed49bd7ad8a32d1867 Mon Sep 17 00:00:00 2001 From: yflory Date: Tue, 8 Oct 2019 15:25:19 +0200 Subject: [PATCH] Fix team creation UI issue --- www/common/outer/team.js | 2 +- www/teams/inner.js | 29 ++++++++++++++++++++--------- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/www/common/outer/team.js b/www/common/outer/team.js index d99f169d3..2b395c8f9 100644 --- a/www/common/outer/team.js +++ b/www/common/outer/team.js @@ -649,8 +649,8 @@ define([ if (err) { console.error(err); } })); }).nThen(function () { - cb(); closeTeam(ctx, teamId); + cb(); }); }; diff --git a/www/teams/inner.js b/www/teams/inner.js index bb5422f3a..b31da7911 100644 --- a/www/teams/inner.js +++ b/www/teams/inner.js @@ -367,7 +367,7 @@ define([ refreshList(common, cb); }); - makeBlock('create', function (common, cb) { + var refreshCreate = function (common, cb) { var metadataMgr = common.getMetadataMgr(); var privateData = metadataMgr.getPrivateData(); var content = []; @@ -395,17 +395,21 @@ define([ content.push(h('br')); content.push(h('br')); content.push(button); + var $spinner = $('', {'class': 'fa fa-spinner fa-pulse'}).hide(); + content.push($spinner[0]); var state = false; $(button).click(function () { if (state) { return; } var name = $(input).val(); if (!name.trim()) { return; } state = true; + $spinner.show(); APP.module.execCommand('CREATE_TEAM', { name: name }, function (obj) { if (obj && obj.error) { console.error(obj.error); + $spinner.hide(); return void UI.warn(Messages.error); } // Redraw the create block @@ -417,15 +421,15 @@ define([ refreshList(common, function (content) { state = false; $div.append(content); + $spinner.hide(); $('div.cp-team-cat-list').click(); }); }); }); cb(content); - }); - - makeBlock('back', function (common, cb) { - refreshList(common, cb); + }; + makeBlock('create', function (common, cb) { + refreshCreate(common, cb); }); makeBlock('drive', function (common, cb) { @@ -956,10 +960,17 @@ define([ metadataMgr.onChange(function () { var $div = $('div.cp-team-list'); - if (!$div.length) { return; } - refreshList(common, function (content) { - $div.empty().append(content); - }); + if ($div.length) { + refreshList(common, function (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) {