feat: init directive
This commit is contained in:
parent
dcbaa7529d
commit
3948b26f6b
|
@ -0,0 +1,17 @@
|
||||||
|
export default {
|
||||||
|
mounted: function (el, binding, { ctx }) {
|
||||||
|
const { innerText, localName } = el;
|
||||||
|
const { type, attrs } = ctx;
|
||||||
|
|
||||||
|
el.setAttribute(
|
||||||
|
'data-cy',
|
||||||
|
`${attrs?.label ?? innerText}_${type.name.replace('Q', '').toLowerCase()}`
|
||||||
|
);
|
||||||
|
console.error('dataCy', el.getAttribute('data-cy'));
|
||||||
|
},
|
||||||
|
unmounted: function (el) {
|
||||||
|
if (el._handleKeydown) {
|
||||||
|
window.removeEventListener('keydown', el._handleKeydown);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
|
@ -3,12 +3,14 @@ import qFormMixin from './qformMixin';
|
||||||
import keyShortcut from './keyShortcut';
|
import keyShortcut from './keyShortcut';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
import { CanceledError } from 'axios';
|
import { CanceledError } from 'axios';
|
||||||
|
import dataCy from './dataCy';
|
||||||
|
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
export default boot(({ app }) => {
|
export default boot(({ app }) => {
|
||||||
app.mixin(qFormMixin);
|
app.mixin(qFormMixin);
|
||||||
app.directive('shortcut', keyShortcut);
|
app.directive('shortcut', keyShortcut);
|
||||||
|
app.directive('dataCy', dataCy);
|
||||||
app.config.errorHandler = (error) => {
|
app.config.errorHandler = (error) => {
|
||||||
let message;
|
let message;
|
||||||
const response = error.response;
|
const response = error.response;
|
||||||
|
|
Loading…
Reference in New Issue