|
105 | 105 | </span> |
106 | 106 | {# Invisible input, toggles the edit box appearing #} |
107 | 107 | <input type="checkbox" id="user-profile__avatar-row-checkbox" name="avatar-row-checkbox" class="badge-button__radio" /> |
108 | | - {# File input, shown in the empty state #} |
109 | | - {% include 'v3/includes/_field_file.html' with name=user_profile_form.avatar.name extra_class='user-profile__empty-avatar-input' accept='image/png,image/jpeg' only %} |
| 108 | + {% include 'v3/includes/_field_file.html' with id="field-avatar-modal-new" name=user_profile_form.avatar.name extra_class='user-profile__empty-avatar-input' accept='image/png,image/jpeg' only %} |
110 | 109 | <div class="user-profile__default-space-col user-profile__default-avatar-buttons"> |
111 | 110 | {# Delete and replace buttons, shown in filled state #} |
112 | 111 | <label id="user-profile__avatar-replace-button" for="user-profile__avatar-row-checkbox" class="btn btn-secondary">Replace Avatar<span class="btn-icon" aria-hidden>{% include 'includes/icon.html' with icon_name='pixel-pencil' icon_size=16 icon_viewbox='0 0 16 16' only %}</span></label> |
|
420 | 419 | const SLACK_PROFILE_URL_PREFIX = '{{ SLACK_PROFILE_URL_PREFIX|escapejs }}'; |
421 | 420 | const SLACK_MEMBER_ID_PATTERN = /^[A-Z0-9]{9,11}$/i; |
422 | 421 |
|
423 | | - const avatarInput = document.querySelector("input[name='{{user_profile_form.avatar.name}}']"); |
| 422 | + const avatarInput = document.querySelector("input[id='field-avatar-modal']") |
| 423 | + const avatarInputNew = document.querySelector("input[id='field-avatar-modal-new']") |
424 | 424 | const avatarDelete = document.querySelector('#user-profile__avatar-delete-checkbox') |
425 | 425 | const avatarComponent = document.querySelector('#user-profile-editable-avatar') |
426 | 426 | const avatarImg = avatarComponent.querySelector('img') |
|
522 | 522 | if(avatarDelete.checked) { |
523 | 523 | avatar = null; |
524 | 524 | } |
| 525 | + |
525 | 526 | if(avatarInput.files.length > 0) formData.append('profile_image', avatarInput.files[0]) |
| 527 | + else if(avatarInputNew.files.length > 0) formData.append('profile_image', avatarInputNew.files[0]) |
526 | 528 | formData.append('delete_profile_image', avatarDelete.checked) |
527 | 529 |
|
528 | 530 | this.saving = true; |
529 | 531 | this.saveStatus = ''; |
530 | 532 | this.saveError = ''; |
531 | 533 |
|
532 | | - |
533 | 534 | try { |
534 | 535 | const res = await fetch('/api/v1/users/me/', { |
535 | 536 | method: 'PATCH', |
|
0 commit comments