/**
 * set row height
 */
<template>
    <Modal v-model="show" title="设置行高" @on-ok="ok" @on-cancel="cancel">
        <Row>
            <Col span="6">行高:</Col>
            <Col span="18"><Input v-model="height"></Input></Col>
        </Row>
    </Modal>
</template>

<script>
    import Hub from '../../../Hub.js'
    import { setDirty } from '../../utils/Utils.js';
    import { mapState, mapActions } from 'vuex';
    
    export default {
        name: 'SetRowHeight',
        data() {
            return {
                show: false,
                height: 0
            };
        },
        computed: {
            ...mapState(['context', 'currRowHeight'])
        },
        methods: {
            ok() {
                const hot = this.context.hot;
                
                const selected = hot.getSelected()[0];
                const startRow = selected[0];
                const rowHeights = hot.getSettings().rowHeights;

                rowHeights.splice(startRow, 1, this.height);
                hot.updateSettings({
                    rowHeights: rowHeights,
                    manualRowResize: rowHeights
                });

                this.show = false 
            },
            cancel() {
                this.show = false;
            }
        },
        created() {
            const that = this;
            Hub.$on('show_set_row_height_dialog', () => {
                that.show = true;
                that.height = that.currRowHeight;
            });
        }
    };
</script>

<style>
</style>
