Added types to emails. Support for custom types. Partial fix for oc-1508.

This commit is contained in:
Thomas Tanghus 2012-08-21 00:10:31 +02:00
parent 719ae155db
commit 1e42cd162e
3 changed files with 25 additions and 8 deletions

View File

@ -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 */

View File

@ -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>');
}
}
}
}

View File

@ -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>