|
150 | 150 | config.info_update_url = confcontainer.find('.info_update_url').text(); |
151 | 151 | }; |
152 | 152 |
|
153 | | - var render_mails_into = function(container, person_list) { |
| 153 | + var render_mails_into = function(container, person_list, as_html) { |
154 | 154 | var html=''; |
155 | 155 |
|
156 | 156 | $.each(person_list, function(index, person) { |
157 | | - html += person[0] + ' <<a href="mailto:'+person[1]+'">'+person[1]+'</a>><br />'; |
| 157 | + if (as_html) { |
| 158 | + html += person[0] + ' <<a href="mailto:'+person[1]+'">'+person[1]+'</a>><br />'; |
| 159 | + } else { |
| 160 | + html += person[0] + ' <'+person[1]+'>\n'; |
| 161 | + } |
158 | 162 | }); |
159 | 163 | container.html(html); |
160 | 164 | }; |
|
204 | 208 | updateReplyTo(); |
205 | 209 | }; |
206 | 210 |
|
207 | | - var updateInfo = function() { |
| 211 | + var updateInfo = function(first_time) { |
208 | 212 | var entity = organization; |
209 | 213 | var to_entity = from; |
210 | 214 | if (!entity.is('select') || !to_entity.is('select')) { |
|
221 | 225 | from_entity_id: to_entity.val()}, |
222 | 226 | success: function(response){ |
223 | 227 | if (!response.error) { |
224 | | - render_mails_into(cc, response.cc); |
225 | | - render_mails_into(poc, response.poc); |
| 228 | + if (!first_time || !cc.text()) { |
| 229 | + render_mails_into(cc, response.cc, false); |
| 230 | + } |
| 231 | + render_mails_into(poc, response.poc, true); |
226 | 232 | toggleApproval(response.needs_approval); |
227 | 233 | checkPostOnly(response.post_only); |
228 | 234 | userSelect(response.full_list); |
|
320 | 326 | return false; |
321 | 327 | }; |
322 | 328 |
|
323 | | - var checkFrom = function() { |
| 329 | + var checkFrom = function(first_time) { |
324 | 330 | var reduce_options = form.find('.reducedToOptions'); |
325 | 331 | if (!reduce_options.length) { |
326 | | - updateInfo(); |
| 332 | + updateInfo(first_time); |
327 | 333 | return; |
328 | 334 | } |
329 | 335 | var to_select = organization; |
|
344 | 350 | to_select.find('optgroup').show(); |
345 | 351 | to_select.find('option').show(); |
346 | 352 | } |
347 | | - updateInfo(); |
| 353 | + updateInfo(first_time); |
348 | 354 | }; |
349 | 355 |
|
350 | 356 | var initTriggers = function() { |
351 | | - organization.change(updateInfo); |
| 357 | + organization.change(function() {updateInfo(false);}); |
352 | 358 | organization.change(checkOtherSDO); |
353 | | - from.change(checkFrom); |
| 359 | + from.change(function() {checkFrom(false);}); |
354 | 360 | reply.keyup(updateFrom); |
355 | 361 | purpose.change(updatePurpose); |
356 | 362 | cancel.click(cancelForm); |
|
360 | 366 |
|
361 | 367 | var updateOnInit = function() { |
362 | 368 | updateFrom(); |
363 | | - checkFrom(); |
| 369 | + checkFrom(true); |
364 | 370 | updatePurpose(); |
365 | 371 | checkOtherSDO(); |
366 | 372 | }; |
|
0 commit comments