-
Notifications
You must be signed in to change notification settings - Fork 246
Expand file tree
/
Copy pathTaskInterstitial.vue
More file actions
106 lines (102 loc) · 2.31 KB
/
TaskInterstitial.vue
File metadata and controls
106 lines (102 loc) · 2.31 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<template>
<div>
<screen-select
v-if="allowInterstitial"
v-model="screen"
name="interstitialScreen"
:label="$t('Screen Interstitial')"
:required="true"
:helper="$t('What Screen Should Be Used For Rendering This Interstitial')"
:params="parameters"
default-key="interstitial"
/>
</div>
</template>
<script>
import { get } from "lodash";
import ScreenSelect from "./ScreenSelect.vue";
export default {
components: { ScreenSelect },
props: {
label: {
type: String,
default: "",
},
helper: {
type: String,
default: "",
},
enabledByDefault: {
type: Boolean,
default: false,
},
},
data() {
return {
screen: null,
loading: false,
error: "",
parameters: {
type: "DISPLAY",
},
isDisabled: false,
};
},
computed: {
/**
* Get the value of the edited property
*/
allowInterstitial: {
get() {
const { node } = this;
// Get the value of allowInterstitial or set it to true if it hasn't been defined yet.
const value = get(node, "allowInterstitial", this.enabledByDefault);
this.screen = get(node, "interstitialScreenRef");
return value;
},
/**
* Update allowInterstitial property
*/
set(value) {
this.$set(this.node, "allowInterstitial", value);
},
},
node() {
return this.$root.$children[0].$refs.modeler.highlightedNode.definition;
},
},
watch: {
screen: {
handler(value) {
this.$set(this.node, "interstitialScreenRef", value);
},
},
},
created() {
// Listen for elementDestination interstitial event
this.$root.$on("handle-task-interstitial", this.handleInterstitial);
},
mounted() {
if (!("allowInterstitial" in this.node)) {
this.$set(this.node, "allowInterstitial", this.enabledByDefault);
}
},
methods: {
/**
* Handle interstitial event
*
* @param {Object} { nodeId, isDisabled }
*/
handleInterstitial({ nodeId, show }) {
if (nodeId !== this.node.id) {
return;
}
if (show) {
this.$set(this.node, "allowInterstitial", true);
} else {
this.$set(this.node, "allowInterstitial", false);
}
},
},
};
</script>