/
rule-container.mixin.js
64 lines (53 loc) · 1.4 KB
/
rule-container.mixin.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
const { Mixin } = Shopware;
Mixin.register('ruleContainer', {
inject: [
'conditionDataProviderService',
'createCondition',
'insertNodeIntoTree',
'removeNodeFromTree',
'childAssociationField'
],
props: {
condition: {
type: Object,
required: true
},
parentCondition: {
type: Object,
required: false,
default: null
},
level: {
type: Number,
required: true
},
disabled: {
type: Boolean,
required: false,
default: false
}
},
computed: {
containerRowClass() {
const classes = {
'is--disabled': this.disabled
};
const level = this.level % 2 ? 'container-condition-level__is--odd' : 'container-condition-level__is--even';
classes[level] = true;
return classes;
},
nextPosition() {
if (this.condition[this.childAssociationField] && this.condition[this.childAssociationField].length > 0) {
return this.condition[this.childAssociationField].length;
}
return 0;
}
},
watch: {
nextPosition() {
if (this.nextPosition === 0) {
this.onAddPlaceholder();
}
}
}
});