All files / src/components/u-info-list.vue group.vue

68.42% Statements 13/19
7.69% Branches 2/26
33.33% Functions 1/3
72.22% Lines 13/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99      7x   7x     7x                                                                                                                                                                             7x 7x    
<template>
<div :class="$style.root">
    <div v-if="!parentVM || parentVM.showHead" :class="$style.head">
        <div :class="$style.title" vusion-slot-name="title" vusion-slot-name-edit="title">
            <slot name="title">
                {{ title }}
                <s-empty
                    v-if="!$slots.title
                        && !title
                        && $env.VUE_APP_DESIGNER
                        && !!$attrs['vusion-node-path']">
                </s-empty>
            </slot>
        </div>
        <div :class="$style.extra" vusion-slot-name="extra">
            <slot name="extra"></slot>
            <s-empty v-if="(!$slots.extra) && $env.VUE_APP_DESIGNER && !!$attrs['vusion-node-path']"></s-empty>
        </div>
    </div>
    <div :class="$style.body" vusion-slot-name="default">
        <s-empty v-if="(!$slots.default) && $env.VUE_APP_DESIGNER && !!$attrs['vusion-node-path']"></s-empty>
        <slot></slot>
    </div>
</div>
</template>
 
<script>
import MEmitter from '../m-emitter.vue';
import SEmpty from '../s-empty.vue';
 
export default {
    name: 'u-info-list-group',
    parentName: 'u-info-list',
    childName: 'u-info-list-item',
    components: {
        SEmpty,
    },
    mixins: [MEmitter],
    props: {
        title: String,
        column: [String, Number],
        labelSize: String,
        repeat: [String, Number],
    },
    data() {
        return { parentVM: undefined, itemVMs: [] };
    },
    created() {
        this.$on('add-item-vm', (itemVM) => {
            itemVM.groupVM = this;
            this.itemVMs.push(itemVM);
        });
        this.$on('remove-item-vm', (itemVM) => {
            itemVM.groupVM = undefined;
            this.itemVMs.splice(this.itemVMs.indexOf(itemVM), 1);
        });
        this.$dispatch(this.$options.parentName, 'add-group-vm', this);
    },
    destroyed() {
        this.$dispatch(this.$options.parentName, 'remove-group-vm', this);
    },
};
</script>
 
<style module>
.root:not(:last-child) {
    margin-bottom: 20px;
}
 
.head {
    padding: 6px 20px;
    margin: 0;
    line-height: 30px;
    color: var(--color-base);
    background-color: var(--background-color-light);
    border-bottom: 1px solid var(--border-color-base);
}
 
.head::after {
    content: '';
    clear: both;
}
 
.title {
    display: inline-block;
}
 
.extra {
    float: right;
}
 
.body {
    position: relative;
    display: table;
    table-layout: fixed;
    width: 100%;
}
</style>