feat: Add disabled class to cfg button while fetching

This commit is contained in:
1ambda 2017-02-16 12:37:09 +09:00
parent 76d50ca48b
commit f31bf3c7c3
2 changed files with 10 additions and 2 deletions

View file

@ -200,9 +200,14 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
};
$scope.configOpened = function(pkgSearchResult) {
return pkgSearchResult.configOpened;
return pkgSearchResult.configOpened && !pkgSearchResult.configFetching;
};
$scope.getConfigButtonClass = function(pkgSearchResult) {
return (pkgSearchResult.configOpened && pkgSearchResult.configFetching) ?
'disabled' : '';
}
$scope.toggleConfigButton = function(pkgSearchResult) {
if (pkgSearchResult.configOpened) {
pkgSearchResult.configOpened = false;
@ -211,11 +216,13 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
const pkg = pkgSearchResult.pkg;
const pkgName = pkg.name;
pkgSearchResult.configFetching = true;
pkgSearchResult.configOpened = true;
heliumService.getSinglePackageConfigs(pkg)
.then(confs => {
$scope.defaultPackageConfigs[pkgName] = confs;
pkgSearchResult.configOpened = true;
pkgSearchResult.configFetching = false;
$scope.$digest(); // to trigger view update
});
};

View file

@ -70,6 +70,7 @@ limitations under the License.
style="float:right">Disable</div>
<div ng-show="configExists(pkgSearchResult)"
ng-click="toggleConfigButton(pkgSearchResult)"
ng-class="getConfigButtonClass(pkgSearchResult)"
class="btn btn-default btn-xs spellConfigButton"
style="float:right; margin-right:5px;">Config</div>
</div>