From 10fa229d7a1463d417c10ac3e11f49aeaa09073c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 25 Aug 2016 00:40:12 +0200 Subject: [PATCH] Add support for X-ABLABEL refs #204 (#377) --- js/components/detailsItem/detailsItem_controller.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/js/components/detailsItem/detailsItem_controller.js b/js/components/detailsItem/detailsItem_controller.js index e296da43e..1eef2ac01 100644 --- a/js/components/detailsItem/detailsItem_controller.js +++ b/js/components/detailsItem/detailsItem_controller.js @@ -43,6 +43,18 @@ angular.module('contactsApp') ctrl.availableOptions = ctrl.availableOptions.concat([{id: ctrl.type, name: displayName}]); } } + if (!_.isUndefined(ctrl.data) && !_.isUndefined(ctrl.data.namespace)) { + if (!_.isUndefined(ctrl.model.contact.props['X-ABLABEL'])) { + var val = _.find(this.model.contact.props['X-ABLABEL'], function(x) { return x.namespace === ctrl.data.namespace; }); + ctrl.type = val.value; + if (!_.isUndefined(val)) { + // in case the type is not yet in the default list of available options we add it + if (!ctrl.availableOptions.some(function(e) { return e.id === val.value; } )) { + ctrl.availableOptions = ctrl.availableOptions.concat([{id: val.value, name: val.value}]); + } + } + } + } ctrl.availableGroups = []; ContactService.getGroups().then(function(groups) {