<template>
    <div class="card">
        <div class="card-header">Basket Settings</div>
        <div class="card-body">

            <div class="mb-3">
                <label class="form-label">Position</label>
                <div class="row mb-2">
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">X:</div>
                            <div class="col"><input v-model="basket.pos.x" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">Y:</div>
                            <div class="col"><input v-model="basket.pos.y" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col">
                        <div class="row">
                            <div class="col-auto pt-1">Z:</div>
                            <div class="col"><input v-model="basket.pos.z" type="number" step="0.01" class="form-control form-control-sm"></div>
                        </div>
                    </div>
                    <div class="col-auto">
                        <button class="btn btn-sm btn-outline-secondary btn-danger me-1" @click="setPosition(n)" title="Set current position of nozzle">🞊</button>
                    </div>
                </div>
            </div>

            <div class="row mt-2">
                <div class="col">
                    <button :disabled="loading" class="btn btn-sm btn-outline-secondary" @click="applaySettings()">Applay settings</button>
                </div>
            </div>

        </div>

    </div>
</template>

<script>
    import machineState from '../js/machine_state.js'

    export default {
        mixins: [machineState],
        props: {
            basket: Object,
            machineState: Object,
            machinePos: Object,
            loading: Boolean
        },
        methods: {
            applaySettings() {
                this.$emit('applaySettings')
            },
            setPosition(number) {
                if (this.machineStateIsOK() == true) {
                    this.basket.pos.x = parseFloat(this.machinePos.x)
                    this.basket.pos.y = parseFloat(this.machinePos.y)
                    this.basket.pos.z = parseFloat(this.machinePos.z)
                }
            },
        }
    }
</script>

<style>

</style>
