|
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 | var url = config.info_update_url; |
|
218 | 222 | from_entity_id: to_entity.val()}, |
219 | 223 | success: function(response){ |
220 | 224 | if (!response.error) { |
221 | | - render_mails_into(cc, response.cc); |
222 | | - render_mails_into(poc, response.poc); |
| 225 | + if (!first_time || !cc.text()) { |
| 226 | + render_mails_into(cc, response.cc, false); |
| 227 | + } |
| 228 | + render_mails_into(poc, response.poc, true); |
223 | 229 | toggleApproval(response.needs_approval); |
224 | 230 | checkPostOnly(response.post_only); |
225 | 231 | userSelect(response.full_list); |
|
317 | 323 | return false; |
318 | 324 | }; |
319 | 325 |
|
320 | | - var checkFrom = function() { |
| 326 | + var checkFrom = function(first_time) { |
321 | 327 | var reduce_options = form.find('.reducedToOptions'); |
322 | 328 | if (!reduce_options.length) { |
323 | | - updateInfo(); |
| 329 | + updateInfo(first_time); |
324 | 330 | return; |
325 | 331 | } |
326 | 332 | var to_select = organization; |
|
341 | 347 | to_select.find('optgroup').show(); |
342 | 348 | to_select.find('option').show(); |
343 | 349 | } |
344 | | - updateInfo(); |
| 350 | + updateInfo(first_time); |
345 | 351 | }; |
346 | 352 |
|
347 | 353 | var initTriggers = function() { |
348 | | - organization.change(updateInfo); |
| 354 | + organization.change(function() {updateInfo(false);}); |
349 | 355 | organization.change(checkOtherSDO); |
350 | | - from.change(checkFrom); |
| 356 | + from.change(function() {checkFrom(false);}); |
351 | 357 | reply.keyup(updateFrom); |
352 | 358 | purpose.change(updatePurpose); |
353 | 359 | cancel.click(cancelForm); |
|
357 | 363 |
|
358 | 364 | var updateOnInit = function() { |
359 | 365 | updateFrom(); |
360 | | - checkFrom(); |
| 366 | + checkFrom(true); |
361 | 367 | updatePurpose(); |
362 | 368 | checkOtherSDO(); |
363 | 369 | }; |
|
0 commit comments