Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@eslint/eslintrc": "^3.3.0",
"@eslint/js": "^9.22.0",
"@mdi/font": "^7.4.47",
"@profcomff/api-uilib": "^2025.4.15",
"@profcomff/api-uilib": "^2025.10.15",
"@types/node": "^22.13.10",
"@typescript-eslint/eslint-plugin": "^8.26.1",
"@typescript-eslint/parser": "^8.26.1",
Expand Down
18 changes: 9 additions & 9 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/components/TheLecturerSearchCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<!-- <div v-else class="text-caption-2">Нет предметов</div> -->
<div>отзывы: {{ lecturer.comments?.length ?? '—' }}</div>
<div>
оценка: {{ lecturer.mark_general > 0 ? '+' : '' }}{{ lecturer.mark_general?.toFixed(2) ?? '—' }}
оценка: {{ lecturer.mark_weighted > 0 ? '+' : '' }}{{ lecturer.mark_weighted.toFixed(2) ?? '—' }}
</div>
</div>
</template>
Expand Down
19 changes: 19 additions & 0 deletions src/components/TheSearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@
@click:clear="subject = ''"
@click.stop
/>

<v-text-field
v-model="mark"
class="text-body-1 mb-2"
label="Минимальный рейтинг от -2 до 2"
type="number"
min="-2"
max="2"
step="0.1"
density="compact"
variant="outlined"
hide-details="auto"
@click.stop
/>

<v-row class="w-100 mb-2" no-gutters align="center">
<v-select
v-model="order"
Expand Down Expand Up @@ -100,6 +115,8 @@ const propsParent = defineProps({
const searchQuery = defineModel('searchQuery', { type: String });
const subject = defineModel('subject', { type: String });
const order = defineModel('order', { type: String });
const mark = defineModel('mark', { type: String });

const orderTypes = [
'по релевантности',
'по общей оценке',
Expand Down Expand Up @@ -130,6 +147,7 @@ function changeAscDesc() {
emits('changed-asc-desc');
}


async function shareSearch() {
/* eslint-disable @typescript-eslint/no-explicit-any */
const params: Record<string, any> = {};
Expand All @@ -138,6 +156,7 @@ async function shareSearch() {
if (order.value && order.value !== 'по релевантности') params.order = order.value;
if (subject.value) params.subject = subject.value;
if (propsParent.page > 1) params.page = propsParent.page;
if (mark.value) params.mark = mark.value;

// Значение ascending обратное иконке (если иконка ascending, то значение false)
const isAscending = iconAscDesc.value === 'mdi-sort-alphabetical-ascending';
Expand Down
6 changes: 5 additions & 1 deletion src/pages/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const subject = ref<Subject>(searchStore.subject);
const order = ref(searchStore.order || 'по релевантности');
const ascending = ref(searchStore.ascending);
const page = ref(searchStore.page);
const mark = ref(searchStore.mark || '');

// Вычисляем порядковые номера для компактного режима
const lecturerRatings = computed(() => {
Expand All @@ -44,6 +45,7 @@ async function updateLecturersList() {
subject: subject.value,
orderBy: OrderFromText[order.value as keyof typeof OrderFromText] as Order,
ascending: ascending.value,
mark: mark.value || undefined,
});
}

Expand All @@ -56,10 +58,11 @@ async function onSearchParamChange() {
await updateLecturersList();
}

watch(mark, onSearchParamChange);
watch(page, updateLecturersList);

function toLecturerPage(id: number) {
searchStore.setParams(name.value, subject.value, order.value, ascending.value, page.value);
searchStore.setParams(name.value, subject.value, order.value, ascending.value, page.value, mark.value);
router.push({ path: 'lecturer', query: { lecturer_id: id } });
}

Expand All @@ -74,6 +77,7 @@ function toggleViewMode() {
v-model:search-query="name"
v-model:subject="subject"
v-model:order="order"
v-model:mark="mark"
:is-admin="userAdmin"
:ascending="ascending"
:page="page"
Expand Down
24 changes: 16 additions & 8 deletions src/store/lecturerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface FetchLecturersParams {
subject?: string;
orderBy?: Order;
ascending?: boolean;
mark?: string;
}

export const useLecturerStore = defineStore('lecturer', () => {
Expand All @@ -23,16 +24,23 @@ export const useLecturerStore = defineStore('lecturer', () => {
// Actions
async function fetchLecturers(params: FetchLecturersParams) {
const offset = (params.page - 1) * params.itemsPerPage;

// Создаем объект параметров запроса
const queryParams: Record<string, unknown> = {
limit: params.itemsPerPage,
offset,
info: ['comments'],
order_by: `${params.ascending ? '+' : '-'}${params.orderBy ?? 'mark_general'}`,
};

// Добавляем опциональные параметры
if (params.name) queryParams.name = params.name;
if (params.subject) queryParams.subject = params.subject;
if (params.mark) queryParams.mark = params.mark;

const res = await apiClient.GET('/rating/lecturer', {
params: {
query: {
limit: params.itemsPerPage,
name: params.name,
offset,
info: ['comments'],
subject: params.subject,
order_by: `${params.ascending ? '+' : '-'}${params.orderBy ?? 'mark_general'}`,
},
query: queryParams,
},
});

Expand Down
21 changes: 19 additions & 2 deletions src/store/searchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,33 @@ export const useSearchStore = defineStore('search', () => {
const order = ref<string>('по общей оценке');
const ascending = ref<boolean>(false);
const page = ref<number>(1);
const mark = ref<string>('');

const getParams = () => {
return name.value, subject.value, order.value, ascending.value, page.value;
return {
name: name.value,
subject: subject.value,
order: order.value,
ascending: ascending.value,
page: page.value,
mark: mark.value,
};
};

const setParams = (oldName: string, oldSubject: Subject, oldOrder: string, oldAsc: boolean, oldPage: number) => {
const setParams = (
oldName: string,
oldSubject: Subject,
oldOrder: string,
oldAsc: boolean,
oldPage: number,
oldMark?: string,
) => {
name.value = oldName;
subject.value = oldSubject;
order.value = oldOrder;
ascending.value = oldAsc;
page.value = oldPage;
mark.value = oldMark || '';
};

return {
Expand All @@ -27,6 +43,7 @@ export const useSearchStore = defineStore('search', () => {
order,
ascending,
page,
mark,

getParams,
setParams,
Expand Down