Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | 1x 38x 10x 10x 10x 10x 6x 6x 4x 4x 13x 8x 5x | // @ts-check import { filter, first, get, invoke, isEmpty } from "lodash"; import { mixinMaker } from "../utils"; const component = mixinMaker({ /** * @return {{ * warnings: { [id: string]: any }, * errors: { [id: string]: any } * }} */ data: () => ({ warnings: {}, errors: {} }), computed: { /** * @return {boolean} */ hasErrors() { return !(isEmpty(this.warnings) && isEmpty(this.errors)); } }, methods: { async checkValidity() { await this.$nextTick(); const errors = filter(invoke(this.$el, "querySelectorAll", "input"), function(node) { return !node.checkValidity(); }); if (isEmpty(errors)) { this.removeError("b-checkValidity"); return true; } else { this.addError("b-checkValidity", get(first(errors), "validationMessage", "invalid value")); return false; } }, /** * @param {string} id * @param {string} message */ addError(id, message) { this.$set(this.errors, id, message); }, /** * @param {string} id */ removeError(id) { this.$delete(this.errors, id); }, /** * @param {string} id * @param {string} message */ addWarning(id, message) { this.$set(this.warnings, id, message); }, /** * @param {string} id */ removeWarning(id) { this.$delete(this.warnings, id); } } }); export default component; |