feat: Close spell config panel after saving

This commit is contained in:
1ambda 2017-02-21 15:44:03 +09:00
parent c9b0145d27
commit e599ab92da
2 changed files with 11 additions and 3 deletions

View file

@ -230,7 +230,10 @@ export default function HeliumCtrl($scope, $rootScope, $sce,
const pkgName = pkgSearchResult.pkg.name;
const currentConf = $scope.defaultPackageConfigs[pkgName];
heliumService.saveConfig(pkgSearchResult.pkg, currentConf);
heliumService.saveConfig(pkgSearchResult.pkg, currentConf, () => {
// close after config is saved
pkgSearchResult.configOpened = false;
});
};
init();

View file

@ -126,7 +126,7 @@ export default function heliumService($http, $sce, baseUrlSrv) {
return $http.post(baseUrlSrv.getRestApiBase() + '/helium/disable/' + name);
};
this.saveConfig = function(pkg , defaultPackageConfig) {
this.saveConfig = function(pkg , defaultPackageConfig, closeConfigPanelCallback) {
// in case of local package, it will include `/`
const pkgArtifact = encodeURIComponent(pkg.artifact);
const pkgName = pkg.name;
@ -139,7 +139,12 @@ export default function heliumService($http, $sce, baseUrlSrv) {
}
const url = `${baseUrlSrv.getRestApiBase()}/helium/config/${pkgName}/${pkgArtifact}`;
return $http.post(url, filtered);
return $http.post(url, filtered)
.then(() => {
if (closeConfigPanelCallback) { closeConfigPanelCallback(); }
}).catch((error) => {
console.error(`Failed to save config for ${pkgArtifact}`, error);
});
};
/**