summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Tanghus <thomas@tanghus.net>2012-08-21 00:10:31 +0200
committerThomas Tanghus <thomas@tanghus.net>2012-08-21 00:20:18 +0200
commit1e42cd162e70b6c9498c806a05c5c52402035c65 (patch)
tree45f8ec7969fc2fa144c52f608ee3f8bf3faeb6f1
parent719ae155db3c0d4a97250fdf00a34ae2d83aaf3e (diff)
downloadnextcloud-server-1e42cd162e70b6c9498c806a05c5c52402035c65.tar.gz
nextcloud-server-1e42cd162e70b6c9498c806a05c5c52402035c65.zip
Added types to emails. Support for custom types. Partial fix for oc-1508.
-rw-r--r--apps/contacts/css/contacts.css3
-rw-r--r--apps/contacts/js/contacts.js28
-rw-r--r--apps/contacts/templates/part.contact.php2
3 files changed, 25 insertions, 8 deletions
diff --git a/apps/contacts/css/contacts.css b/apps/contacts/css/contacts.css
index 54edf163970..d7c9a6bf342 100644
--- a/apps/contacts/css/contacts.css
+++ b/apps/contacts/css/contacts.css
@@ -119,8 +119,7 @@ input[type="checkbox"] { width: 20px; height: 20px; vertical-align: bottom; }
.propertycontainer dd { float: left; width: 25em; }
.propertylist { clear: none; max-width: 28em; }
.propertylist li.propertycontainer { white-space: nowrap; min-width: 35em; /*max-width: 30em;*/ display: block; clear: right; }
-.propertycontainer[data-element="EMAIL"] > input[type="email"] { min-width: 19em !important; float: left; }
-.propertycontainer[data-element="TEL"] > input[type="text"] { width: 10em !important; float: left; }
+.propertycontainer[data-element="EMAIL"] > input[type="email"],.propertycontainer[data-element="TEL"] > input[type="text"] { min-width: 12em !important; float: left; }
.propertylist li > input[type="checkbox"],input[type="radio"] { float: left; clear: left; width: 20px; height: 20px; vertical-align: middle; }
.propertylist li > select { float: left; max-width: 8em; }
.typelist[type="button"] { float: left; max-width: 10em; border: 0; background-color: #fff; color: #bbb} /* for multiselect */
diff --git a/apps/contacts/js/contacts.js b/apps/contacts/js/contacts.js
index fda47665c90..8f52ec88733 100644
--- a/apps/contacts/js/contacts.js
+++ b/apps/contacts/js/contacts.js
@@ -1301,26 +1301,39 @@ OC.Contacts={
loadMails:function() {
$('#emails').hide();
$('#emaillist li.propertycontainer').remove();
+ var emaillist = $('#emaillist');
for(var mail in this.data.EMAIL) {
this.addMail();
//$('#emaillist li:first-child').clone().appendTo($('#emaillist')).show();
- $('#emaillist li:last-child').data('checksum', this.data.EMAIL[mail]['checksum'])
- $('#emaillist li:last-child').find('input[type="email"]').val(this.data.EMAIL[mail]['value']);
+ var curemail = emaillist.find('li:last-child');
+ curemail.data('checksum', this.data.EMAIL[mail]['checksum'])
+ curemail.find('input[type="email"]').val(this.data.EMAIL[mail]['value']);
for(var param in this.data.EMAIL[mail]['parameters']) {
if(param.toUpperCase() == 'PREF') {
- $('#emaillist li:last-child').find('input[type="checkbox"]').attr('checked', 'checked')
+ curemail.find('input[type="checkbox"]').attr('checked', 'checked')
}
else if(param.toUpperCase() == 'TYPE') {
for(etype in this.data.EMAIL[mail]['parameters'][param]) {
+ var found = false;
var et = this.data.EMAIL[mail]['parameters'][param][etype];
- $('#emaillist li:last-child').find('select option').each(function(){
+ curemail.find('select option').each(function(){
if($.inArray($(this).val().toUpperCase(), et.toUpperCase().split(',')) > -1) {
$(this).attr('selected', 'selected');
+ found = true;
}
});
+ if(!found) {
+ curemail.find('select option:last-child').after('<option value="'+et+'" selected="selected">'+et+'</option>');
+ }
}
}
}
+ curemail.find('select').multiselect({
+ noneSelectedText: t('contacts', 'Select type'),
+ header: false,
+ selectedList: 4,
+ classes: 'typelist'
+ });
}
if($('#emaillist li').length > 1) {
$('#emails').show();
@@ -1359,13 +1372,18 @@ OC.Contacts={
}
else if(param.toUpperCase() == 'TYPE') {
for(ptype in this.data.TEL[phone]['parameters'][param]) {
+ var found = false;
var pt = this.data.TEL[phone]['parameters'][param][ptype];
- phonelist.find('li:last-child').find('select option').each(function(){
+ phonelist.find('li:last-child').find('select option').each(function() {
//if ($(this).val().toUpperCase() == pt.toUpperCase()) {
if ($.inArray($(this).val().toUpperCase(), pt.toUpperCase().split(',')) > -1) {
$(this).attr('selected', 'selected');
+ found = true;
}
});
+ if(!found) {
+ phonelist.find('li:last-child').find('select option:last-child').after('<option class="custom" value="'+pt+'" selected="selected">'+pt+'</option>');
+ }
}
}
}
diff --git a/apps/contacts/templates/part.contact.php b/apps/contacts/templates/part.contact.php
index 1f85f656874..41c91221372 100644
--- a/apps/contacts/templates/part.contact.php
+++ b/apps/contacts/templates/part.contact.php
@@ -61,7 +61,7 @@ $id = isset($_['id']) ? $_['id'] : '';
<li class="template hidden" data-element="EMAIL">
<input type="checkbox" class="contacts_property tip" name="parameters[TYPE][]" value="PREF" title="<?php echo $l->t('Preferred'); ?>" />
<input type="email" required="required" class="nonempty contacts_property" name="value" value="" x-moz-errormessage="<?php echo $l->t('Please specify a valid email address.'); ?>" placeholder="<?php echo $l->t('Enter email address'); ?>" />
- <select class="hidden" multiple="multiple" name="parameters[TYPE][]">
+ <select multiple="multiple" name="parameters[TYPE][]">
<?php echo OCP\html_select_options($_['email_types'], array()) ?>
</select>
<span class="listactions"><a class="action mail" title="<?php echo $l->t('Mail to address'); ?>"></a>