fix phone columns
This commit is contained in:
1 parent
69de29a8fa
commit
1dea3509a7
4 files changed
+52
-53
No files matched your search
@@ -0,0 +1,37 @@
|
|||||||
|
{% load custom_tags %}
|
||||||
|
{# ستون «شمارههای تماس» مشتری — تکمنبع برای همهٔ صفحاتِ ستون اطلاعات مشتری. #}
|
||||||
|
{# شمارهها از خودِ شیء customer استخراج میشوند (نه context view) تا هیچ صفحهای بدون داده نماند. #}
|
||||||
|
{# با phones_editable=1 (قالبهایی که اسکریپت افزودن/حذف شماره دارند) دکمههای ویرایش هم میآیند. #}
|
||||||
|
{% customer_phones customer as sms_phone_entries %}
|
||||||
|
<div class="field column is-12-desktop is-12-mobile m-0">
|
||||||
|
<label class="label">شمارههای تماس</label>
|
||||||
|
<div id="dynamic-phones-edit">
|
||||||
|
{% for entry in sms_phone_entries %}
|
||||||
|
<div class="field has-addons mt-2 ss02">
|
||||||
|
<div class="control" style="width: 30%;">
|
||||||
|
<input disabled value="{{ entry.title }}" name="phone_titles" class="input" type="text" placeholder="عنوان">
|
||||||
|
</div>
|
||||||
|
<div class="control is-expanded">
|
||||||
|
<input disabled value="{{ entry.display }}" name="phones" class="input an_phone" type="text" placeholder="تلفن">
|
||||||
|
</div>
|
||||||
|
<div class="control">
|
||||||
|
<a href="tel:{{ entry.display }}" class="button is-success" title="تماس با {{ entry.display }}">
|
||||||
|
📞
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% if phones_editable and perms.admin_panel.ViewStore %}
|
||||||
|
<div class="control">
|
||||||
|
<button type="button" disabled class="button is-danger remove-phone-btn">-</button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% empty %}
|
||||||
|
<p class="help mt-2">شمارهای برای این مشتری ثبت نشده است.</p>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% if phones_editable and perms.admin_panel.ViewStore %}
|
||||||
|
<button type="button" disabled id="add-more-phone-edit" class="button is-small is-info mt-2 w-100 add-phone-btn">
|
||||||
|
+ افزودن شماره دیگر
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
@@ -27,26 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field column is-9-desktop is-9-mobile m-0">
|
{% include "./_customer_phones.html" %}
|
||||||
<label class="label">تلفن همراه</label>
|
|
||||||
<div class="control">
|
|
||||||
{% if perms.admin_panel.ViewStore %}
|
|
||||||
<input disabled value="{{ customer.phone1 }}" name="phone1" id="phone-1" class="input an_phone" type="text" placeholder="تلفن 1">
|
|
||||||
<input disabled value="{{ customer.phone2 }}" name="phone2" id="phone-2" class="input an_phone" type="text" placeholder="تلفن 2">
|
|
||||||
<input disabled value="{{ customer.phone3 }}" name="phone3" id="phone-3" class="input an_phone" type="text" placeholder="تلفن 3">
|
|
||||||
{% else %}
|
|
||||||
<p class="pb-4">
|
|
||||||
<a href="tel:{% if customer.phone1|first in '0' %}{{ customer.phone1 }}{% else %}0{{ customer.phone1 }}{% endif %}">{{ customer.phone1 }}</a>
|
|
||||||
</p>
|
|
||||||
<p class="pb-4">
|
|
||||||
<a href="tel:0{% if customer.phone2|first in '0' %}{{ customer.phone2 }}{% else %}0{{ customer.phone2 }}{% endif %}">{{ customer.phone2 }}</a>
|
|
||||||
</p>
|
|
||||||
<p class="pb-4">
|
|
||||||
<a href="tel:0{% if customer.phone3|first in '0' %}{{ customer.phone3 }}{% else %}0{{ customer.phone3 }}{% endif %}">{{ customer.phone3 }}</a>
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="field column is-12-desktop is-12-mobile m-0">
|
<div class="field column is-12-desktop is-12-mobile m-0">
|
||||||
|
|||||||
@@ -42,39 +42,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="field column is-12-desktop is-12-mobile m-0">
|
{% include "./_customer_phones.html" with phones_editable=1 %}
|
||||||
<label class="label">شمارههای تماس</label>
|
|
||||||
<div id="dynamic-phones-edit">
|
|
||||||
{# همهٔ شمارهها از هر منبعی که ذخیره شدهاند (جدول شمارهها + فیلدهای قدیمی)، بدون تکرار #}
|
|
||||||
{% for entry in sms_phone_entries %}
|
|
||||||
<div class="field has-addons mt-2 ss02">
|
|
||||||
<div class="control" style="width: 30%;">
|
|
||||||
<input disabled value="{{ entry.title }}" name="phone_titles" class="input" type="text" placeholder="عنوان">
|
|
||||||
</div>
|
|
||||||
<div class="control is-expanded">
|
|
||||||
<input disabled value="{{ entry.display }}" name="phones" class="input an_phone" type="text" placeholder="تلفن">
|
|
||||||
</div>
|
|
||||||
<div class="control">
|
|
||||||
<a href="tel:{{ entry.display }}" class="button is-success" title="تماس با {{ entry.display }}">
|
|
||||||
📞
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
{% if perms.admin_panel.ViewStore %}
|
|
||||||
<div class="control">
|
|
||||||
<button type="button" disabled class="button is-danger remove-phone-btn">-</button>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% empty %}
|
|
||||||
<p class="help mt-2">شمارهای برای این مشتری ثبت نشده است.</p>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
{% if perms.admin_panel.ViewStore %}
|
|
||||||
<button type="button" disabled id="add-more-phone-edit" class="button is-small is-info mt-2 w-100 add-phone-btn">
|
|
||||||
+ افزودن شماره دیگر
|
|
||||||
</button>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="field column is-12-desktop is-12-mobile m-0">
|
<div class="field column is-12-desktop is-12-mobile m-0">
|
||||||
|
|||||||
@@ -20,6 +20,19 @@ def toJalaliDT(value):
|
|||||||
def has_group(user, group_name):
|
def has_group(user, group_name):
|
||||||
return user.groups.filter(name=group_name).exists()
|
return user.groups.filter(name=group_name).exists()
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def customer_phones(customer):
|
||||||
|
"""شمارههای مشتری برای ستون اطلاعات مشتری.
|
||||||
|
|
||||||
|
قبلاً این داده فقط از context view میآمد و صفحاتی که آن را پاس نمیدادند
|
||||||
|
«شمارهای ثبت نشده» نشان میدادند؛ حالا از خودِ شیء ``customer`` استخراج
|
||||||
|
میشود تا هر صفحهای که این ستون را رندر میکند یکسان باشد.
|
||||||
|
"""
|
||||||
|
if not getattr(customer, 'pk', None):
|
||||||
|
return []
|
||||||
|
from admin_panel.sms.phones import customer_phone_entries
|
||||||
|
return customer_phone_entries(customer)
|
||||||
|
|
||||||
register.filter('has_group', has_group)
|
register.filter('has_group', has_group)
|
||||||
register.filter('toJalali', toJalali)
|
register.filter('toJalali', toJalali)
|
||||||
register.filter('toJalaliDT', toJalaliDT)
|
register.filter('toJalaliDT', toJalaliDT)
|
||||||
Reference in new issue
Block a user