Added the capability to create address books

pull/91/head
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)">
<i class="md-icon-folder-shared"><!-- icon --></i>
</md-button>
<md-button ng-click="newAddressbook()">
<i class="md-icon-add-circle"><!-- icon --></i>
</md-button>
</div>
</md-toolbar>
</md-content>

View File

@ -109,23 +109,50 @@
$scope.select = function(rowIndex) {
$scope.editMode = false;
};
$scope.newAddressbook = function() {
$scope.newAddressbook = function(ev) {
$scope.editMode = false;
Dialog.prompt(l('New addressbook'),
l('Name of new addressbook'))
.then(function(name) {
if (name && name.length > 0) {
var addressbook = new AddressBook(
{
name: name,
isEditable: true,
isRemote: false,
owner: UserLogin
}
);
AddressBook.$add(addressbook);
}
});
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: ev,
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(
{
name: scope.name,
isEditable: true,
isRemote: false,
owner: UserLogin
}
);
AddressBook.$add(addressbook);
$mdDialog.hide();
}
}
};
$scope.newComponent = function(ev) {
$mdDialog.show({