Allow creation or list/contact

This commit is contained in:
Ludovic Marcotte
2015-04-22 10:01:31 -04:00
committed by Francis Lachapelle
parent 11179cf27d
commit 5ea57f195b
3 changed files with 42 additions and 3 deletions

View File

@@ -240,14 +240,16 @@
</md-list-item>
</md-list>
</md-content>
<md-button class="iconButton md-fab md-fab--bottom md-accent hide-sm" label:aria-label="New Contact" ui-sref="addressbook.new({addressbookId: addressbook.id, contactType: 'card'})"><i class="md-icon-add"><!--icon--></i></md-button>
<md-button class="iconButton md-fab md-fab--bottom md-accent
hide-sm" label:aria-label="New Contact" ng-click="newComponent()"><i class="md-icon-add"><!--icon--></i></md-button>
<!-- This extra container is used to animate views transitions
double quotes in ng-animate is not a typo -->
<div id="detailView" class="view-detail" layout="column">
<md-card class="viewer" ui-view="card"><!-- card view --></md-card>
</div>
<md-button class="iconButton md-fab md-accent show-sm" label:aria-label="New Contact" ui-sref="addressbook.new({addressbookId: addressbook.id, contactType: 'card'})"><i class="md-icon-add"><!--icon--></i></md-button>
<md-button class="iconButton md-fab md-accent show-sm"
label:aria-label="New Contact" ng-click="newComponent()"><i class="md-icon-add"><!--icon--></i></md-button>
</div>
</section>

View File

@@ -21,6 +21,8 @@
this.isNew = true;
}
this.refs = [];
if (!this.shortFormat)
this.shortFormat = this.$shortFormat();

View File

@@ -91,7 +91,7 @@
$urlRouterProvider.otherwise('/personal');
}])
.controller('AddressBookCtrl', ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$mdDialog', 'sgFocus', 'sgCard', 'sgAddressBook', 'sgDialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook', function($state, $scope, $rootScope, $stateParams, $timeout, $modal, focus, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {
.controller('AddressBookCtrl', ['$state', '$scope', '$rootScope', '$stateParams', '$timeout', '$mdDialog', 'sgFocus', 'sgCard', 'sgAddressBook', 'sgDialog', 'sgSettings', 'stateAddressbooks', 'stateAddressbook', function($state, $scope, $rootScope, $stateParams, $timeout, $mdDialog, focus, Card, AddressBook, Dialog, Settings, stateAddressbooks, stateAddressbook) {
var currentAddressbook;
$scope.activeUser = Settings.activeUser;
@@ -127,6 +127,41 @@
}
});
};
$scope.newComponent = function(ev) {
$mdDialog.show({
parent: angular.element(document.body),
targetEvent: ev,
clickOutsideToClose: true,
escapeToClose: true,
template:
'<md-dialog aria-label="Create component">' +
' <md-content>' +
' <div layout="column">' +
' <md-button ng-click="createContact()">' +
' Contact' +
' </md-button>' +
' <md-button ng-click="createList()">' +
' List' +
' </md-button>' +
' </div>' +
' </md-content>' +
'</md-dialog>',
locals: {
state: $state
},
controller: ComponentDialogController
});
function ComponentDialogController(scope, $mdDialog, state) {
scope.createContact = function() {
state.go('addressbook.new', { addressbookId: $scope.addressbook.id, contactType: 'card' });
$mdDialog.hide();
}
scope.createList = function() {
state.go('addressbook.new', { addressbookId: $scope.addressbook.id, contactType: 'list' });
$mdDialog.hide();
}
}
};
$scope.currentFolderIsConfigurable = function(folder) {
return ($scope.addressbook && $scope.addressbook.id == folder.id && !folder.isRemote);
};