-
Notifications
You must be signed in to change notification settings - Fork 37
/
HandlesFieldValue.js
45 lines (36 loc) · 992 Bytes
/
HandlesFieldValue.js
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
export default {
data() {
return {
guard: this.field.default_impersonator_guard,
guards: this.field.impersonator_guards,
openModal: false
};
},
created() {
document.addEventListener("keydown", this.handleKeyDown);
},
destroyed() {
document.removeEventListener("keydown", this.handleKeyDown);
},
methods: {
handleKeyDown(e) {
if (e.key === this.field.key_down) {
this.onClick();
}
},
onClick() {
if (this.field.enable_multi_guard === false) {
this.openUrl();
} else {
this.openModal = true;
}
},
openUrl() {
this.openModal = false;
window.open(
`/nova-impersonate/users/${this.field.id}/${this.guard}?redirect_to=${this.field.redirect_to}`,
"_self"
);
},
},
}