Skip to content

Commit 5c5d128

Browse files
Поддержка изменений в ручке get (#93)
* добавил обработку параметра mark * добавлен ввод значения mark в выпадающем списке сортировок, обработка действия. * поддержаны обновления в TheSearchBar.vue * обновлены setParams и getParams для хранения состояния marks * api update --------- Co-authored-by: Илья Батуев <batuev.io18@physics.msu.ru>
1 parent e77a7eb commit 5c5d128

7 files changed

Lines changed: 70 additions & 22 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@eslint/eslintrc": "^3.3.0",
2626
"@eslint/js": "^9.22.0",
2727
"@mdi/font": "^7.4.47",
28-
"@profcomff/api-uilib": "^2025.4.15",
28+
"@profcomff/api-uilib": "^2025.10.15",
2929
"@types/node": "^22.13.10",
3030
"@typescript-eslint/eslint-plugin": "^8.26.1",
3131
"@typescript-eslint/parser": "^8.26.1",

pnpm-lock.yaml

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/TheLecturerSearchCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<!-- <div v-else class="text-caption-2">Нет предметов</div> -->
4040
<div>отзывы: {{ lecturer.comments?.length ?? '—' }}</div>
4141
<div>
42-
оценка: {{ lecturer.mark_general > 0 ? '+' : '' }}{{ lecturer.mark_general?.toFixed(2) ?? '—' }}
42+
оценка: {{ lecturer.mark_weighted > 0 ? '+' : '' }}{{ lecturer.mark_weighted.toFixed(2) ?? '—' }}
4343
</div>
4444
</div>
4545
</template>

src/components/TheSearchBar.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@
3939
@click:clear="subject = ''"
4040
@click.stop
4141
/>
42+
43+
<v-text-field
44+
v-model="mark"
45+
class="text-body-1 mb-2"
46+
label="Минимальный рейтинг от -2 до 2"
47+
type="number"
48+
min="-2"
49+
max="2"
50+
step="0.1"
51+
density="compact"
52+
variant="outlined"
53+
hide-details="auto"
54+
@click.stop
55+
/>
56+
4257
<v-row class="w-100 mb-2" no-gutters align="center">
4358
<v-select
4459
v-model="order"
@@ -100,6 +115,8 @@ const propsParent = defineProps({
100115
const searchQuery = defineModel('searchQuery', { type: String });
101116
const subject = defineModel('subject', { type: String });
102117
const order = defineModel('order', { type: String });
118+
const mark = defineModel('mark', { type: String });
119+
103120
const orderTypes = [
104121
'по релевантности',
105122
'по общей оценке',
@@ -130,6 +147,7 @@ function changeAscDesc() {
130147
emits('changed-asc-desc');
131148
}
132149
150+
133151
async function shareSearch() {
134152
/* eslint-disable @typescript-eslint/no-explicit-any */
135153
const params: Record<string, any> = {};
@@ -138,6 +156,7 @@ async function shareSearch() {
138156
if (order.value && order.value !== 'по релевантности') params.order = order.value;
139157
if (subject.value) params.subject = subject.value;
140158
if (propsParent.page > 1) params.page = propsParent.page;
159+
if (mark.value) params.mark = mark.value;
141160
142161
// Значение ascending обратное иконке (если иконка ascending, то значение false)
143162
const isAscending = iconAscDesc.value === 'mdi-sort-alphabetical-ascending';

src/pages/MainPage.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const subject = ref<Subject>(searchStore.subject);
2929
const order = ref(searchStore.order || 'по релевантности');
3030
const ascending = ref(searchStore.ascending);
3131
const page = ref(searchStore.page);
32+
const mark = ref(searchStore.mark || '');
3233
3334
// Вычисляем порядковые номера для компактного режима
3435
const lecturerRatings = computed(() => {
@@ -44,6 +45,7 @@ async function updateLecturersList() {
4445
subject: subject.value,
4546
orderBy: OrderFromText[order.value as keyof typeof OrderFromText] as Order,
4647
ascending: ascending.value,
48+
mark: mark.value || undefined,
4749
});
4850
}
4951
@@ -56,10 +58,11 @@ async function onSearchParamChange() {
5658
await updateLecturersList();
5759
}
5860
61+
watch(mark, onSearchParamChange);
5962
watch(page, updateLecturersList);
6063
6164
function toLecturerPage(id: number) {
62-
searchStore.setParams(name.value, subject.value, order.value, ascending.value, page.value);
65+
searchStore.setParams(name.value, subject.value, order.value, ascending.value, page.value, mark.value);
6366
router.push({ path: 'lecturer', query: { lecturer_id: id } });
6467
}
6568
@@ -74,6 +77,7 @@ function toggleViewMode() {
7477
v-model:search-query="name"
7578
v-model:subject="subject"
7679
v-model:order="order"
80+
v-model:mark="mark"
7781
:is-admin="userAdmin"
7882
:ascending="ascending"
7983
:page="page"

src/store/lecturerStore.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface FetchLecturersParams {
1212
subject?: string;
1313
orderBy?: Order;
1414
ascending?: boolean;
15+
mark?: string;
1516
}
1617

1718
export const useLecturerStore = defineStore('lecturer', () => {
@@ -23,16 +24,23 @@ export const useLecturerStore = defineStore('lecturer', () => {
2324
// Actions
2425
async function fetchLecturers(params: FetchLecturersParams) {
2526
const offset = (params.page - 1) * params.itemsPerPage;
27+
28+
// Создаем объект параметров запроса
29+
const queryParams: Record<string, unknown> = {
30+
limit: params.itemsPerPage,
31+
offset,
32+
info: ['comments'],
33+
order_by: `${params.ascending ? '+' : '-'}${params.orderBy ?? 'mark_general'}`,
34+
};
35+
36+
// Добавляем опциональные параметры
37+
if (params.name) queryParams.name = params.name;
38+
if (params.subject) queryParams.subject = params.subject;
39+
if (params.mark) queryParams.mark = params.mark;
40+
2641
const res = await apiClient.GET('/rating/lecturer', {
2742
params: {
28-
query: {
29-
limit: params.itemsPerPage,
30-
name: params.name,
31-
offset,
32-
info: ['comments'],
33-
subject: params.subject,
34-
order_by: `${params.ascending ? '+' : '-'}${params.orderBy ?? 'mark_general'}`,
35-
},
43+
query: queryParams,
3644
},
3745
});
3846

src/store/searchStore.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,33 @@ export const useSearchStore = defineStore('search', () => {
88
const order = ref<string>('по общей оценке');
99
const ascending = ref<boolean>(false);
1010
const page = ref<number>(1);
11+
const mark = ref<string>('');
1112

1213
const getParams = () => {
13-
return name.value, subject.value, order.value, ascending.value, page.value;
14+
return {
15+
name: name.value,
16+
subject: subject.value,
17+
order: order.value,
18+
ascending: ascending.value,
19+
page: page.value,
20+
mark: mark.value,
21+
};
1422
};
1523

16-
const setParams = (oldName: string, oldSubject: Subject, oldOrder: string, oldAsc: boolean, oldPage: number) => {
24+
const setParams = (
25+
oldName: string,
26+
oldSubject: Subject,
27+
oldOrder: string,
28+
oldAsc: boolean,
29+
oldPage: number,
30+
oldMark?: string,
31+
) => {
1732
name.value = oldName;
1833
subject.value = oldSubject;
1934
order.value = oldOrder;
2035
ascending.value = oldAsc;
2136
page.value = oldPage;
37+
mark.value = oldMark || '';
2238
};
2339

2440
return {
@@ -27,6 +43,7 @@ export const useSearchStore = defineStore('search', () => {
2743
order,
2844
ascending,
2945
page,
46+
mark,
3047

3148
getParams,
3249
setParams,

0 commit comments

Comments
 (0)