From: Stéphane Jacob Date: Sat, 26 Jun 2010 15:06:53 +0000 (+0200) Subject: Renumbering of phones now works in all cases (Closes #1158). X-Git-Tag: xorg/1.0.0~23 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=c8023e61e995f45eab8a47b1fb2d87de16363924;p=platal.git Renumbering of phones now works in all cases (Closes #1158). Signed-off-by: Stéphane Jacob --- diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index ef96031..217658b 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -344,15 +344,15 @@ function addTel(prefid, prefname) Ajax.update_html(prefix + i, 'profile/ajax/tel/' + prefid + '/' + prefname + '/' + i); } -function removeTel(id) +function removeTel(prefname, prefid, id) { var total = 0; - while ($('#tels_' + total).length != 0) { + while ($('#' + prefid + '_' + total).length != 0) { ++total; } - $('#tels_' + id).remove(); + $('#' + prefid + '_' + id).remove(); for (var i = parseInt(id) + 1; i < total; ++i) { - renumberPhone(i); + renumberPhone(prefname, prefid, i); } } @@ -369,25 +369,25 @@ function removePhoneComment(id, pref) $('#' + id + '_addComment').show(); } -function renumberPhone(i) +function renumberPhone(prefname, prefid, i) { var telid = i - 1; - var telprefOld = 'tels[' + i + ']'; - var telpref = 'tels[' + telid + ']'; - var idOld = 'tels_' + i; - var id = 'tels_' + telid; - - $('#tels_' + i).attr('id', 'tels_' + telid); - $('#tels_' + telid).find('div.titre').html('N°' + i); - $('#tels_' + telid).find('a.removeTel').attr('href', 'javascript:removeTel(' + telid + ')'); - $('#tels_' + telid).find('select').attr('name', telpref + '[type]'); - $('#tels_' + telid).find("[name='" + telprefOld + "[tel]']").attr('name', telpref + '[tel]'); - $('#tels_' + telid).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]'); - $('#tels_' + telid).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')'); - $('#tels_' + telid).find('#' + idOld + '_addComment').attr('id', id + '_addComment'); - $('#tels_' + telid).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')'); - $('#tels_' + telid).find('#' + idOld + '_comment').attr('id', id + '_comment'); - $('#tels_' + telid).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]'); + var telprefOld = prefname + '[' + i + ']'; + var telpref = prefname + '[' + telid + ']'; + var idOld = prefid + '_' + i; + var id = prefid + '_' + telid; + + $('#' + idOld).attr('id', id); + $('#' + id).find('div.titre').html('N°' + i); + $('#' + id).find('a.removeTel').attr('href', 'javascript:removeTel(\'' + prefname + '\',\'' + prefid + '\',' + telid + ')'); + $('#' + id).find('select').attr('name', telpref + '[type]'); + $('#' + id).find("[name='" + telprefOld + "[tel]']").attr('name', telpref + '[tel]'); + $('#' + id).find("[name='" + telprefOld + "[comment]']").attr('name', telpref + '[comment]'); + $('#' + id).find('a.removePhoneComment').attr('href', 'javascript:removePhoneComment(' + id + ',' + telpref + ')'); + $('#' + id).find('#' + idOld + '_addComment').attr('id', id + '_addComment'); + $('#' + id).find('#' + id + '_addComment').attr('href', 'javascript:addPhoneComment(' + id + ')'); + $('#' + id).find('#' + idOld + '_comment').attr('id', id + '_comment'); + $('#' + id).find("[name='" + telprefOld + "[pub]']").attr('name', telpref + '[pub]'); } // {{{1 Groups diff --git a/templates/profile/phone.tpl b/templates/profile/phone.tpl index c588e84..15a34e5 100644 --- a/templates/profile/phone.tpl +++ b/templates/profile/phone.tpl @@ -30,7 +30,7 @@ - + {icon name=cross title="Supprimer ce numéro de téléphone"}