|
1 | 1 | <template>
|
2 |
| - <PanelItem :index="index" :field="field"> |
3 |
| - <template #value> |
4 |
| - <div v-for="(group, index) in orderedGroups"> |
5 |
| - <detail-nova-flexible-content-group |
6 |
| - :index="index" |
7 |
| - :last="(index === groups.length - 1)" |
8 |
| - :group="group" |
9 |
| - :key="group.key" |
10 |
| - :resource="resource" |
11 |
| - :resourceName="resourceName" |
12 |
| - :resourceId="resourceId" |
13 |
| - :attribute="field.attribute" |
14 |
| - /> |
15 |
| - </div> |
16 |
| - </template> |
17 |
| - </PanelItem> |
| 2 | + <PanelItem :index="index" :field="field"> |
| 3 | + <template #value> |
| 4 | + <div v-for="(group, index) in orderedGroups"> |
| 5 | + <detail-nova-flexible-content-group |
| 6 | + :index="index" |
| 7 | + :last="index === groups.length - 1" |
| 8 | + :group="group" |
| 9 | + :key="group.key" |
| 10 | + :resource="resource" |
| 11 | + :resourceName="resourceName" |
| 12 | + :resourceId="resourceId" |
| 13 | + :attribute="field.attribute" |
| 14 | + /> |
| 15 | + </div> |
| 16 | + </template> |
| 17 | + </PanelItem> |
18 | 18 | </template>
|
19 | 19 |
|
20 | 20 | <script>
|
21 |
| -import Group from '../group'; |
| 21 | +import Group from "../group"; |
22 | 22 |
|
23 | 23 | export default {
|
| 24 | + props: ["resource", "resourceName", "resourceId", "field"], |
| 25 | + data: () => ({ |
| 26 | + order: [], |
| 27 | + groups: {}, |
| 28 | + }), |
24 | 29 |
|
25 |
| - props: ['resource', 'resourceName', 'resourceId', 'field'], |
26 |
| - data: () => ({ |
27 |
| - order: [], |
28 |
| - groups: {}, |
29 |
| - }), |
30 |
| -
|
31 |
| - computed: { |
32 |
| - layouts() { |
33 |
| - return this.field.layouts || false; |
34 |
| - }, |
35 |
| - orderedGroups() { |
36 |
| - this.value = this.field.value || []; |
| 30 | + computed: { |
| 31 | + layouts() { |
| 32 | + return this.field.layouts || false; |
| 33 | + }, |
| 34 | + orderedGroups() { |
| 35 | + this.value = this.field.value || []; |
37 | 36 |
|
38 |
| - this.populateGroups(); |
| 37 | + this.populateGroups(); |
39 | 38 |
|
40 |
| - return this.order.reduce((groups, key) => { |
41 |
| - groups.push(this.groups[key]); |
42 |
| - return groups; |
43 |
| - }, []); |
44 |
| - }, |
| 39 | + return this.order.reduce((groups, key) => { |
| 40 | + groups.push(this.groups[key]); |
| 41 | + return groups; |
| 42 | + }, []); |
45 | 43 | },
|
| 44 | + }, |
46 | 45 |
|
47 |
| - methods: { |
48 |
| - /* |
49 |
| - * Set the displayed layouts from the field's current value |
50 |
| - */ |
51 |
| - populateGroups() { |
52 |
| - this.order.splice(0, this.order.length); |
53 |
| - this.groups = {}; |
| 46 | + methods: { |
| 47 | + /* |
| 48 | + * Set the displayed layouts from the field's current value |
| 49 | + */ |
| 50 | + populateGroups() { |
| 51 | + this.order.splice(0, this.order.length); |
| 52 | + this.groups = {}; |
54 | 53 |
|
55 |
| - for (var i = 0; i < this.value.length; i++) { |
56 |
| - this.addGroup( |
57 |
| - this.getLayout(this.value[i].layout), |
58 |
| - this.value[i].attributes, |
59 |
| - this.value[i].key, |
60 |
| - this.field.collapsed, |
61 |
| - this.value[i].title_data |
62 |
| - ); |
63 |
| - } |
64 |
| - }, |
| 54 | + for (var i = 0; i < this.value.length; i++) { |
| 55 | + this.addGroup( |
| 56 | + this.getLayout(this.value[i].layout), |
| 57 | + this.value[i].attributes, |
| 58 | + this.value[i].key, |
| 59 | + this.field.collapsed, |
| 60 | + this.value[i].title_data, |
| 61 | + ); |
| 62 | + } |
| 63 | + }, |
65 | 64 |
|
66 |
| - /** |
67 |
| - * Retrieve layout definition from its name |
68 |
| - */ |
69 |
| - getLayout(name) { |
70 |
| - if (!this.layouts) return; |
71 |
| - return this.layouts.find((layout) => layout.name == name); |
72 |
| - }, |
| 65 | + /** |
| 66 | + * Retrieve layout definition from its name |
| 67 | + */ |
| 68 | + getLayout(name) { |
| 69 | + if (!this.layouts) return; |
| 70 | + return this.layouts.find((layout) => layout.name == name); |
| 71 | + }, |
73 | 72 |
|
74 |
| - /** |
75 |
| - * Append the given layout to flexible content's list |
76 |
| - */ |
77 |
| - addGroup(layout, attributes, key, collapsed, resolved_title) { |
78 |
| - if (!layout) return; |
| 73 | + /** |
| 74 | + * Append the given layout to flexible content's list |
| 75 | + */ |
| 76 | + addGroup(layout, attributes, key, collapsed, resolved_title) { |
| 77 | + if (!layout) return; |
79 | 78 |
|
80 |
| - collapsed = collapsed || false; |
| 79 | + collapsed = collapsed || false; |
81 | 80 |
|
82 |
| - let fields = |
83 |
| - attributes || JSON.parse(JSON.stringify(layout.fields)), |
84 |
| - group = new Group( |
85 |
| - layout.name, |
86 |
| - layout.title, |
87 |
| - fields, |
88 |
| - this.field, |
89 |
| - key, |
90 |
| - collapsed, |
91 |
| - layout, |
92 |
| - resolved_title |
93 |
| - ); |
| 81 | + let fields = attributes || JSON.parse(JSON.stringify(layout.fields)), |
| 82 | + group = new Group( |
| 83 | + layout.name, |
| 84 | + layout.title, |
| 85 | + fields, |
| 86 | + this.field, |
| 87 | + key, |
| 88 | + collapsed, |
| 89 | + layout, |
| 90 | + resolved_title, |
| 91 | + ); |
94 | 92 |
|
95 |
| - this.groups[group.key] = group; |
96 |
| - this.order.push(group.key); |
97 |
| - }, |
| 93 | + this.groups[group.key] = group; |
| 94 | + this.order.push(group.key); |
98 | 95 | },
|
| 96 | + }, |
99 | 97 | };
|
100 | 98 | </script>
|
0 commit comments