0.0.326 upd change_profile

This commit is contained in:
2023-12-15 15:44:23 +03:00
parent 037b4cc562
commit 65eccde487
7 changed files with 35 additions and 30 deletions

View File

@@ -367,25 +367,26 @@ async function attachFilemeassge (el,id_ticket=null,sender=null,receiver=null,ch
function change_profile_confirm (el){
event.preventDefault()
let form = el.form
let changed_elements = {}
for (let i = 0;i < form.length;i++){
let cur_el = form[i]
if (cur_el.localName !== 'button'){
let new_val = cur_el.value
let dataset = cur_el.dataset
let old_val = ''
if (dataset){
old_val = dataset['initialValue']
}
// if (old_val){
if (old_val === new_val){
//
} else {
changed_elements[cur_el.name] = cur_el.value
}
}
// }
}
let formData = new FormData(form);
// let changed_elements = {}
// for (let i = 0;i < form.length;i++){
// let cur_el = form[i]
// if (cur_el.localName !== 'button'){
// let new_val = cur_el.value
// let dataset = cur_el.dataset
// let old_val = ''
// if (dataset){
// old_val = dataset['initialValue']
// }
// // if (old_val){
// if (old_val === new_val){
// //
// } else {
// changed_elements[cur_el.name] = cur_el.value
// }
// }
// // }
// }
$.ajax({
@@ -397,7 +398,8 @@ function change_profile_confirm (el){
processData: false,
contentType: false,
// enctype: 'json',
data: JSON.stringify(changed_elements),
// data: JSON.stringify(changed_elements),
data: formData,
success: function(data){
middleWareJS()
@@ -406,7 +408,8 @@ function change_profile_confirm (el){
},
error: function (data){
document.querySelector(".avatar_user_profile").innerHTML = data.responseJSON.html;
// document.querySelector(".avatar_user_profile").innerHTML = data.responseJSON.html;
document.querySelector(".info_profile").innerHTML = data.responseJSON.html;
}
});

View File

@@ -65,7 +65,9 @@
<span class="chat-username">{{ cur_receiver.last_name }} {{ cur_receiver.first_name }}</span>
</div>
<div class="header-chat-right-part">
<img class="header-icons-right-part-padding" src="{% static "img/svg/phone.svg" %}">
<a href="tel:{{ cur_receiver.user_profile.phone }}">
<img class="header-icons-right-part-padding" src="{% static "img/svg/phone.svg" %}">
</a>
<img class="header-icons-right-part-padding" src="{% static "img/svg/info.svg" %}">
</div>
</div>

View File

@@ -404,7 +404,7 @@
/>
{% if not errors_off and form.errors and form.errors.phone %}
<span id="error_id_phone">{{ form.errors.phone }}</span>
<span id="error_id_phone">{{ form.errors.phone|safe }}</span>
{% endif %}
</div>

View File

@@ -37,10 +37,10 @@
<div class="container_el_form_profile">
<label class="label_f_profile" for="id_tel">{% if profileForm.fields.tel.required %}<span class="orange-text">*</span>{% endif %}{% translate "Номер телефона" %} </label>
<input class="input_f_profile" type="text" id="id_tel" name="tel" {% if profileForm.initial.tel %}value="{{ profileForm.initial.tel }}" {% endif %} {% if profileForm.initial.tel %}data-initial-value="{{ profileForm.initial.tel }}"{% else %}data-initial-value=""{% endif %}>
{% if profileForm.errors.tel %}<div class="error_form_profile">{{ profileForm.errors.tel }}</div>{% endif %}
{% if profileForm.errors.tel %}<div class="error_form_profile">{{ profileForm.errors.tel|safe }}</div>{% endif %}
</div>
<div class="container_el_form_profile">
<label class="label_f_profile" for="id_email">{% if profileForm.fields.email.required %}<span class="orange-text">*</span>{% endif %} E-mail</label>
<label class="label_f_profile" for="id_email">E-mail</label>
<input class="input_f_profile grey" type="text" id="id_email" name="email" readonly {% if profileForm.initial.email %}value="{{ profileForm.initial.email }}" {% endif %} {% if profileForm.initial.email %}data-initial-value="{{ profileForm.initial.email }}"{% else %}data-initial-value=""{% endif %}>
{% if profileForm.errors.email %}<div class="error_form_profile">{{ profileForm.errors.email }}</div>{% endif %}
</div>
@@ -58,11 +58,11 @@
<div class="line_f_form_profile"></div>
<div class="container_el_form_profile">
<label class="label_f_profile" for="id_password">{% if profileForm.fields.password.required %}<span class="orange-text">*</span>{% endif %}{% translate "Новый пароль" %} </label>
<label class="label_f_profile" for="id_password">{% translate "Новый пароль" %} </label>
<input class="input_f_profile" type="text" id="id_password" name="password" {% if profileForm.initial.password %}value="{{ profileForm.initial.password }}" {% endif %} {% if profileForm.initial.password %}data-initial-value="{{ profileForm.initial.password }}"{% else %}data-initial-value=""{% endif %}>
</div>
<div class="container_el_form_profile">
<label class="label_f_profile" for="id_confirm_password">{% if profileForm.fields.confirm_password.required %}<span class="orange-text">*</span>{% endif %}{% translate "Подтвердить пароль" %} </label>
<label class="label_f_profile" for="id_confirm_password">{% translate "Подтвердить пароль" %} </label>
<input class="input_f_profile" type="text" id="id_confirm_password" name="confirm_password" {% if profileForm.initial.confirm_password %}value="{{ profileForm.initial.confirm_password }}" {% endif %} {% if profileForm.initial.confirm_password %}data-initial-value="{{ profileForm.initial.confirm_password }}"{% else %}data-initial-value=""{% endif %}>
</div>
<button class="confirm_profile_btn" onclick="change_profile_confirm(this)">{% translate "Сохарнить" %}</button>

View File

@@ -27,7 +27,7 @@
onkeydown = "hideErrors(this)"
placeholder="{% translate 'Телефон' %}"{% if form.phone %} value="{{ form.phone }}"{% endif %}>
{% if form.errors.phone %}
<span id="error_com_offer">{{ form.errors.phone }}</span>
<span id="error_com_offer">{{ form.errors.phone|safe }}</span>
{% endif %}
</div>

View File

@@ -42,7 +42,7 @@
onkeydown ="hideErrors(this)"
placeholder="{% translate 'Телефон' %}"{% if form.phone %} value="{{ form.phone }}"{% endif %}>
{% if form.errors.phone %}
<span id="error_feedback">{{ form.errors.phone }}</span>
<span id="error_feedback">{{ form.errors.phone|safe }}</span>
{% endif %}
</div>
</div>

View File

@@ -62,7 +62,7 @@
{% if form.data.tel %} value="{{ form.data.tel }}"{% endif %}>
{% if form.errors and form.errors.tel %}
<span>{{ form.errors.tel }}</span>
<span>{{ form.errors.tel|safe }}</span>
{% endif %}
</div>
</div>