update
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -62,6 +62,19 @@
|
||||
return html;
|
||||
}
|
||||
|
||||
function buildPaymentMethodCheckboxes(namePrefix) {
|
||||
var html = '<div class="checkbox-group">';
|
||||
Object.keys(data.paymentMethodOptions || {}).forEach(function(methodKey) {
|
||||
var label = data.paymentMethodOptions[methodKey] || methodKey;
|
||||
html += '<label class="checkbox-label">'
|
||||
+ '<input type="checkbox" name="' + namePrefix + '[payment_method_keys][]" value="' + escapeHtml(methodKey) + '"> '
|
||||
+ escapeHtml(label)
|
||||
+ '</label>';
|
||||
});
|
||||
html += '</div>';
|
||||
return html;
|
||||
}
|
||||
|
||||
function buildOrderStatusCheckboxes(namePrefix) {
|
||||
var html = '<div class="checkbox-group">';
|
||||
(data.orderStatusOptions || []).forEach(function(statusOption) {
|
||||
@@ -167,6 +180,7 @@
|
||||
+ '<option value="integration" selected>Integracja (kanal sprzedazy)</option>'
|
||||
+ '<option value="shipment_status">Status przesylki</option>'
|
||||
+ '<option value="payment_status">Status platnosci</option>'
|
||||
+ '<option value="payment_method">Metoda platnosci</option>'
|
||||
+ '<option value="order_status">Status zamowienia</option>'
|
||||
+ '<option value="days_in_status">Liczba dni w statusie</option>'
|
||||
+ '</select>'
|
||||
@@ -226,6 +240,10 @@
|
||||
configDiv.innerHTML = buildPaymentStatusCheckboxes(namePrefix);
|
||||
return;
|
||||
}
|
||||
if (select.value === 'payment_method') {
|
||||
configDiv.innerHTML = buildPaymentMethodCheckboxes(namePrefix);
|
||||
return;
|
||||
}
|
||||
if (select.value === 'order_status') {
|
||||
configDiv.innerHTML = buildOrderStatusCheckboxes(namePrefix);
|
||||
return;
|
||||
|
||||
@@ -104,6 +104,39 @@
|
||||
dropdown.style.left = wrapRect.left + 'px';
|
||||
}
|
||||
|
||||
function refreshTableAndPanel() {
|
||||
var url = window.location.pathname + window.location.search;
|
||||
fetch(url, {
|
||||
method: 'GET',
|
||||
headers: { 'X-Requested-With': 'XMLHttpRequest' }
|
||||
})
|
||||
.then(function (resp) {
|
||||
if (!resp.ok) return;
|
||||
return resp.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
if (!data) return;
|
||||
if (data.tableHtml) {
|
||||
var tableContainer = document.querySelector('.table-list');
|
||||
if (tableContainer) {
|
||||
tableContainer.outerHTML = data.tableHtml;
|
||||
}
|
||||
}
|
||||
if (data.panelHtml) {
|
||||
var tmp = document.createElement('div');
|
||||
tmp.innerHTML = data.panelHtml;
|
||||
var newBody = tmp.querySelector('.order-statuses-side__body');
|
||||
var currentBody = document.querySelector('.order-statuses-side__body');
|
||||
if (newBody && currentBody) {
|
||||
currentBody.innerHTML = newBody.innerHTML;
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(function () {
|
||||
// Status already updated optimistically — silent fail for table refresh
|
||||
});
|
||||
}
|
||||
|
||||
function changeStatus(wrap, orderId, newStatusCode, allStatuses, statusColorMap, csrfToken) {
|
||||
var prevHtml = wrap.innerHTML;
|
||||
var prevStatus = wrap.getAttribute('data-current-status');
|
||||
@@ -152,7 +185,7 @@
|
||||
var d = result.data;
|
||||
wrap.innerHTML = buildBadgeHtml(d.status_code, d.status_label, d.status_color);
|
||||
wrap.setAttribute('data-current-status', d.status_code);
|
||||
location.reload();
|
||||
refreshTableAndPanel();
|
||||
})
|
||||
.catch(function () {
|
||||
wrap.innerHTML = prevHtml;
|
||||
|
||||
Reference in New Issue
Block a user