-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Expression.vue
84 lines (74 loc) · 1.98 KB
/
Expression.vue
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
<template>
<grid columns="4" v-infoView="{ title: iVTitle, body: iVBody, id: iVID }">
<c span="1..">
<grid columns="4">
<c span="2+2">
<Textarea v-model="expression" @change="updateExpression" />
</c>
</grid>
</c>
</grid>
</template>
<script>
export default {
props: {
inputId: {
type: String,
required: true
}
},
data() {
return {
iVTitle: "Expression",
iVBody:
"Expressions allow assigned input values to be shaped with JavaScript synax and math. Multiplication, division, custom intensity curves - whatever goes. `value` is the incoming number, want to make everything 3 times as punchy? `value * 3`. Need to soften things a little? `value / 2`. More examples can be found on modV's website under Guides, Expression.",
iVID: "Expression",
expression: "value",
expressionId: null
};
},
created() {
this.restoreExpressionValues();
},
methods: {
async updateExpression() {
const { inputId, expression, expressionId } = this;
if (expressionId) {
this.expressionId = await this.$modV.store.dispatch(
"expressions/update",
{
id: expressionId,
expression
}
);
} else {
this.expressionId = await this.$modV.store.dispatch(
"expressions/create",
{
expression,
inputId
}
);
}
},
restoreExpressionValues(inputId = this.inputId) {
const expressionAssignment = this.$modV.store.getters[
"expressions/getByInputId"
](inputId);
if (expressionAssignment) {
this.expression = expressionAssignment.expression;
this.expressionId = expressionAssignment.id;
} else {
this.expression = "value";
this.expressionId = null;
}
}
},
watch: {
inputId(inputId) {
this.restoreExpressionValues(inputId);
}
}
};
</script>
<style scoped></style>