Skip to content

Commit 5f40942

Browse files
committed
🎨 Adds debug mode to BaseTable
1 parent 01781ec commit 5f40942

File tree

3 files changed

+41
-24
lines changed

3 files changed

+41
-24
lines changed

src/components/UI/BaseTable.vue

+34-23
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,32 @@
2020
<fa-icon v-if="sort === head && type === 1" icon="caret-up"></fa-icon>
2121
<fa-icon v-else-if="sort === head" icon="caret-down"></fa-icon>
2222
</th>
23-
<th v-if="editable || deletable || downloadable"></th>
23+
<th v-if="downloadable"></th>
24+
<th v-if="editable"></th>
25+
<th v-if="deletable"></th>
2426
</tr>
2527
</thead>
2628
<tbody>
2729
<tr v-for="(row, i) in sortedData" :key="i">
28-
<td v-for="head in headers" :key="head + i">
30+
<td
31+
v-for="head in headers"
32+
:key="head + i"
33+
:class="typeof row[head] === 'number' ? 'text-center' : ''"
34+
>
2935
{{ row[head] ? row[head] : row[head] === 0 ? 0 : '-' }}
3036
</td>
31-
<td v-if="editable || deletable || downloadable" class="text-center">
32-
<base-button
33-
v-if="downloadable"
34-
type="outline-success btn-sm mx-1"
35-
@click="download(row[downloadable])"
36-
>
37+
<td v-if="downloadable" class="text-center p-1 py-2">
38+
<base-button type="outline-success btn-sm" @click="download(row[downloadable])">
3739
<fa-icon icon="download"></fa-icon>
3840
</base-button>
39-
<base-button
40-
v-if="editable"
41-
type="outline-warning btn-sm mx-1"
42-
@click="edit(row[editable])"
43-
>
41+
</td>
42+
<td v-if="editable" class="text-center p-1 py-2">
43+
<base-button type="outline-warning btn-sm" @click="edit(row[editable])">
4444
<fa-icon icon="edit"></fa-icon>
4545
</base-button>
46-
<base-button
47-
v-if="deletable"
48-
type="outline-danger btn-sm"
49-
@click="delId = row[deletable]"
50-
>
46+
</td>
47+
<td v-if="deletable" class="text-center p-1 py-2">
48+
<base-button type="outline-danger btn-sm" @click="delId = row[deletable]">
5149
<fa-icon :icon="['far', 'trash-alt']"></fa-icon>
5250
</base-button>
5351
</td>
@@ -59,7 +57,9 @@
5957
</template>
6058

6159
<script>
62-
// TODO szűrő, és akár rendezés nyilakkal
60+
//TODO szűrő
61+
//TODO átnevezés
62+
//TODO előnézet
6363
import { computed, ref } from 'vue';
6464
export default {
6565
name: 'BaseTable',
@@ -85,17 +85,17 @@ export default {
8585
getHeaders();
8686
8787
function edit(id) {
88-
context.emit('edit', id);
8988
if (props.debug) console.log('Szerkesztés: ', id);
89+
context.emit('edit', id);
9090
}
9191
function del() {
92-
context.emit('delete', delId.value);
9392
if (props.debug) console.log('Törlés: ', delId.value);
93+
context.emit('delete', delId.value);
9494
delId.value = 0;
9595
}
9696
function download(id) {
97-
context.emit('download', id);
9897
if (props.debug) console.log('Letöltés: ', id);
98+
context.emit('download', id);
9999
}
100100
101101
const sortedData = computed(() => {
@@ -124,7 +124,18 @@ export default {
124124
} else type.value = type.value === 1 ? -1 : 1;
125125
}
126126
127-
return { headers, getHeaders, edit, del, delId, sort, setSort, type, sortedData, download };
127+
return {
128+
headers,
129+
getHeaders,
130+
edit,
131+
del,
132+
delId,
133+
sort,
134+
setSort,
135+
type,
136+
sortedData,
137+
download,
138+
};
128139
},
129140
watch: {
130141
data() {

src/config/fontawesome.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
faCaretDown,
2020
faDownload,
2121
faFile,
22+
faPen,
2223
} from '@fortawesome/free-solid-svg-icons';
2324

2425
library.add(
@@ -43,6 +44,7 @@ library.add(
4344
faCaretDown,
4445
faDownload,
4546
faFile,
47+
faPen,
4648
);
4749

4850
// $ npm i --save @fortawesome/free-brands-svg-icons //. fab

src/views/File.vue

+5-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ export default {
6161
.get(`/files/${id}`, { responseType: 'arraybuffer' })
6262
.then(res => {
6363
forceDownload(res.data, item.Név);
64+
files.value = files.value.map(file => {
65+
if (file.id === id) file['Letöltések száma']++;
66+
return file;
67+
});
6468
})
6569
.catch(err => {
6670
console.log(err.response.data);
@@ -78,7 +82,7 @@ export default {
7882
function getAll() {
7983
axios.get('/files').then(({ data }) => {
8084
files.value = data.map(d => {
81-
return { Név: d.name, id: d.id };
85+
return { id: d.id, Név: d.name, 'Letöltések száma': d.downloads };
8286
});
8387
});
8488
}

0 commit comments

Comments
 (0)