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