<template>
    <Dialog header="Define searcher"
            :visible.sync="showDialog"
            :maximizable="true"
            :modal="true"
            :block-scroll="true"
            :style="{width: '95vw', height: '95vh',}"
            :contentStyle="{overflow: 'visible'}"
            :baseZIndex="2014"
            id="define-searcher"
            ref="define-searcher">

        <create-searcher :is-defining="true"
                         :defined-searcher="text"
                         @defined="onDefined">
        </create-searcher>
    </Dialog>
</template>

<script lang="ts">
import {Component, Prop, Vue, Watch} from "vue-property-decorator";
import CreateSearcher from './Create';

@Component({
    components: {
        CreateSearcher,
    },
})
export default class DefineSearcher extends Vue {
    private showDialog: boolean = false;

    @Prop({default: ''})
    public readonly text!: string;

    private onDefined(searcher: Object) {
        this.$emit('done', searcher);
    }

    @Watch('showDialog')
    showDialogChanged() {
        if ( ! this.showDialog) {
            this.$emit('close');
        }
    }

    mounted() {
        this.showDialog = true;
    }
};
</script>

<style lang="sass">
    #define-searcher
        .p-dialog-content
            min-height: 90%
</style>
