Added the capability to create address books

This commit is contained in:
Ludovic Marcotte 2015-04-23 14:41:32 -04:00 committed by Francis Lachapelle
parent ecf30daaf3
commit 19c12add73
2 changed files with 46 additions and 16 deletions

View file

@ -182,6 +182,9 @@
sg-subscribe-on-select="subscribeToFolder(folderData)"> sg-subscribe-on-select="subscribeToFolder(folderData)">
<i class="md-icon-folder-shared"><!-- icon --></i> <i class="md-icon-folder-shared"><!-- icon --></i>
</md-button> </md-button>
<md-button ng-click="newAddressbook()">
<i class="md-icon-add-circle"><!-- icon --></i>
</md-button>
</div> </div>
</md-toolbar> </md-toolbar>
</md-content> </md-content>

View file

@ -109,23 +109,50 @@
$scope.select = function(rowIndex) { $scope.select = function(rowIndex) {
$scope.editMode = false; $scope.editMode = false;
}; };
$scope.newAddressbook = function() { $scope.newAddressbook = function(ev) {
$scope.editMode = false; $scope.editMode = false;
Dialog.prompt(l('New addressbook'), $mdDialog.show({
l('Name of new addressbook')) parent: angular.element(document.body),
.then(function(name) { targetEvent: ev,
if (name && name.length > 0) { clickOutsideToClose: true,
escapeToClose: true,
template:
'<md-dialog aria-label="' + l('New addressbook') + '">' +
' <md-content layout="column">' +
' <md-input-container>' +
' <label>' + l('Name of new addressbook') + '</label>' +
' <input type="text" ng-model="name" required="required"/>' +
' </md-input-container>' +
' <div layout="row">' +
' <md-button ng-click="cancelClicked()">' +
' Cancel' +
' </md-button>' +
' <md-button ng-click="okClicked()" ng-disabled="!name.length">' +
' OK' +
' </md-button>' +
' </div>'+
' </md-content>' +
'</md-dialog>',
controller: NewAddressBookDialogController
});
function NewAddressBookDialogController(scope, $mdDialog) {
scope.name = "";
scope.cancelClicked = function() {
$mdDialog.hide();
}
scope.okClicked = function() {
var addressbook = new AddressBook( var addressbook = new AddressBook(
{ {
name: name, name: scope.name,
isEditable: true, isEditable: true,
isRemote: false, isRemote: false,
owner: UserLogin owner: UserLogin
} }
); );
AddressBook.$add(addressbook); AddressBook.$add(addressbook);
$mdDialog.hide();
}
} }
});
}; };
$scope.newComponent = function(ev) { $scope.newComponent = function(ev) {
$mdDialog.show({ $mdDialog.show({