fix [P-276]: merge

This commit is contained in:
Denis Voinovich committed 2025-06-25 12:10:31 +03:00
1 parent 6dc007aa1f
commit 03ea4a8e2f
1 file changed
+38 -10
+38 -10
View File
@@ -223,7 +223,8 @@ export default {
pagecounter();
const accountStore = useAccountStore();
const router = useRouter();
const activeTab = ref(0);
const savedTab = localStorage.getItem('testHomePage_activeTab');
const activeTab = ref(savedTab ? parseInt(savedTab) : 0);
const currentTest = ref('');
const getAllTests = ref([]);
const deleteDialog = ref(false);
@@ -239,13 +240,38 @@ export default {
color: 'error'
});
// Функция для показа уведомлений
const showNotification = (text, color = 'error') => {
snackbar.value.text = text;
snackbar.value.color = color;
snackbar.value.show = true;
};
const updateCurrentTestCount = () => {
if (activeTab.value === 0) {
currentTest.value = getAllTests.value.filter(test =>
test.is_active &&
test.is_passed !== true &&
test.attemps_number > 0
).length;
}
};
const getAssignedTestsCount = () => {
axiosApiInstance
.get('/api/tests/gettests?status=active')
.then((resp) => {
const assignedTests = resp.data.filter(test =>
test.is_active &&
test.is_passed !== true &&
test.attemps_number > 0
);
currentTest.value = assignedTests.length;
})
.catch(() => {
currentTest.value = 0;
});
};
const getTestById = () => {
const status = activeTab.value === 2 ? '' :
activeTab.value === 0 ? '?status=active' :
@@ -258,26 +284,29 @@ export default {
})
.finally(() => {
if (activeTab.value === 0) {
currentTest.value = getAllTests.value.filter(test =>
test.is_active &&
test.is_passed !== true &&
test.attemps_number > 0
).length;
updateCurrentTestCount();
} else {
getAssignedTestsCount();
}
});
};
getTestById();
if (activeTab.value !== 0) {
getAssignedTestsCount();
}
watch(
() => activeTab.value,
() => {
(newTab) => {
localStorage.setItem('testHomePage_activeTab', newTab.toString());
getTestById();
},
);
const tabs = computed(() => [
{ value: 0, title: `Назначенные (${currentTest.value})` },
{ value: 0, title: `Назначенные${currentTest.value !== '' ? ` (${currentTest.value})` : ''}` },
{ value: 1, title: 'Завершенные' },
{ value: 2, title: 'Каталог' },
...(accountStore.user.is_staff ? [{ value: 3, title: 'Создать новый тест' }] : []),
@@ -363,7 +392,6 @@ export default {
const assignmentIds = activeAssignments.map(assignment => assignment.id);
await deleteTestingRecord(assignmentIds);
// Обновляем данные диалога после удаления всех назначений
await openAddDialog(selectedTestId.value);
showNotification('Все назначения успешно отменены', 'green');