PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.20
ووسلام – همگام سازی ووکامرس و باسلام v1.10.20
1.10.19 1.10.20 1.10.18 1.10.17 1.10.15 1.10.14 1.10.13 1.10.12 1.10.10 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.2 1.9.1 1.9.0 1.8.8 1.8.5 1.8.6 All 53 releases
← All changes | assets/js/admin.js +33 -2 1.10.51.10.20 View file →
@@ -208,14 +208,45 @@
208 208 });
209 209
210 210 const select = document.getElementById("basalam-sync-type");
211 211 if (select) {
212 + const customFields = document.getElementById("Basalam-custom-fields");
213 + const settingsForm = select.closest("form");
214 + const validationMessage =
215 + "در حالت سفارشی باید حداقل یک فیلد را برای بروزرسانی انتخاب کنید.";
216 +
212 217 const toggleFields = (val) => {
213 - document.getElementById("Basalam-custom-fields").style.display =
214 - val === "custom" ? "block" : "none";
218 + if (customFields) {
219 + customFields.style.display = val === "custom" ? "block" : "none";
220 + }
215 221 };
222 +
223 + const hasSelectedCustomField = () =>
224 + customFields &&
225 + Array.from(
226 + customFields.querySelectorAll('input[type="checkbox"]')
227 + ).some((checkbox) => checkbox.checked);
228 +
216 229 toggleFields(select.value);
217 230 select.addEventListener("change", (e) => toggleFields(e.target.value));
231 +
232 + if (settingsForm) {
233 + settingsForm.addEventListener("submit", (event) => {
234 + if (select.value !== "custom" || hasSelectedCustomField()) return;
235 +
236 + event.preventDefault();
237 + event.stopImmediatePropagation();
238 +
239 + if (window.BasalamToast) {
240 + window.BasalamToast.error(validationMessage);
241 + }
242 +
243 + if (customFields) {
244 + customFields.scrollIntoView({ behavior: "smooth", block: "center" });
245 + customFields.querySelector('input[type="checkbox"]')?.focus();
246 + }
247 + }, true);
248 + }
218 249 }
219 250
220 251 // Tab functionality for settings modal
221 252 const initTabs = () => {