fix: rename global canWrite variable to avoid naming conflicts\n\n- Renamed global 'canWrite' variable to 'pricelistsCanWrite' to avoid potential conflicts\n- Updated all references to the renamed variable in pricelists functions\n- Maintains same functionality while improving code quality

This commit is contained in:
Mikhail Chusavitin
2026-02-02 13:00:05 +03:00
parent 6f1feb942a
commit e307a2765d

View File

@@ -213,6 +213,7 @@ let componentsCache = [];
let sortField = 'popularity_score';
let sortDir = 'desc';
let pricelistsPage = 1;
let pricelistsCanWrite = false;
async function loadTab(tab) {
currentTab = tab;
@@ -896,9 +897,9 @@ async function checkPricelistWritePermission() {
try {
const resp = await fetch('/api/pricelists/can-write');
const data = await resp.json();
canWrite = data.can_write;
pricelistsCanWrite = data.can_write;
if (canWrite) {
if (pricelistsCanWrite) {
document.getElementById('pricelists-create-btn-container').innerHTML = `
<button onclick="openPricelistsCreateModal()" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">
Создать прайслист
@@ -934,7 +935,7 @@ function renderPricelists(pricelists) {
document.getElementById('pricelists-body').innerHTML = `
<tr>
<td colspan="7" class="px-6 py-4 text-center text-gray-500">
Прайслисты не найдены. ${canWrite ? 'Создайте первый прайслист.' : ''}
Прайслисты не найдены. ${pricelistsCanWrite ? 'Создайте первый прайслист.' : ''}
</td>
</tr>
`;
@@ -947,7 +948,7 @@ function renderPricelists(pricelists) {
const statusText = pl.is_active ? 'Активен' : 'Неактивен';
let actions = `<a href="/pricelists/${pl.id}" class="text-blue-600 hover:text-blue-800 text-sm">Просмотр</a>`;
if (canWrite && pl.usage_count === 0) {
if (pricelistsCanWrite && pl.usage_count === 0) {
actions += ` <button onclick="deletePricelist(${pl.id})" class="text-red-600 hover:text-red-800 text-sm ml-2">Удалить</button>`;
}