PluginProbe
ووسلام – همگام سازی ووکامرس و باسلام / 1.10.19
ووسلام – همگام سازی ووکامرس و باسلام v1.10.19
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 +40 -9 1.9.21.10.19 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 = () => {
@@ -867,15 +898,15 @@
867 898 }
868 899 });
869 900 };
870 901
871 - const syncIncreaseVisibility = () => {
902 + const syncPriceChangeVisibility = () => {
872 903 document
873 - .querySelectorAll('select[name="sync_basalam_bulk_increase_action"]')
904 + .querySelectorAll('select[name="sync_basalam_bulk_price_change_action"]')
874 905 .forEach((select) => {
875 906 const field = select
876 907 .closest(".sync-basalam-bulk-edit")
877 - ?.querySelector(".sync-basalam-bulk-increase-value");
908 + ?.querySelector(".sync-basalam-bulk-price-change-value");
878 909
879 910 if (field) {
880 911 field.style.display = select.value === "set" ? "block" : "none";
881 912 }
@@ -905,9 +936,9 @@
905 936
906 937 window.requestAnimationFrame(() => {
907 938 setBulkEditMode("basalam");
908 939 syncTypeVisibility();
909 - syncIncreaseVisibility();
940 + syncPriceChangeVisibility();
910 941 });
911 942 };
912 943
913 944 document.addEventListener("change", (event) => {
@@ -919,10 +950,10 @@
919 950 if (target.name === "sync_basalam_bulk_product_type_action") {
920 951 syncTypeVisibility();
921 952 }
922 953
923 - if (target.name === "sync_basalam_bulk_increase_action") {
924 - syncIncreaseVisibility();
954 + if (target.name === "sync_basalam_bulk_price_change_action") {
955 + syncPriceChangeVisibility();
925 956 }
926 957 });
927 958
928 959 document.addEventListener("click", (event) => {
@@ -967,9 +998,9 @@
967 998
968 999 setBulkEditMode("default");
969 1000
970 1001 syncTypeVisibility();
971 - syncIncreaseVisibility();
1002 + syncPriceChangeVisibility();
972 1003 };
973 1004
974 1005 initBulkEditFields();
975 1006