Skip to content

Commit

Permalink
turn add collections into a promise
Browse files Browse the repository at this point in the history
  • Loading branch information
officert committed Feb 6, 2016
1 parent 89ee433 commit 75a32ad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/ui/components/addCollection/addCollectionCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ angular.module('app').controller('addCollectionCtrl', [
'$scope',
'$uibModalInstance',
'database',
'notificationService',
function($scope, $uibModalInstance, database, notificationService) {
'notificationService', ($scope, $uibModalInstance, database, notificationService) => {
const logger = require('lib/modules/logger');

$scope.close = function() {
$uibModalInstance.close(1);
Expand All @@ -18,11 +18,15 @@ angular.module('app').controller('addCollectionCtrl', [

if (!addCollectionForm.$valid) return;

database.addCollection($scope.form);
database.addCollection($scope.form)
.then(() => {
notificationService.success('New collection added');

notificationService.success('New collection added');

$scope.close();
$scope.close();
})
.catch(err => {
logger.error(err);
});
};
}
]);

0 comments on commit 75a32ad

Please sign in to comment.