feat
This commit is contained in:
parent
70a97da790
commit
01eba5aa1e
@ -29,8 +29,18 @@
|
|||||||
data-post-id="{{ doc._id }}"
|
data-post-id="{{ doc._id }}"
|
||||||
onchange="selectPost(this)"
|
onchange="selectPost(this)"
|
||||||
>
|
>
|
||||||
<span class="offer-text">Выбрать</span>
|
<span class="offer-text">Принять</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="offer-label">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
class="offer-checkbox"
|
||||||
|
data-post-id="{{ doc._id }}"
|
||||||
|
onchange="uSelectPost(this)"
|
||||||
|
>
|
||||||
|
<span class="offer-text">Отклонить</span>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
|
||||||
<p class="b_6spaf">...</p>
|
<p class="b_6spaf">...</p>
|
||||||
</figcaption>
|
</figcaption>
|
||||||
@ -145,7 +155,6 @@
|
|||||||
const postId = String(checkbox.dataset.postId || '');
|
const postId = String(checkbox.dataset.postId || '');
|
||||||
if (!postId) return;
|
if (!postId) return;
|
||||||
|
|
||||||
// делаем из текущего состояния множества (устойчиво к дублям и т.п.)
|
|
||||||
const ids = loadSelectedIds();
|
const ids = loadSelectedIds();
|
||||||
const set = new Set(ids);
|
const set = new Set(ids);
|
||||||
|
|
||||||
@ -159,6 +168,36 @@
|
|||||||
updateSelectedCount();
|
updateSelectedCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uSelectPost(checkbox) {
|
||||||
|
if (!checkbox || !checkbox.dataset) return;
|
||||||
|
|
||||||
|
const postId = String(checkbox.dataset.postId || '');
|
||||||
|
if (!postId) return;
|
||||||
|
|
||||||
|
// Reject: remove from selected and uncheck any accept checkbox for same post
|
||||||
|
const ids = loadSelectedIds();
|
||||||
|
const set = new Set(ids);
|
||||||
|
set.delete(postId);
|
||||||
|
saveSelectedIds(Array.from(set));
|
||||||
|
|
||||||
|
// Uncheck the "Принять" checkbox for this post
|
||||||
|
const figure = checkbox.closest('figure');
|
||||||
|
if (figure) {
|
||||||
|
const acceptBoxes = figure.querySelectorAll('.offer-checkbox');
|
||||||
|
acceptBoxes.forEach(cb => {
|
||||||
|
if (cb !== checkbox) {
|
||||||
|
cb.checked = false;
|
||||||
|
setStateUI(cb);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setStateUI(checkbox);
|
||||||
|
updateSelectedCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async function accept_inv(inv_id) {
|
async function accept_inv(inv_id) {
|
||||||
const ids = loadSelectedIds();
|
const ids = loadSelectedIds();
|
||||||
|
|
||||||
@ -181,8 +220,6 @@
|
|||||||
|
|
||||||
showToast({ message: 'Приглашение принято. Перенаправляем на страницу доставки' });
|
showToast({ message: 'Приглашение принято. Перенаправляем на страницу доставки' });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
localStorage.removeItem(LS_KEY);
|
localStorage.removeItem(LS_KEY);
|
||||||
window.location.href = '/profile/delivery#main?exhibition_id={{doc.get("exhibition_id")}}';
|
window.location.href = '/profile/delivery#main?exhibition_id={{doc.get("exhibition_id")}}';
|
||||||
@ -193,7 +230,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// загрузка состояния при открытии страницы
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
setAllCheckboxesFromStorage();
|
setAllCheckboxesFromStorage();
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user