Files
mixtape/zero.Backoffice.UI/app/components/ui-tab.vue
T

85 lines
1.3 KiB
Vue
Raw Normal View History

2020-04-08 13:52:45 +02:00
<template>
2021-12-23 14:39:00 +01:00
<section v-show="active && !hide" class="ui-tab" :aria-hidden="!active ? true : null" role="tabpanel">
2020-04-08 13:52:45 +02:00
<slot />
</section>
</template>
<script>
2021-12-07 15:59:29 +01:00
import { generateId } from '../utils';
2020-09-09 13:43:01 +02:00
2020-04-08 13:52:45 +02:00
export default {
name: 'uiTab',
props: {
label: {
2021-01-14 16:09:39 +01:00
type: String
2020-04-08 13:52:45 +02:00
},
count: {
type: Number,
default: 0
},
disabled: {
type: Boolean,
default: false
2021-12-14 14:21:48 +01:00
},
2021-12-21 13:58:48 +01:00
hide: {
2021-12-14 14:21:48 +01:00
type: Boolean,
default: false
2020-04-08 13:52:45 +02:00
}
},
data: () => ({
2020-09-09 13:43:01 +02:00
id: null,
2020-06-17 11:34:32 +02:00
loaded: false,
2020-09-09 13:43:01 +02:00
active: false,
2020-10-01 16:06:44 +02:00
hasErrors: false,
countOutput: 0
2020-04-08 13:52:45 +02:00
}),
2020-06-17 11:34:32 +02:00
watch: {
active(val)
{
this.loaded = true;
2020-10-01 16:06:44 +02:00
},
count(val)
{
this.countOutput = val;
2020-06-17 11:34:32 +02:00
}
},
2020-10-01 16:06:44 +02:00
created()
2020-04-08 13:52:45 +02:00
{
2021-12-07 01:11:18 +01:00
this.id = generateId();
2020-06-17 11:34:32 +02:00
this.loaded = this.active;
2020-10-01 16:06:44 +02:00
this.countOutput = this.count;
2021-12-07 01:11:18 +01:00
this.$parent.register(this);
},
unmounted()
{
this.$parent.unregister(this);
2020-04-08 13:52:45 +02:00
},
methods: {
2020-10-01 16:06:44 +02:00
setCount(count)
{
this.countOutput = count;
},
2020-09-09 13:43:01 +02:00
// set and display errors
setErrors(errors, append)
{
this.hasErrors = !!errors;
},
// clear errors and hide
clearErrors()
{
this.hasErrors = false;
}
2020-04-08 13:52:45 +02:00
}
}
</script>