From 4e89e9e90e51131dfca58ead5b5044ac13b8f94e Mon Sep 17 00:00:00 2001 From: Gerald Vogt Date: Wed, 15 Jul 2015 18:15:12 +0200 Subject: [PATCH] Show property as preferred if parameter PREF is set or parameter TYPE contains PREF. --- js/contacts.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/js/contacts.js b/js/contacts.js index 78d749b0..53fd7614 100644 --- a/js/contacts.js +++ b/js/contacts.js @@ -1446,13 +1446,13 @@ OC.Contacts = OC.Contacts || {}; property.parameters.TYPE.push(property.label); meta.push(property.label); } + var preferred = false; for(var param in property.parameters) { if(property.parameters.hasOwnProperty(param)) { //console.log('param', param); if(param.toUpperCase() === 'PREF') { - var $cb = $property.find('input[type="checkbox"]'); - $cb.attr('checked', 'checked'); - meta.push($cb.attr('title')); + preferred = true; + continue; } else if(param.toUpperCase() === 'TYPE') { for(var etype in property.parameters[param]) { @@ -1462,6 +1462,10 @@ OC.Contacts = OC.Contacts || {}; if(typeof et !== 'string') { continue; } + if(et.toUpperCase() === 'PREF') { + preferred = true; + continue; + } $property.find('select.type option').each(function() { if($(this).val().toUpperCase() === et.toUpperCase()) { $(this).attr('selected', 'selected'); @@ -1481,6 +1485,11 @@ OC.Contacts = OC.Contacts || {}; } } } + if(preferred) { + var $cb = $property.find('input[type="checkbox"]'); + $cb.attr('checked', 'checked'); + meta.push($cb.attr('title')); + } var $meta = $property.find('.meta'); if($meta.length) { $meta.html(meta.join('/'));