fixed phone popup (opening on [More...]) does not show always shown numbers (work, cell, home, fax) and if they are prefered, also changes made to them get not propagated back

This commit is contained in:
Ralf Becker 2014-02-13 10:06:18 +00:00
parent 8d86f8496b
commit 8525d55080
2 changed files with 71 additions and 53 deletions

View File

@ -157,45 +157,63 @@ app.classes.addressbook = AppJS.extend(
nm_action(_action, _senders);
},
showphones: function(form)
/**
* [More...] in phones clicked: copy allways shown phone numbers to phone popup
*
* @param {jQuery.event} _event
* @param {et2_widget} _widget
*/
showphones: function(_event, _widget)
{
if (form) {
copyvalues(form,"tel_home","tel_home2");
copyvalues(form,"tel_work","tel_work2");
copyvalues(form,"tel_cell","tel_cell2");
copyvalues(form,"tel_fax","tel_fax2");
}
this._copyvalues({
tel_home: 'tel_home2',
tel_work: 'tel_work2',
tel_cell: 'tel_cell2',
tel_fax: 'tel_fax2',
});
jQuery('table.editphones').css('display','inline');
_event.stopPropagation();
return false;
},
hidephones: function(form)
/**
* [OK] in phone popup clicked: copy phone numbers back to always shown ones
*
* @param {jQuery.event} _event
* @param {et2_widget} _widget
*/
hidephones: function(_event, _widget)
{
if (form) {
copyvalues(form,"tel_home2","tel_home");
copyvalues(form,"tel_work2","tel_work");
copyvalues(form,"tel_cell2","tel_cell");
copyvalues(form,"tel_fax2","tel_fax");
}
this._copyvalues({
tel_home2: 'tel_home',
tel_work2: 'tel_work',
tel_cell2: 'tel_cell',
tel_fax2: 'tel_fax',
});
jQuery('table.editphones').css('display','none');
_event.stopPropagation();
return false;
},
copyvalues: function(form,src,dst)
/**
* Copy content of multiple fields
*
* @param {object} what object with src: dst pairs
*/
_copyvalues: function(what)
{
var srcelement = getElement(form,src); //ById("exec["+src+"]");
var dstelement = getElement(form,dst); //ById("exec["+dst+"]");
if (srcelement && dstelement) {
dstelement.value = srcelement.value;
}
},
getElement: function(form,pattern)
for(var name in what)
{
for (i = 0; i < form.length; i++){
if(form.elements[i].name){
var found = form.elements[i].name.search("\\["+pattern+"\\]");
if (found != -1){
return form.elements[i];
}
}
var src = this.et2.getWidgetById(name);
var dst = this.et2.getWidgetById(what[name]);
if (src && dst) dst.set_value(src.get_value());
}
// change tel_prefer according to what
var tel_prefer = this.et2.getWidgetById('tel_prefer');
if (tel_prefer && typeof what[tel_prefer.get_value()] != 'undefined')
tel_prefer.set_value(what[tel_prefer.get_value()]);
},
/**

View File

@ -431,17 +431,17 @@
<row>
<description for="tel_work2" value="business" class="bold"/>
<url-phone id="tel_work2" options="30"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_work,&amp;hearts;"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_work2,&amp;hearts;"/>
</row>
<row>
<description for="tel_cell2" value="mobile phone"/>
<url-phone id="tel_cell2" options="30"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_cell,&amp;hearts;"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_cell2,&amp;hearts;"/>
</row>
<row>
<description for="tel_fax" value="fax"/>
<description for="tel_fax2" value="fax"/>
<url-phone id="tel_fax2" options="30"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_fax,&amp;hearts;"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_fax2,&amp;hearts;"/>
</row>
<row>
<description for="tel_car" value="car phone"/>
@ -471,7 +471,7 @@
<row>
<description for="tel_home2" value="Private" class="bold"/>
<url-phone id="tel_home2" options="30"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_home,&amp;hearts;"/>
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_home2,&amp;hearts;"/>
</row>
<row>
<description for="tel_cell_private" value="mobile phone"/>
@ -492,7 +492,7 @@
<radio statustext="select phone number as prefered way of contact" id="tel_prefer" options="tel_other,&amp;hearts;"/>
</row>
<row>
<button align="center" label="Ok" id="button[ok]" class="button_ok" onclick="jQuery('table.editphones').css('display','none'); if (window.hidephones) hidephones(this.form); return false;" span="all" image="check" background_image="1"/>
<button align="center" label="Ok" id="button[ok]" class="button_ok" onclick="app.addressbook.hidephones" span="all" image="check" background_image="1"/>
</row>
</rows>
</grid>
@ -592,7 +592,7 @@
<row>
<description/>
<description/>
<button accesskey="m" label="More ..." id="button[more]" class="button_more" onclick="jQuery('table.editphones').css('display','inline'); if (window.showphones) showphones(this.form); return false;" image="edit" background_image="1"/>
<button accesskey="m" label="More ..." id="button[more]" class="button_more" onclick="app.addressbook.showphones" image="edit" background_image="1"/>
<description/>
</row>
</rows>
@ -641,7 +641,7 @@
<button label="Apply" id="button[apply]" class="button_apply" image="apply" background_image="1"/>
<button label="Cancel" id="button[cancel]" class="button_cancel" onclick="if($cont[view] || false) return true; self.close(); return false;" image="cancel" background_image="1"/>
<checkbox statustext="Apply changes to all members, whose fields have the same previous content" label="change all organisation members" id="change_org" span="all"/>
<button align="left" label="Delete" id="button[delete]" class="button_delete" onclick="et2_dialog.confirm(widget,'Do you really want to delete this contact?','Delete')" tabindex="25" image="delete" background_image="1"/>
<button align="right" label="Delete" id="button[delete]" class="button_delete" onclick="et2_dialog.confirm(widget,'Do you really want to delete this contact?','Delete')" tabindex="25" image="delete" background_image="1"/>
</hbox>
</row>