<script>
import fields from '@yootheme/fields';

export default {
    name: 'FormControlSelect',

    extends: fields.components.FieldYooessentialsSelectDropdown,

    inject: {
        $node: {
            default: null,
        },
        Form: {
            from: 'EssentialsForm',
        },
    },

    computed: {
        status() {
            return !this.value || this.fields.some((f) => f.props?.control_name === this.value);
        },

        fields() {
            return this.Form.getFields()
                .filter((field) => field?.type.name.match(this.field?.filterType))
                .filter((field) => field?.props.control_name);
        },
    },

    created() {
        this.entries = this.fields.map((field) => ({
            value: field.props.control_name,
            text: field.props.control_name,
        }));
    },
};
</script>
