Add meta component pricing functionality and admin UI enhancements
This commit is contained in:
@@ -21,6 +21,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Server count input -->
|
||||
<div class="bg-white rounded-lg shadow p-4 mb-4">
|
||||
<div class="flex items-center space-x-4">
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1">Количество серверов</label>
|
||||
<input type="number" id="server-count" min="1" value="1"
|
||||
class="w-20 px-3 py-2 border rounded focus:ring-2 focus:ring-blue-500"
|
||||
onchange="updateServerCount()">
|
||||
</div>
|
||||
<div class="text-sm text-gray-500">
|
||||
<span id="server-count-info">Всего: <span id="total-server-count">1</span> сервер(а)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Category Tabs -->
|
||||
<div class="bg-white rounded-lg shadow">
|
||||
<div class="border-b">
|
||||
@@ -204,6 +219,7 @@ let allComponents = [];
|
||||
let cart = [];
|
||||
let categoryOrderMap = {}; // Category code -> display_order mapping
|
||||
let autoSaveTimeout = null; // Timeout for debounced autosave
|
||||
let serverCount = 1; // Server count for the configuration
|
||||
|
||||
// Autocomplete state
|
||||
let autocompleteInput = null;
|
||||
@@ -280,6 +296,11 @@ document.addEventListener('DOMContentLoaded', async function() {
|
||||
document.getElementById('config-name').textContent = config.name;
|
||||
document.getElementById('save-buttons').classList.remove('hidden');
|
||||
|
||||
// Set server count from config
|
||||
serverCount = config.server_count || 1;
|
||||
document.getElementById('server-count').value = serverCount;
|
||||
document.getElementById('total-server-count').textContent = serverCount;
|
||||
|
||||
if (config.items && config.items.length > 0) {
|
||||
cart = config.items.map(item => ({
|
||||
lot_name: item.lot_name,
|
||||
@@ -323,6 +344,22 @@ async function loadAllComponents() {
|
||||
}
|
||||
}
|
||||
|
||||
function updateServerCount() {
|
||||
const serverCountInput = document.getElementById('server-count');
|
||||
const newCount = parseInt(serverCountInput.value) || 1;
|
||||
serverCount = Math.max(1, newCount);
|
||||
serverCountInput.value = serverCount;
|
||||
|
||||
// Update total server count display
|
||||
document.getElementById('total-server-count').textContent = serverCount;
|
||||
|
||||
// Update cart UI to reflect the server count
|
||||
updateCartUI();
|
||||
|
||||
// Trigger auto-save
|
||||
triggerAutoSave();
|
||||
}
|
||||
|
||||
function getCategoryFromLotName(lotName) {
|
||||
const parts = lotName.split('_');
|
||||
return parts[0] || '';
|
||||
@@ -1081,6 +1118,9 @@ async function saveConfig(showNotification = true) {
|
||||
const customPriceValue = parseFloat(customPriceInput.value);
|
||||
const customPrice = customPriceValue > 0 ? customPriceValue : null;
|
||||
|
||||
// Get server count
|
||||
const serverCountValue = serverCount;
|
||||
|
||||
try {
|
||||
const resp = await fetch('/api/configs/' + configUUID, {
|
||||
method: 'PUT',
|
||||
@@ -1092,7 +1132,8 @@ async function saveConfig(showNotification = true) {
|
||||
name: configName,
|
||||
items: cart,
|
||||
custom_price: customPrice,
|
||||
notes: ''
|
||||
notes: '',
|
||||
server_count: serverCountValue
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user