Skip to content

Commit 41f3031

Browse files
committed
feat: added buttons
1 parent 7436a6a commit 41f3031

3 files changed

Lines changed: 61 additions & 4 deletions

File tree

components/ClassesList.vue

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-row justify="center" align="center">
3-
<v-col cols="12" sm="12" md="10" lg="8">
3+
<v-col cols="12" sm="12" md="12" lg="8">
44
<v-card :disabled="loading">
55
<v-card-title>
66
<v-text-field
@@ -17,27 +17,65 @@
1717
:items="classes"
1818
item-key="crn"
1919
sort-by="semster_index"
20-
:dense="true"
20+
:dense="false"
2121
:loading="loading"
2222
group-by="semster_index"
2323
class="elevation-1"
2424
:search="search"
2525
show-group-by
26-
></v-data-table>
26+
>
27+
<template v-slot:item.days="{ item }">
28+
<v-chip v-for="day in item.days" :key="day">
29+
{{ daysNames[day] }}
30+
</v-chip>
31+
</template>
32+
33+
<template v-slot:item.button="{ item }">
34+
<v-tooltip top :color="item.buttonOptions.color">
35+
<template v-slot:activator="{ on, attrs }">
36+
<v-btn
37+
elevation="2"
38+
:color="item.buttonOptions.color"
39+
:disabled="item.buttonOptions.disabled"
40+
v-bind="attrs"
41+
v-on="on"
42+
fab
43+
small
44+
@click="$emit('class:action', item)"
45+
>
46+
<v-icon> mdi-plus </v-icon>
47+
</v-btn>
48+
</template>
49+
<div v-for="tooltip in item.buttonOptions.tooltips">
50+
{{ tooltip }}
51+
</div>
52+
</v-tooltip>
53+
</template>
54+
</v-data-table>
2755
</v-card>
2856
</v-col>
2957
</v-row>
3058
</template>
3159

3260
<script>
3361
export default {
62+
emits: ['class:action'],
3463
props: {
3564
classes: { type: Array, default: {} },
3665
loading: { type: Boolean, default: false },
3766
},
3867
data() {
3968
return {
4069
search: '',
70+
daysNames: {
71+
1: 'Sun',
72+
2: 'Mon',
73+
3: 'Tue',
74+
4: 'Wed',
75+
5: 'Thu',
76+
6: 'Fri',
77+
7: 'Sat',
78+
},
4179
headers: [
4280
{ text: 'Course Name', align: 'start', value: 'name' },
4381
{ text: 'Code', value: 'code', align: 'right', groupable: false },
@@ -47,6 +85,7 @@ export default {
4785
{ text: 'time', value: 'time', align: 'right', groupable: false },
4886
{ text: 'Instructor', value: 'instructor', align: 'right' },
4987
{ text: 'Semster', value: 'semster_index', align: 'right' },
88+
{ text: 'button', value: 'button', align: 'right', groupable: false },
5089
],
5190
}
5291
},

logic/classes.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// too lazy to add types ;)
2+
export function buttonOptions(todo: any) {
3+
let buttonOptions = {
4+
disabled: false,
5+
color: 'success',
6+
tooltips: ['Hello!', 'Error 2'],
7+
}
8+
return { ...todo, buttonOptions }
9+
}
10+
export function findConflicts(todo: any) {
11+
return todo
12+
}

pages/index.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<script>
1818
const axios = require('axios')
19+
import { buttonOptions, findConflicts } from '@/logic/classes'
1920
2021
export default {
2122
data() {
@@ -58,9 +59,14 @@ export default {
5859
},
5960
computed: {
6061
filteredClasses() {
61-
return this.rawClasses.filter((c) =>
62+
// selected semster (from <ClassesFilters/>
63+
let filtered = this.rawClasses.filter((c) =>
6264
this.selectedSemsters.includes(c.semster_index)
6365
)
66+
filtered = filtered.map(findConflicts)
67+
filtered = filtered.map(buttonOptions)
68+
69+
return filtered
6470
},
6571
},
6672
methods: {

0 commit comments

Comments
 (0)