GUI contact list creation
This commit is contained in:
parent
57791e384b
commit
7e43b13f21
|
@ -71,7 +71,7 @@
|
|||
<script type="text/ng-template" id="addressbook.html">
|
||||
<ion-view title="{{addressbook.name}}">
|
||||
<ion-nav-buttons side="right">
|
||||
<a class="button button-clear button-positive button-icon icon ion-ios7-plus-empty" ui-sref="app.newCard({ addressbookId: addressbook.id, contactType: 'card' })"><!-- new --></a>
|
||||
<a class="button button-clear button-positive button-icon icon ion-ios7-plus-empty" ng-click="addCard()"><!-- new --></a>
|
||||
</ion-nav-buttons>
|
||||
<ion-content class="has-header">
|
||||
<ion-list>
|
||||
|
@ -306,7 +306,74 @@
|
|||
ng-click="confirmDelete(card)"><var:string label:value="Delete"/></button>
|
||||
</ion-content>
|
||||
</form>
|
||||
<form name="listForm" data-ng-show="card.$isList()">
|
||||
<ion-header-bar class="bar-positive">
|
||||
<button class="button button-clear" ng-click="cancel()"><var:string label:value="Cancel"/></button>
|
||||
<button class="button button-clear" ng-click="save(listForm)"><var:string label:value="Save" /></button>
|
||||
</ion-header-bar>
|
||||
<ion-content padding="10">
|
||||
<div>
|
||||
<div class="subtitle">
|
||||
<var:string label:value="List display"/>
|
||||
</div>
|
||||
<ion-list class="list-clear">
|
||||
<ion-item class="item-input">
|
||||
<input type="text" label:placeholder="Display" ng-model="card.fn"/>
|
||||
</ion-item>
|
||||
<ion-item class="item-input">
|
||||
<input type="text" label:placeholder="Nickname" ng-model="card.nickname"/>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</div>
|
||||
<div class="subtitle">
|
||||
<var:string label:value="List of members"/>
|
||||
</div>
|
||||
<div id="search-box" class="item-input-inset">
|
||||
<div class="item-input-wrapper">
|
||||
<i class="icon ion-search placeholder-icon"></i>
|
||||
<input type="text" label:placeholder="Search" ng-model="searchCards.fn" data-ng-keyup="showPopOver($event)" />
|
||||
<!--TODO <i class="clear-search icon ion-ios7-close-empty" ng-click="clearSearch()"></i> -->
|
||||
</div>
|
||||
</div>
|
||||
<ion-list class="list-clear">
|
||||
<ion-item ng-repeat="ref in card.refs" class="item-input">
|
||||
<button class="button button-small button-assertive button-icon icon ion-minus-circled"
|
||||
data-ng-click="card.$delete('refs', $index)"><!-- remove --></button>
|
||||
<span ng-if="ref.fn">({{ref.fn}})</span>
|
||||
<span>{{ref.email}}</span>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
<button class="button button-block button-assertive" ng-hide="card.isNew"
|
||||
ng-click="confirmDelete(card)"><var:string label:value="Delete"/></button>
|
||||
</ion-content>
|
||||
</form>
|
||||
</ion-modal-view>
|
||||
</script>
|
||||
|
||||
<script type="text/ng-template" id="searchFolderContacts.html">
|
||||
<ion-popover-view>
|
||||
<ion-content>
|
||||
<ion-list ng-repeat="card in addressbook.cards | orderBy:['sn'] | filter:searchCards">
|
||||
<ion-item ng-if="card.emails.length > 1" ng-click="toggleEMailList(card)" ng-class="{active: isEMailsShown(card)}">
|
||||
<i class="icon" ng-class="isEMailsShown(card) ? 'ion-minus' : 'ion-plus'"><!-- spacer --></i>
|
||||
<span ng-if="card.fn">{{card.fn}}</span>
|
||||
<!--TODO<span ng-if="!card.fn && card.c_givenname">{{card.c_givenname}}</span>-->
|
||||
<!--TODO<span ng-if="!card.fn && !card.c_givenname">{{card.c_mail}}</span>-->
|
||||
<ion-item class="item-accordion"
|
||||
ng-repeat="email in card.emails"
|
||||
ng-show="isEMailsShown(card)"
|
||||
ng-click="card.$updateMember($index, $model, $item)">
|
||||
{{email}}
|
||||
</ion-item>
|
||||
</ion-item>
|
||||
<ion-item ng-if="displayContact(card)" ng-click="addMember(card)">
|
||||
<span ng-if="card.fn">{{card.fn}}</span>
|
||||
<!--TODO<span ng-if="!card.fn">{{card.c_givenname}}</span>-->
|
||||
<span ng-if="!card.fn">{{card.c_mail}}</span>
|
||||
</ion-item>
|
||||
</ion-list>
|
||||
</ion-content>
|
||||
</ion-popover-view>
|
||||
</script>
|
||||
|
||||
</var:component>
|
||||
|
|
|
@ -176,10 +176,31 @@
|
|||
};
|
||||
}])
|
||||
|
||||
.controller('AddressBookCtrl', ['$scope', '$rootScope', '$stateParams', '$state', 'sgAddressBook', 'sgCard', 'stateAddressbook', function($scope, $rootScope, $stateParams, $state, AddressBook, Card, stateAddressbook) {
|
||||
.controller('AddressBookCtrl', ['$scope', '$rootScope', '$stateParams', '$state', '$ionicActionSheet', 'sgAddressBook', 'sgCard', 'stateAddressbook', function($scope, $rootScope, $stateParams, $state, $ionicActionSheet, AddressBook, Card, stateAddressbook) {
|
||||
$rootScope.addressbook = stateAddressbook;
|
||||
|
||||
$scope.search = { status: null, filter: null, lastFilter: null };
|
||||
|
||||
$scope.addCard = function() {
|
||||
$ionicActionSheet.show({
|
||||
titleText: l('Create a new card or a new list'),
|
||||
buttons: [
|
||||
{ text: l('New Card')},
|
||||
{ text: l('New List')}
|
||||
],
|
||||
canceltext: l('Cancel'),
|
||||
buttonClicked: function(index) {
|
||||
if(index == 0){
|
||||
$state.go('app.newCard', { addressbookId: stateAddressbook.id, contactType: 'card' });
|
||||
}
|
||||
else if(index == 1){
|
||||
$state.go('app.newCard', { addressbookId: stateAddressbook.id, contactType: 'list' });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.doSearch = function(keyEvent) {
|
||||
if ($scope.search.lastFilter != $scope.search.filter) {
|
||||
if ($scope.search.filter.length > 2) {
|
||||
|
@ -203,7 +224,8 @@
|
|||
};
|
||||
}])
|
||||
|
||||
.controller('CardCtrl', ['$scope', '$rootScope', '$state', '$stateParams', '$ionicModal', 'sgDialog', 'sgAddressBook', 'sgCard', 'stateCard', function($scope, $rootScope, $state, $stateParams, $ionicModal, Dialog, AddressBook, Card, stateCard) {
|
||||
.controller('CardCtrl', ['$scope', '$rootScope', '$state', '$stateParams', '$ionicModal', '$ionicPopover', 'sgDialog', 'sgAddressBook', 'sgCard', 'stateCard',
|
||||
function($scope, $rootScope, $state, $stateParams, $ionicModal, $ionicPopover, Dialog, AddressBook, Card, stateCard) {
|
||||
$scope.card = stateCard;
|
||||
|
||||
$scope.UserFolderURL = UserFolderURL;
|
||||
|
@ -212,6 +234,13 @@
|
|||
$scope.allUrlTypes = Card.$URL_TYPES;
|
||||
$scope.allAddressTypes = Card.$ADDRESS_TYPES;
|
||||
|
||||
$ionicPopover.fromTemplateUrl('searchFolderContacts.html', {
|
||||
scope: $scope,
|
||||
}).then(function(popover) {
|
||||
$scope.popover = popover;
|
||||
});
|
||||
$scope.searchCards = {fn: ""};
|
||||
|
||||
$scope.edit = function() {
|
||||
// Build modal editor
|
||||
$ionicModal.fromTemplateUrl('cardEditor.html', {
|
||||
|
@ -263,9 +292,46 @@
|
|||
var i = $scope.card.$addAddress('', '', '', '', '', '', '', '');
|
||||
focus('address_' + i);
|
||||
};
|
||||
$scope.addMember = function() {
|
||||
$scope.addMember = function(member) {
|
||||
var isAlreadyInList = angular.forEach($scope.card.refs, function(ref) {
|
||||
if (member.c_mail == ref.email)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
});
|
||||
if (member.c_mail && isAlreadyInList) {
|
||||
var i = $scope.card.$addMember('');
|
||||
focus('ref_' + i);
|
||||
$scope.card.$updateMember(i, member.c_mail, member);
|
||||
$scope.popover.hide();
|
||||
}
|
||||
};
|
||||
$scope.toggleEMailList = function(card) {
|
||||
if ($scope.isEMailsShown(card))
|
||||
$scope.EMailsShown = null;
|
||||
else
|
||||
$scope.EMailsShown = card;
|
||||
};
|
||||
$scope.isEMailsShown = function(card) {
|
||||
return $scope.EMailsShown === card;
|
||||
};
|
||||
$scope.showPopOver = function(keyEvent) {
|
||||
$scope.popover.show(keyEvent);
|
||||
}
|
||||
$scope.displayContact = function(card) {
|
||||
var b = true;
|
||||
if(card.tag == "vcard" && card.emails.length > 0){
|
||||
angular.forEach($scope.card.refs, function(ref) {
|
||||
angular.forEach(card.emails, function(email) {
|
||||
if (email.value == ref.email) {
|
||||
b = false;
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
else
|
||||
b = false;
|
||||
|
||||
return b;
|
||||
};
|
||||
$scope.save = function(form) {
|
||||
if (form.$valid) {
|
||||
|
@ -320,5 +386,4 @@
|
|||
$scope.edit();
|
||||
}
|
||||
}]);
|
||||
|
||||
})();
|
||||
|
|
|
@ -74,3 +74,12 @@ ion-item {
|
|||
border-radius: 4px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
margin-left: 5px;
|
||||
margin-top: 5px;
|
||||
color:#4a87ee;
|
||||
line-height: initial;
|
||||
font-size: 120%;
|
||||
text-shadow: 1px #145fd7;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue