Змінено директорії
Додано скрипти CRON Поліпшено механізм запису стендів та їх редагування
This commit is contained in:
@@ -114,44 +114,6 @@ const Stand_card = {
|
||||
}
|
||||
},
|
||||
|
||||
// update(msg) {
|
||||
// console.log(msg.type, msg.data.id);
|
||||
|
||||
// if (msg.type == "stand_locking") {
|
||||
// const id = msg.data.id;
|
||||
// const el = document.getElementById(`name-${id}`);
|
||||
|
||||
// if (msg.user.id != USER.id) {
|
||||
// el.disabled = true;
|
||||
// el.style.border = "2px solid var(--PrimaryColor);"
|
||||
// el.style.backgroundColor = "red"
|
||||
// }
|
||||
// } else if (msg.type == "stand_unlocking") {
|
||||
// const id = msg.data.id;
|
||||
// const el = document.getElementById(`name-${id}`);
|
||||
// if (msg.user.id != USER.id || !msg.data.sheep_id) {
|
||||
// el.style.border = "";
|
||||
// el.style.backgroundColor = ""
|
||||
// el.removeAttribute('disabled');
|
||||
// }
|
||||
// } else if (msg.type == "stand_update") {
|
||||
// const id = msg.data.id;
|
||||
// const el = document.getElementById(`name-${id}`);
|
||||
// if (msg.data.sheep_id == USER.id) {
|
||||
// el.innerHTML = `<option value=""></option><option selected value="${USER.id}">${USER.name}</option>`;
|
||||
// el.removeAttribute('disabled');
|
||||
// } else if (msg.data.sheep_id == "" || msg.data.sheep_id == null || msg.data.sheep_id == USER.id) {
|
||||
// el.innerHTML = `<option value=""></option><option value="${USER.id}">${USER.name}</option>`;
|
||||
// el.removeAttribute('disabled');
|
||||
// } else {
|
||||
// el.innerHTML = `<option value="${msg.data.sheep_id}">${msg.data.sheep_name}</option>`;
|
||||
// el.disabled = true;
|
||||
// }
|
||||
// el.style.border = "";
|
||||
// el.style.backgroundColor = ""
|
||||
// } else return;
|
||||
// },
|
||||
|
||||
mess: {
|
||||
locking({ id }) {
|
||||
const message = {
|
||||
@@ -235,13 +197,69 @@ const Stand_card = {
|
||||
|
||||
schedule: {
|
||||
list: [],
|
||||
|
||||
genNull() {
|
||||
return `
|
||||
<div id="null-list" class="mess-list" data-visible="false">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V75.5l32,11.3c0.3,0.1,0.7,0.2,1,0.2c1,0,2-0.5,2.6-1.5L64,69.8l9.4,15.7 C74,86.5,75,87,76,87c0.3,0,0.7-0.1,1-0.2l32-11.3V104.9z M67,34.2L103,47L67,59.8V34.2z M77.3,80.4l-8.9-14.8l42.2-15l8.9,14.8 L77.3,80.4z M17.3,50.6l42.2,15l-8.9,14.8l-42.2-15L17.3,50.6z"
|
||||
/>
|
||||
</svg>
|
||||
<h3>Доступних днів поки немає</h3>
|
||||
</div>
|
||||
|
||||
<div id="load-list" class="mess-list" data-visible="false">
|
||||
<svg
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="1.0"
|
||||
width="64px"
|
||||
height="64px"
|
||||
viewBox="0 0 128 128"
|
||||
xml:space="preserve"
|
||||
>
|
||||
<g>
|
||||
<path
|
||||
d="M64 9.75A54.25 54.25 0 0 0 9.75 64H0a64 64 0 0 1 128 0h-9.75A54.25 54.25 0 0 0 64 9.75z"
|
||||
></path>
|
||||
<animateTransform
|
||||
attributeName="transform"
|
||||
type="rotate"
|
||||
from="0 64 64"
|
||||
to="360 64 64"
|
||||
dur="1400ms"
|
||||
repeatCount="indefinite"
|
||||
></animateTransform>
|
||||
</g>
|
||||
</svg>
|
||||
<h3>Зачекайте ...</h3>
|
||||
</div>
|
||||
`
|
||||
},
|
||||
|
||||
async setHTML() {
|
||||
const block = document.getElementById('stand-schedule');
|
||||
block.innerHTML = '';
|
||||
block.innerHTML = this.genNull();
|
||||
|
||||
const null_list = document.getElementById('null-list');
|
||||
const load_list = document.getElementById('load-list');
|
||||
|
||||
null_list.setAttribute("data-visible", "false");
|
||||
load_list.setAttribute("data-visible", "true");
|
||||
|
||||
const url = `${CONFIG.api}stand/schedule/list/${Stand_card.id}`;
|
||||
this.list = Stand_card.grouped(await Stand_card.loadAPI(url));
|
||||
|
||||
if (this.list.length == 0) {
|
||||
null_list.setAttribute("data-visible", "true");
|
||||
load_list.setAttribute("data-visible", "false");
|
||||
} else {
|
||||
null_list.setAttribute("data-visible", "false");
|
||||
load_list.setAttribute("data-visible", "false");
|
||||
}
|
||||
|
||||
const fragment = document.createDocumentFragment();
|
||||
|
||||
const createSelect = (sheep) => {
|
||||
@@ -303,14 +321,19 @@ const Stand_card = {
|
||||
textContent: `${formattedDate(timestamp)} • ${formattedDayName(timestamp)}`
|
||||
}));
|
||||
|
||||
const step = day[1]?.[0]?.hour - day[0]?.[0]?.hour || 0.5; // крок між інтервалами
|
||||
|
||||
day.forEach((hour, hourIndex) => {
|
||||
const hourDiv = Object.assign(document.createElement("div"), {
|
||||
id: `hour-${dayIndex}-${hourIndex}`
|
||||
});
|
||||
|
||||
const start = hour[0].hour;
|
||||
const end = start + step;
|
||||
|
||||
hourDiv.appendChild(Object.assign(document.createElement("span"), {
|
||||
className: "time",
|
||||
textContent: `${Stand_card.formatTime(hour[0].hour)}-${Stand_card.formatTime(hour[0].hour + Stand_card.info.list.processing_time)}`
|
||||
textContent: `${Stand_card.formatTime(start)}-${Stand_card.formatTime(end)}`
|
||||
}));
|
||||
|
||||
hour.forEach(sheep => hourDiv.appendChild(createSelect(sheep)));
|
||||
@@ -320,7 +343,7 @@ const Stand_card = {
|
||||
fragment.appendChild(dayDiv);
|
||||
});
|
||||
|
||||
// кнопка добавления
|
||||
// кнопка додавання
|
||||
if (USER.possibilities.can_add_stand) {
|
||||
const btn = Object.assign(document.createElement("button"), {
|
||||
id: "stand-new-button",
|
||||
@@ -332,132 +355,6 @@ const Stand_card = {
|
||||
|
||||
block.appendChild(fragment);
|
||||
}
|
||||
// async setHTML() {
|
||||
// const block_schedule = document.getElementById('stand-schedule');
|
||||
// block_schedule.innerHTML = '';
|
||||
|
||||
// const url = `${CONFIG.api}stand/schedule/list/${Stand_card.id}`;
|
||||
// this.list = Stand_card.grouped(await Stand_card.loadAPI(url));
|
||||
|
||||
// let dayIndex = 0;
|
||||
// for (const day of this.list) {
|
||||
// const timestamp = day[0][0].date;
|
||||
|
||||
// const dayDiv = document.createElement("div");
|
||||
// dayDiv.className = "block-day";
|
||||
// dayDiv.id = `day-${dayIndex}`;
|
||||
|
||||
// const header = document.createElement("h3");
|
||||
// header.textContent = `${formattedDate(timestamp)} • ${formattedDayName(timestamp)}`;
|
||||
// dayDiv.appendChild(header);
|
||||
|
||||
// let hourIndex = 0;
|
||||
// for (const hour of day) {
|
||||
// const hourDiv = document.createElement("div");
|
||||
// hourDiv.id = `hour-${dayIndex}-${hourIndex}`;
|
||||
|
||||
// const span = document.createElement("span");
|
||||
// span.className = "time";
|
||||
// span.textContent = `${Stand_card.formatTime(hour[0].hour)}-${Stand_card.formatTime(hour[0].hour + Stand_card.info.list.processing_time)}`;
|
||||
// hourDiv.appendChild(span);
|
||||
|
||||
// for (const sheep of hour) {
|
||||
// const select = document.createElement("select");
|
||||
// select.id = `name-${sheep.id}`;
|
||||
|
||||
// const emptyOption = document.createElement("option");
|
||||
// emptyOption.value = "";
|
||||
// emptyOption.textContent = " ";
|
||||
// select.appendChild(emptyOption);
|
||||
|
||||
// if (sheep.sheep_id && sheep.sheep_id == USER.id) {
|
||||
// const opt = document.createElement("option");
|
||||
// opt.value = USER.id;
|
||||
// opt.textContent = USER.name;
|
||||
// opt.selected = true;
|
||||
// select.appendChild(opt);
|
||||
|
||||
// // --- Обработчики событий ---
|
||||
// select.addEventListener("focus", () => {
|
||||
// // пользователь начал взаимодействие → блокируем
|
||||
// Stand_card.cloud.mess.locking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("blur", () => {
|
||||
// // пользователь ушёл → разблокируем
|
||||
// Stand_card.cloud.mess.unlocking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("change", () => {
|
||||
// // пользователь выбрал что-то → обновляем
|
||||
// Stand_card.cloud.mess.update({ sheep_id: select.value, id: sheep.id });
|
||||
// });
|
||||
// } else if (sheep.sheep_id && sheep.sheep_id != USER.id) {
|
||||
// const opt = document.createElement("option");
|
||||
// opt.value = sheep.sheep_id;
|
||||
// opt.textContent = sheep.sheep_name;
|
||||
// opt.selected = true;
|
||||
// select.appendChild(opt);
|
||||
|
||||
// // --- Обработчики событий ---
|
||||
// select.addEventListener("focus", () => {
|
||||
// // пользователь начал взаимодействие → блокируем
|
||||
// Stand_card.cloud.mess.locking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("blur", () => {
|
||||
// // пользователь ушёл → разблокируем
|
||||
// Stand_card.cloud.mess.unlocking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("change", () => {
|
||||
// // пользователь выбрал что-то → обновляем
|
||||
// Stand_card.cloud.mess.update({ sheep_id: select.value, id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.disabled = true;
|
||||
// } else {
|
||||
// const opt = document.createElement("option");
|
||||
// opt.value = USER.id;
|
||||
// opt.textContent = USER.name;
|
||||
// select.appendChild(opt);
|
||||
|
||||
// // --- Обработчики событий ---
|
||||
// select.addEventListener("focus", () => {
|
||||
// // пользователь начал взаимодействие → блокируем
|
||||
// Stand_card.cloud.mess.locking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("blur", () => {
|
||||
// // пользователь ушёл → разблокируем
|
||||
// Stand_card.cloud.mess.unlocking({ id: sheep.id });
|
||||
// });
|
||||
|
||||
// select.addEventListener("change", () => {
|
||||
// // пользователь выбрал что-то → обновляем
|
||||
// Stand_card.cloud.mess.update({ sheep_id: select.value, id: sheep.id });
|
||||
// });
|
||||
// }
|
||||
|
||||
// hourDiv.appendChild(select);
|
||||
// }
|
||||
|
||||
// dayDiv.appendChild(hourDiv);
|
||||
// hourIndex++;
|
||||
// }
|
||||
|
||||
// block_schedule.appendChild(dayDiv);
|
||||
// dayIndex++;
|
||||
// }
|
||||
|
||||
// if (USER.possibilities.can_add_stand) {
|
||||
// const btn = document.createElement("button");
|
||||
// btn.id = "stand-new-button";
|
||||
// btn.onclick = () => Stand_card.addStand();
|
||||
// btn.textContent = "Додати стенд(и)";
|
||||
// block_schedule.appendChild(btn);
|
||||
// }
|
||||
// }
|
||||
},
|
||||
|
||||
grouped(list) {
|
||||
|
||||
Reference in New Issue
Block a user