# Checkbox Bone

# Introducción

Componente lógico.

# Código fuente

<script>
import { separateValidPositions } from '../../../mixins/comportamientoPositionCheck'
const validPositions=['append', 'label', 'message', 'prepend']
const props = {
    falseValue: {
      type: undefined,
      default: false
    },
    required: {
      type: Boolean,
      default: false
    },
    pattern: {
      type: String,
      default: undefined
    },
    messages: {
      type: String,
      default: ''
    },
    id_resolver: {
      type: String,
    },
    label: {
      type: String,
      default: ''
    },
    linked: {
      type: Boolean,
      default: false
    },
    comportamientos:{type: Array, required: false}
  }
import { normalizeProps, assignCamelToSnake } from '../../../helpers/propsGenerator';
const mergedProps = normalizeProps(props)
import {checkboxComponentName} from '../../../constants'
export default {
  name: checkboxComponentName+'Bone',
  props: mergedProps,
  data() {
    return {
      usedPosition:[],
      structureError: false
    }
  },
  computed: {
    manageMessage() {
      if (this.messages)
        return this.messages
      else return ''
    }
  },
  created() {
    assignCamelToSnake(mergedProps, this)
  },
  mounted(){
    this.structureError = this.$propError(props, this.$props, checkboxComponentName)
    if(this.structureError){
      this.$iclstore.commit('updateSnack', {text: 'Ha ocurrido un error al cargar algunos campos del formulario', active: true, color:'warning'})
    }
    this.usedPosition = separateValidPositions(this.comportamientos, validPositions, checkboxComponentName,
    this.$id_resolver, this.$logError) // Valida las posiciones válidas para comportamientos
  },
  render() {
    if(this.structureError){
      return
    }
    return this.$scopedSlots.default({
      falseValue: this.falseValue,
      rules: this.$rulesGenerator(this.required, this.pattern),
      manageMessage: this.manageMessage,
      label: this.label,
      linked: this.linked,
      comportamientos: this.comportamientos,
      comportamientosPositions: this.usedPosition,
      id_resolver: this.id_resolver
    })
  },
}
</script>
Last Updated: 4/5/2024, 4:52:19 PM