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