UNPKG

cheetah-framework

Version:

Cheetah Framework JS used in all our applications

58 lines (48 loc) 1.37 kB
import Criterion from '@cheetah/models/Criterion' import FormErrorHelper from '@cheetah/form/FormErrorHelper' export default { mixins: [FormErrorHelper], props: { fields: { type: Array, required: true }, criterion: { type: Criterion, required: true }, selectedField: { type: Object, required: true }, summary: Boolean }, methods: { getValidationErrorMessage (errorCode, translateVariable = {}, count = null) { const errorKey = 'query_builder.validations.' + errorCode if (count !== null) { return this.$tc(errorKey, count, translateVariable) } return this.$t(errorKey, translateVariable) }, /** * Format value into a formatted list as a string * * @param {string|string[]} value * @return {string} */ formatArrayableSummary (value) { const values = _.isArray(value) ? value : _.trim(value, ' ,').split(/[\s,]*,[\s,]*/g) return _.reduce(values, (valueString, value, index) => { const formattedValue = `<i>${_.escape(value)}</i>` if (index === 0) { return formattedValue } if (index === values.length - 1) { return `${valueString} ${this.$t('or')} ${formattedValue}` } return `${valueString}, ${formattedValue}` }, '') } } }