django-nepkit 0.2.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_nepkit-0.2.0/django_nepkit.egg-info → django_nepkit-0.2.1}/PKG-INFO +2 -2
- django_nepkit-0.2.1/django_nepkit/constants.py +129 -0
- django_nepkit-0.2.1/django_nepkit/lang_utils.py +52 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/models.py +4 -8
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/static/django_nepkit/js/address-chaining.js +63 -50
- django_nepkit-0.2.1/django_nepkit/utils.py +301 -0
- django_nepkit-0.2.1/django_nepkit/views.py +139 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1/django_nepkit.egg-info}/PKG-INFO +2 -2
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit.egg-info/SOURCES.txt +2 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit.egg-info/requires.txt +1 -1
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/pyproject.toml +2 -2
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/setup.py +1 -1
- django_nepkit-0.2.0/django_nepkit/utils.py +0 -427
- django_nepkit-0.2.0/django_nepkit/views.py +0 -85
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/LICENSE +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/MANIFEST.in +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/README.md +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/__init__.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/admin.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/conf.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/filters.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/forms.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/serializers.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/static/django_nepkit/css/admin-nepali-datepicker.css +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/static/django_nepkit/js/admin-jquery-bridge.js +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/static/django_nepkit/js/nepal-data.js +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/static/django_nepkit/js/nepali-datepicker-init.js +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/urls.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/validators.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit/widgets.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit.egg-info/dependency_links.txt +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/django_nepkit.egg-info/top_level.txt +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/__init__.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/admin.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/apps.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/models.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/serializers.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/tests.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/urls.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/demo/views.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/example_project/__init__.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/example_project/settings.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/example_project/urls.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/example_project/wsgi.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/example/manage.py +0 -0
- {django_nepkit-0.2.0 → django_nepkit-0.2.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-nepkit
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Django Nepali date, time, phone, and address fields with helpers.
|
|
5
5
|
Home-page: https://github.com/S4NKALP/django-nepkit
|
|
6
6
|
Author: Sankalp Tharu
|
|
@@ -28,7 +28,7 @@ License-File: LICENSE
|
|
|
28
28
|
Requires-Dist: django>=4.2
|
|
29
29
|
Requires-Dist: django-filter>=25.2
|
|
30
30
|
Requires-Dist: djangorestframework>=3.16.1
|
|
31
|
-
Requires-Dist: nepali>=1.
|
|
31
|
+
Requires-Dist: nepali>=1.2.0
|
|
32
32
|
Provides-Extra: drf
|
|
33
33
|
Requires-Dist: djangorestframework>=3.14; extra == "drf"
|
|
34
34
|
Requires-Dist: django-filter>=23.1; extra == "drf"
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Constants for django-nepkit package.
|
|
3
|
+
Contains hardcoded values, word mappings, and configuration data.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# Nepali number words mapping (0-99)
|
|
7
|
+
NEPALI_ONES = [
|
|
8
|
+
"",
|
|
9
|
+
"एक",
|
|
10
|
+
"दुई",
|
|
11
|
+
"तीन",
|
|
12
|
+
"चार",
|
|
13
|
+
"पाँच",
|
|
14
|
+
"छ",
|
|
15
|
+
"सात",
|
|
16
|
+
"आठ",
|
|
17
|
+
"नौ",
|
|
18
|
+
"दश",
|
|
19
|
+
"एघार",
|
|
20
|
+
"बाह्र",
|
|
21
|
+
"तेह्र",
|
|
22
|
+
"चौध",
|
|
23
|
+
"पन्ध्र",
|
|
24
|
+
"सोह्र",
|
|
25
|
+
"सत्र",
|
|
26
|
+
"अठार",
|
|
27
|
+
"उन्नाइस",
|
|
28
|
+
"बीस",
|
|
29
|
+
"एकाइस",
|
|
30
|
+
"बाइस",
|
|
31
|
+
"तेईस",
|
|
32
|
+
"चौबीस",
|
|
33
|
+
"पच्चीस",
|
|
34
|
+
"छब्बीस",
|
|
35
|
+
"सत्ताइस",
|
|
36
|
+
"अठाइस",
|
|
37
|
+
"उनन्तीस",
|
|
38
|
+
"तीस",
|
|
39
|
+
"एकतीस",
|
|
40
|
+
"बत्तीस",
|
|
41
|
+
"तेत्तीस",
|
|
42
|
+
"चौंतीस",
|
|
43
|
+
"पैंतीस",
|
|
44
|
+
"छत्तीस",
|
|
45
|
+
"सैंतीस",
|
|
46
|
+
"अठतीस",
|
|
47
|
+
"उनन्चालीस",
|
|
48
|
+
"चालीस",
|
|
49
|
+
"एकचालीस",
|
|
50
|
+
"बयालीस",
|
|
51
|
+
"त्रिचालीस",
|
|
52
|
+
"चवालीस",
|
|
53
|
+
"पैंतालीस",
|
|
54
|
+
"छयालीस",
|
|
55
|
+
"सत्तालीस",
|
|
56
|
+
"अठचालीस",
|
|
57
|
+
"उनन्पचास",
|
|
58
|
+
"पचास",
|
|
59
|
+
"एकाउन्न",
|
|
60
|
+
"बाउन्न",
|
|
61
|
+
"त्रिपन्न",
|
|
62
|
+
"चउन्न",
|
|
63
|
+
"पचपन्न",
|
|
64
|
+
"छपन्न",
|
|
65
|
+
"सन्ताउन्न",
|
|
66
|
+
"अन्ठाउन्न",
|
|
67
|
+
"उनन्साठी",
|
|
68
|
+
"साठी",
|
|
69
|
+
"एकसाठी",
|
|
70
|
+
"बासट्ठी",
|
|
71
|
+
"त्रिसट्ठी",
|
|
72
|
+
"चौसट्ठी",
|
|
73
|
+
"पैंसट्ठी",
|
|
74
|
+
"छयसट्ठी",
|
|
75
|
+
"सतसट्ठी",
|
|
76
|
+
"अठसट्ठी",
|
|
77
|
+
"उनन्सत्तरी",
|
|
78
|
+
"सत्तरी",
|
|
79
|
+
"एकहत्तर",
|
|
80
|
+
"बाहत्तर",
|
|
81
|
+
"त्रिहत्तर",
|
|
82
|
+
"चौरहत्तर",
|
|
83
|
+
"पचहत्तर",
|
|
84
|
+
"छयहत्तर",
|
|
85
|
+
"सतहत्तर",
|
|
86
|
+
"अठहत्तर",
|
|
87
|
+
"उनन्असी",
|
|
88
|
+
"असी",
|
|
89
|
+
"एकासी",
|
|
90
|
+
"बयासी",
|
|
91
|
+
"त्रियासी",
|
|
92
|
+
"चौरासी",
|
|
93
|
+
"पचासी",
|
|
94
|
+
"छयासी",
|
|
95
|
+
"सतासी",
|
|
96
|
+
"अठासी",
|
|
97
|
+
"उनन्नब्बे",
|
|
98
|
+
"नब्बे",
|
|
99
|
+
"एकानब्बे",
|
|
100
|
+
"बयानब्बे",
|
|
101
|
+
"त्रियानब्बे",
|
|
102
|
+
"चौरानब्बे",
|
|
103
|
+
"पञ्चानब्बे",
|
|
104
|
+
"छ्यानब्बे",
|
|
105
|
+
"सन्तानब्बे",
|
|
106
|
+
"अन्ठानब्बे",
|
|
107
|
+
"उनन्सय",
|
|
108
|
+
]
|
|
109
|
+
|
|
110
|
+
# Nepali number units and their corresponding names
|
|
111
|
+
NEPALI_UNITS = [
|
|
112
|
+
("", ""),
|
|
113
|
+
(100, "सय"),
|
|
114
|
+
(1000, "हजार"),
|
|
115
|
+
(100000, "लाख"),
|
|
116
|
+
(10000000, "करोड"),
|
|
117
|
+
(1000000000, "अरब"),
|
|
118
|
+
(100000000000, "खरब"),
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
# Placeholder text for location selects
|
|
122
|
+
PLACEHOLDERS = {
|
|
123
|
+
"province": {"ne": "प्रदेश छान्नुहोस्", "en": "Select Province"},
|
|
124
|
+
"district": {"ne": "जिल्ला छान्नुहोस्", "en": "Select District"},
|
|
125
|
+
"municipality": {"ne": "नगरपालिका छान्नुहोस्", "en": "Select Municipality"},
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# Internal parameters to exclude from fallback logic
|
|
129
|
+
INTERNAL_PARAMS = ["ne", "en", "html"]
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Language parameter utilities for django-nepkit.
|
|
3
|
+
Helper functions to resolve Nepali/English language parameters consistently.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from django_nepkit.conf import nepkit_settings
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def resolve_language_params(ne=None, en=None, **kwargs):
|
|
10
|
+
"""
|
|
11
|
+
Resolve language parameters with fallback to default settings.
|
|
12
|
+
"""
|
|
13
|
+
default_lang = nepkit_settings.DEFAULT_LANGUAGE
|
|
14
|
+
|
|
15
|
+
# Extract from kwargs if provided
|
|
16
|
+
if ne is None and "ne" in kwargs:
|
|
17
|
+
ne = kwargs.get("ne")
|
|
18
|
+
if en is None and "en" in kwargs:
|
|
19
|
+
en = kwargs.get("en")
|
|
20
|
+
|
|
21
|
+
# Set defaults
|
|
22
|
+
if ne is None:
|
|
23
|
+
ne = default_lang == "ne"
|
|
24
|
+
|
|
25
|
+
# Handle en parameter logic
|
|
26
|
+
explicit_en = en is not None
|
|
27
|
+
if en is None:
|
|
28
|
+
en = not ne
|
|
29
|
+
|
|
30
|
+
# If ne is True and en wasn't explicitly set, en should be False
|
|
31
|
+
if ne and not explicit_en:
|
|
32
|
+
en = False
|
|
33
|
+
|
|
34
|
+
return ne, en
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def pop_language_params(kwargs):
|
|
38
|
+
"""
|
|
39
|
+
Pop ne/en parameters from kwargs dict and return resolved values.
|
|
40
|
+
"""
|
|
41
|
+
default_lang = nepkit_settings.DEFAULT_LANGUAGE
|
|
42
|
+
ne = kwargs.pop("ne", default_lang == "ne")
|
|
43
|
+
|
|
44
|
+
explicit_en = "en" in kwargs
|
|
45
|
+
en_value = kwargs.pop("en", not ne)
|
|
46
|
+
|
|
47
|
+
if ne and not explicit_en:
|
|
48
|
+
en = False
|
|
49
|
+
else:
|
|
50
|
+
en = en_value
|
|
51
|
+
|
|
52
|
+
return ne, en
|
|
@@ -7,7 +7,6 @@ from django.utils.translation import gettext_lazy as _
|
|
|
7
7
|
from nepali.datetime import nepalidate, nepalidatetime
|
|
8
8
|
from nepali.locations import districts, municipalities, provinces
|
|
9
9
|
|
|
10
|
-
from django_nepkit.forms import NepaliDateFormField
|
|
11
10
|
from django_nepkit.utils import (
|
|
12
11
|
BS_DATE_FORMAT,
|
|
13
12
|
BS_DATETIME_FORMAT,
|
|
@@ -172,6 +171,9 @@ class NepaliDateField(BaseNepaliBSField):
|
|
|
172
171
|
parse_func = staticmethod(try_parse_nepali_date)
|
|
173
172
|
|
|
174
173
|
def formfield(self, **kwargs):
|
|
174
|
+
# Import here to avoid circular dependency
|
|
175
|
+
from django_nepkit.forms import NepaliDateFormField
|
|
176
|
+
|
|
175
177
|
kwargs.setdefault("form_class", NepaliDateFormField)
|
|
176
178
|
return super().formfield(**kwargs)
|
|
177
179
|
|
|
@@ -206,13 +208,7 @@ class BaseLocationField(NepaliFieldMixin, models.CharField):
|
|
|
206
208
|
return [(self._get_name(item, ne), self._get_name(item, ne)) for item in source]
|
|
207
209
|
|
|
208
210
|
def _get_name(self, item, ne):
|
|
209
|
-
|
|
210
|
-
# Handle name variations and Koshi Province mapping
|
|
211
|
-
if name == "Province 1":
|
|
212
|
-
return "Koshi Province"
|
|
213
|
-
if name == "प्रदेश नं. १":
|
|
214
|
-
return "कोशी प्रदेश"
|
|
215
|
-
return name
|
|
211
|
+
return getattr(item, "name_nepali", item.name) if ne else item.name
|
|
216
212
|
|
|
217
213
|
def formfield(self, **kwargs):
|
|
218
214
|
widget_cls = getattr(self, "widget_class", None)
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
(function() {
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
+
// Placeholder text constants
|
|
5
|
+
const PLACEHOLDERS = {
|
|
6
|
+
province: { ne: 'प्रदेश छान्नुहोस्', en: 'Select Province' },
|
|
7
|
+
district: { ne: 'जिल्ला छान्नुहोस्', en: 'Select District' },
|
|
8
|
+
municipality: { ne: 'नगरपालिका छान्नुहोस्', en: 'Select Municipality' }
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get placeholder text for a specific location type
|
|
13
|
+
*/
|
|
14
|
+
function getPlaceholder(type, isNepali) {
|
|
15
|
+
return PLACEHOLDERS[type][isNepali ? 'ne' : 'en'];
|
|
16
|
+
}
|
|
17
|
+
|
|
4
18
|
function updateOptions(selectElement, data, placeholder) {
|
|
5
19
|
selectElement.innerHTML = '';
|
|
6
20
|
if (placeholder) {
|
|
@@ -43,7 +57,45 @@
|
|
|
43
57
|
return null;
|
|
44
58
|
}
|
|
45
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Fetch data from server endpoint
|
|
62
|
+
*/
|
|
63
|
+
function fetchData(selectElement, paramName, paramValue, placeholderType, isNepali) {
|
|
64
|
+
if (!selectElement.dataset.url) return;
|
|
65
|
+
|
|
66
|
+
let url = selectElement.dataset.url + '?' + paramName + '=' + encodeURIComponent(paramValue);
|
|
67
|
+
if (isNepali) url += '&ne=true';
|
|
68
|
+
if (selectElement.dataset.en === 'true') url += '&en=true';
|
|
69
|
+
|
|
70
|
+
fetch(url)
|
|
71
|
+
.then(response => response.json())
|
|
72
|
+
.then(data => {
|
|
73
|
+
updateOptions(selectElement, data, getPlaceholder(placeholderType, isNepali));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Update dependent select element based on parent value
|
|
79
|
+
*/
|
|
80
|
+
function updateDependentSelect(childSelect, dataType, parentValue, placeholderType, isNepali, paramName) {
|
|
81
|
+
if (!childSelect) return;
|
|
82
|
+
|
|
83
|
+
if (!parentValue) {
|
|
84
|
+
updateOptions(childSelect, [], getPlaceholder(placeholderType, isNepali));
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const localData = getLocalData(dataType, parentValue, isNepali);
|
|
89
|
+
|
|
90
|
+
if (localData) {
|
|
91
|
+
updateOptions(childSelect, localData, getPlaceholder(placeholderType, isNepali));
|
|
92
|
+
} else {
|
|
93
|
+
fetchData(childSelect, paramName, parentValue, placeholderType, isNepali);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
46
97
|
function init() {
|
|
98
|
+
// Initialize province selects
|
|
47
99
|
document.querySelectorAll('.nepkit-province-select').forEach(provinceSelect => {
|
|
48
100
|
const isNepali = provinceSelect.dataset.ne === 'true';
|
|
49
101
|
const container = provinceSelect.closest('form') || document;
|
|
@@ -52,14 +104,15 @@
|
|
|
52
104
|
|
|
53
105
|
if (!provinceSelect.value) {
|
|
54
106
|
if (districtSelect && !districtSelect.value) {
|
|
55
|
-
updateOptions(districtSelect, [],
|
|
107
|
+
updateOptions(districtSelect, [], getPlaceholder('district', isNepali));
|
|
56
108
|
}
|
|
57
109
|
if (municipalitySelect && !municipalitySelect.value) {
|
|
58
|
-
updateOptions(municipalitySelect, [],
|
|
110
|
+
updateOptions(municipalitySelect, [], getPlaceholder('municipality', isNepali));
|
|
59
111
|
}
|
|
60
112
|
}
|
|
61
113
|
});
|
|
62
114
|
|
|
115
|
+
// Initialize district selects
|
|
63
116
|
document.querySelectorAll('.nepkit-district-select').forEach(districtSelect => {
|
|
64
117
|
const isNepali = districtSelect.dataset.ne === 'true';
|
|
65
118
|
const container = districtSelect.closest('form') || document;
|
|
@@ -67,13 +120,14 @@
|
|
|
67
120
|
|
|
68
121
|
if (!districtSelect.value) {
|
|
69
122
|
if (municipalitySelect && !municipalitySelect.value) {
|
|
70
|
-
updateOptions(municipalitySelect, [],
|
|
123
|
+
updateOptions(municipalitySelect, [], getPlaceholder('municipality', isNepali));
|
|
71
124
|
}
|
|
72
125
|
}
|
|
73
126
|
});
|
|
74
127
|
}
|
|
75
128
|
|
|
76
129
|
document.addEventListener('change', function(e) {
|
|
130
|
+
// Handle province select change
|
|
77
131
|
if (e.target.matches('.nepkit-province-select')) {
|
|
78
132
|
const province = e.target.value;
|
|
79
133
|
const isNepali = e.target.dataset.ne === 'true';
|
|
@@ -83,63 +137,22 @@
|
|
|
83
137
|
|
|
84
138
|
// Always clear municipality if province changes
|
|
85
139
|
if (municipalitySelect) {
|
|
86
|
-
updateOptions(municipalitySelect, [],
|
|
140
|
+
updateOptions(municipalitySelect, [], getPlaceholder('municipality', isNepali));
|
|
87
141
|
}
|
|
88
142
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
updateOptions(districtSelect, [], isNepali ? 'जिल्ला छान्नुहोस्' : 'Select District');
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const localData = getLocalData('districts', province, isNepali);
|
|
96
|
-
|
|
97
|
-
if (localData) {
|
|
98
|
-
updateOptions(districtSelect, localData, isNepali ? 'जिल्ला छान्नुहोस्' : 'Select District');
|
|
99
|
-
} else if (districtSelect.dataset.url) {
|
|
100
|
-
// Fallback to AJAX
|
|
101
|
-
let url = districtSelect.dataset.url + '?province=' + encodeURIComponent(province);
|
|
102
|
-
if (isNepali) url += '&ne=true';
|
|
103
|
-
if (districtSelect.dataset.en === 'true') url += '&en=true';
|
|
104
|
-
|
|
105
|
-
fetch(url)
|
|
106
|
-
.then(response => response.json())
|
|
107
|
-
.then(data => {
|
|
108
|
-
updateOptions(districtSelect, data, isNepali ? 'जिल्ला छान्नुहोस्' : 'Select District');
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
}
|
|
143
|
+
// Update district options
|
|
144
|
+
updateDependentSelect(districtSelect, 'districts', province, 'district', isNepali, 'province');
|
|
112
145
|
}
|
|
113
146
|
|
|
147
|
+
// Handle district select change
|
|
114
148
|
if (e.target.matches('.nepkit-district-select')) {
|
|
115
149
|
const district = e.target.value;
|
|
116
150
|
const isNepali = e.target.dataset.ne === 'true';
|
|
117
151
|
const container = e.target.closest('form') || document;
|
|
118
152
|
const municipalitySelect = getMatchingSelect(container, '.nepkit-municipality-select', isNepali);
|
|
119
153
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
updateOptions(municipalitySelect, [], isNepali ? 'नगरपालिका छान्नुहोस्' : 'Select Municipality');
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
const localData = getLocalData('municipalities', district, isNepali);
|
|
127
|
-
|
|
128
|
-
if (localData) {
|
|
129
|
-
updateOptions(municipalitySelect, localData, isNepali ? 'नगरपालिका छान्नुहोस्' : 'Select Municipality');
|
|
130
|
-
} else if (municipalitySelect.dataset.url) {
|
|
131
|
-
// Fallback to AJAX
|
|
132
|
-
let url = municipalitySelect.dataset.url + '?district=' + encodeURIComponent(district);
|
|
133
|
-
if (isNepali) url += '&ne=true';
|
|
134
|
-
if (municipalitySelect.dataset.en === 'true') url += '&en=true';
|
|
135
|
-
|
|
136
|
-
fetch(url)
|
|
137
|
-
.then(response => response.json())
|
|
138
|
-
.then(data => {
|
|
139
|
-
updateOptions(municipalitySelect, data, isNepali ? 'नगरपालिका छान्नुहोस्' : 'Select Municipality');
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
154
|
+
// Update municipality options
|
|
155
|
+
updateDependentSelect(municipalitySelect, 'municipalities', district, 'municipality', isNepali, 'district');
|
|
143
156
|
}
|
|
144
157
|
});
|
|
145
158
|
|