2016-03-19 11:02:13 +00:00
|
|
|
angular.module('contactsApp')
|
2017-02-01 12:04:55 +00:00
|
|
|
.controller('contactCtrl', function($route, $routeParams, SortByService) {
|
2015-10-27 17:52:09 +00:00
|
|
|
var ctrl = this;
|
|
|
|
|
2017-01-05 11:32:39 +00:00
|
|
|
ctrl.t = {
|
|
|
|
errorMessage : t('contacts', 'This card is corrupted and has been fixed. Please check the data and trigger a save to make the changes permanent.'),
|
|
|
|
};
|
|
|
|
|
2017-02-01 12:04:55 +00:00
|
|
|
ctrl.getName = function() {
|
|
|
|
// If lastName equals to firstName then none of them is set
|
|
|
|
if (ctrl.contact.lastName() === ctrl.contact.firstName()) {
|
|
|
|
return ctrl.contact.displayName();
|
|
|
|
}
|
|
|
|
|
2017-10-27 15:38:54 +00:00
|
|
|
if (SortByService.getSortByKey() === 'sortLastName') {
|
2017-02-01 12:04:55 +00:00
|
|
|
return (
|
2018-03-21 20:56:26 +00:00
|
|
|
ctrl.contact.lastName()
|
|
|
|
+ (ctrl.contact.firstName() ? ', ' : '')
|
2017-02-01 12:04:55 +00:00
|
|
|
+ ctrl.contact.firstName() + ' '
|
|
|
|
+ ctrl.contact.additionalNames()
|
|
|
|
).trim();
|
|
|
|
}
|
|
|
|
|
2017-10-27 15:38:54 +00:00
|
|
|
if (SortByService.getSortByKey() === 'sortFirstName') {
|
2017-02-01 12:04:55 +00:00
|
|
|
return (
|
|
|
|
ctrl.contact.firstName() + ' '
|
|
|
|
+ ctrl.contact.additionalNames() + ' '
|
|
|
|
+ ctrl.contact.lastName()
|
|
|
|
).trim();
|
|
|
|
}
|
|
|
|
|
|
|
|
return ctrl.contact.displayName();
|
|
|
|
};
|
2016-03-16 19:37:40 +00:00
|
|
|
});
|
2018-03-21 20:56:26 +00:00
|
|
|
|