This commit is contained in:
@@ -58,6 +58,14 @@
|
||||
<input type="number" class="form-control" id="action_number">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="auto_unit" class="form-label">Площадка</label>
|
||||
<select class="form-control" id="auto_unit">
|
||||
<option value="">Выберите площадку</option>
|
||||
</select>
|
||||
<div class="form-text">Выберите площадку из списка доступных</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="text" class="form-label required">Текст поста</label>
|
||||
<textarea class="form-control" id="text" rows="4" required></textarea>
|
||||
@@ -221,6 +229,9 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Загрузка списка площадок
|
||||
loadVenues();
|
||||
|
||||
// Загрузка данных поста (если редактирование)
|
||||
if (postId) {
|
||||
loadPostData(postId);
|
||||
@@ -233,6 +244,31 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Загрузка списка площадок
|
||||
async function loadVenues() {
|
||||
try {
|
||||
const response = await fetch(`${PREFIX}/api/venues`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Ошибка загрузки списка площадок');
|
||||
}
|
||||
const venues = await response.json();
|
||||
|
||||
const select = document.getElementById('auto_unit');
|
||||
// Очищаем список, оставляя только первую опцию
|
||||
select.innerHTML = '<option value="">Выберите площадку</option>';
|
||||
|
||||
// Добавляем площадки
|
||||
venues.forEach(venue => {
|
||||
const option = document.createElement('option');
|
||||
option.value = venue.unit_name;
|
||||
option.textContent = venue.unit_name;
|
||||
select.appendChild(option);
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки площадок:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка данных поста
|
||||
async function loadPostData(postId) {
|
||||
try {
|
||||
@@ -247,6 +283,7 @@
|
||||
document.getElementById('vk_post_id').value = post.vk_post_id || '';
|
||||
document.getElementById('shortname').value = post.shortname || '';
|
||||
document.getElementById('action_number').value = post.action_number || '';
|
||||
document.getElementById('auto_unit').value = post.auto_unit || '';
|
||||
document.getElementById('text').value = post.text || '';
|
||||
document.getElementById('image_url').value = post.image_url || '';
|
||||
document.getElementById('vk_post_url').value = post.vk_post_url || '';
|
||||
@@ -313,6 +350,7 @@
|
||||
vk_post_id: document.getElementById('vk_post_id').value,
|
||||
shortname: document.getElementById('shortname').value,
|
||||
action_number: document.getElementById('action_number').value,
|
||||
auto_unit: document.getElementById('auto_unit').value,
|
||||
text: document.getElementById('text').value,
|
||||
image_url: document.getElementById('image_url').value,
|
||||
vk_post_url: document.getElementById('vk_post_url').value,
|
||||
|
||||
Reference in New Issue
Block a user