2
2
<div class =" relative mb-4 pb-1" :id =" group.key" >
3
3
<div class =" w-full shrink" >
4
4
<div :class =" titleStyle" v-if =" group.title" >
5
- <div class =" h-8 leading-normal h-full flex items-center box-content"
5
+ <div class =" h-8 leading-normal flex items-center box-content"
6
6
:class =" {'border-b border-gray-200 dark:border-gray-700 ': !collapsed}" >
7
- <button
8
- dusk =" expand-group"
9
- type =" button"
10
- class =" shrink-0 group-control btn border-r border-gray-200 dark:border-gray-700 w-8 h-8 block"
11
- :title =" __('Expand')"
12
- @click.prevent =" expand"
13
- v-if =" collapsed" >
14
- <icon type =" plus" class =" align-top" width =" 16" height =" 16" />
15
- </button >
16
- <button
17
- dusk =" collapse-group"
18
- type =" button"
19
- class =" group-control btn border-r border-gray-200 dark:border-gray-700 w-8 h-8 block"
20
- :title =" __('Collapse')"
21
- @click.prevent =" collapse"
22
- v-else >
23
- <icon type =" minus" class =" align-top" width =" 16" height =" 16" />
24
- </button >
25
-
26
- <p class =" text-80 grow px-4" >
27
- <span class =" mr-3 font-semibold" >#{{ index + 1 }}</span >
28
- {{ group.title }}
29
- </p >
30
-
31
- <div class =" flex" v-if =" !readonly" >
32
- <button
7
+ <button
33
8
dusk =" drag-group"
34
9
type =" button"
35
10
class =" group-control btn border-l border-gray-200 dark:border-gray-700 w-8 h-8 block nova-flexible-content-drag-button"
36
11
:title =" __('Drag')"
37
12
>
38
- <icon type =" selector" class =" align-top" width =" 16" height =" 16" />
39
- </button >
40
- <button
41
- dusk =" move-up-group"
42
- type =" button"
43
- class =" group-control btn border-l border-gray-200 dark:border-gray-700 w-8 h-8 block"
44
- :title =" __('Move up')"
45
- @click.prevent =" moveUp" >
46
- <icon type =" arrow-up" class =" align-top" width =" 16" height =" 16" />
47
- </button >
48
- <button
49
- dusk =" move-down-group"
50
- type =" button"
51
- class =" group-control btn border-l border-gray-200 dark:border-gray-700 w-8 h-8 block"
52
- :title =" __('Move down')"
53
- @click.prevent =" moveDown" >
54
- <icon type =" arrow-down" class =" align-top" width =" 16" height =" 16" />
13
+ <svg xmlns =" http://www.w3.org/2000/svg" fill =" none" viewBox =" 0 0 24 24" stroke-width =" 1.5" stroke =" currentColor" class =" h-4 w-4 mx-2" >
14
+ <path stroke-linecap =" round" stroke-linejoin =" round" d =" M3.75 9h16.5m-16.5 6.75h16.5" />
15
+ </svg >
16
+
55
17
</button >
18
+
19
+ <button @click.prevent =" collapsed? expand() : collapse()" class =" text-left text-80 grow" >
20
+ <span class =" mr-3 font-semibold" >#{{ index + 1 }}</span >
21
+ {{ group.title }}<span v-if =" collapsedPreview" >: <span class =" mr-3 font-semibold" >{{ truncate(collapsedPreview, 30) }}</span ></span >
22
+ </button >
23
+
24
+ <div class =" flex" v-if =" !readonly" >
25
+
26
+
56
27
<button
57
28
dusk =" delete-group"
58
29
type =" button"
73
44
74
45
</div >
75
46
</div >
76
- <div :class =" containerStyle" >
77
- <component
78
- v-for =" (item, index) in group.fields"
79
- :key =" index"
80
- :is =" 'form-' + item.component"
81
- :resource-name =" resourceName"
82
- :resource-id =" resourceId"
83
- :field =" item"
84
- :errors =" errors"
85
- :mode =" mode"
86
- :show-help-text =" item.helpText != null"
87
- :class =" { 'remove-bottom-border': index == group.fields.length - 1 }"
88
- />
89
- </div >
90
- </div >
47
+
48
+ <transition v-if =" field.drawer"
49
+ enter-active-class =" transition duration-200 ease-out"
50
+ enter-from-class =" opacity-0"
51
+ enter-to-class =" opacity-100"
52
+ leave-active-class =" transition duration-200 ease-in"
53
+ leave-from-class =" opacity-100"
54
+ leave-to-class =" opacity-0"
55
+ >
56
+ <div v-show =" !collapsed"
57
+ @click =" collapse"
58
+ class =" fixed z-20 inset-0 bg-gray-600/75 dark:bg-gray-900/75"
59
+ ></div >
60
+
61
+ </transition >
62
+
63
+ <div
64
+ :class =" {
65
+ 'translate-x-full opacity-0': collapsed && field.drawer,
66
+ 'fixed flex flex-col z-20 top-0 transition duration-200 ease-in right-0 h-screen divide-y divide-gray-200 dark:divide-gray-700 shadow bg-white dark:bg-gray-800 w-screen max-w-4xl ml-auto border-b border-gray-200 dark:border-gray-700 overflow-x-hidden overflow-y-scroll' : field.drawer,
67
+ 'grow border-b border-r border-l border-gray-200 dark:border-gray-700 rounded-b-lg' : !field.drawer,
68
+ 'hidden': collapsed && !field.drawer }"
69
+
70
+ >
71
+ <div v-if =" field.drawer" class =" -mb-px border-b border-gray-200 z-20 bg-primary-50 sticky top-0 py-5 px-6 md:px-8 flex justify-between" >Edit {{ group.title }} <button class =" ml-auto inline-block" @click.prevent =" collapse" >CLOSE</button ></div >
72
+ <component
73
+ v-for =" (item, index) in group.fields"
74
+ :key =" index"
75
+ :is =" 'form-' + item.component"
76
+ :resource-name =" resourceName"
77
+ :resource-id =" resourceId"
78
+ :field =" item"
79
+ :errors =" errors"
80
+ :mode =" mode"
81
+ :show-help-text =" item.helpText != null"
82
+ @change =" handleFieldChanged($event, item)"
83
+ :class =" { 'remove-bottom-border': index == group.fields.length - 1 }"
84
+ />
85
+ </div >
86
+
87
+
88
+ <!-- </transition> -->
89
+ </div >
91
90
</div >
92
91
</template >
93
92
@@ -113,10 +112,14 @@ export default {
113
112
removeMessage: false ,
114
113
collapsed: this .group .collapsed ,
115
114
readonly: this .group .readonly ,
115
+ collapsedPreview: null ,
116
116
};
117
117
},
118
118
119
119
computed: {
120
+ collapsedPreviewAttribute () {
121
+ return this .field .layouts .find (layout => layout .name === this .group .name )? .collapsedPreviewAttribute ;
122
+ },
120
123
titleStyle () {
121
124
let classes = [' border-t' , ' border-r' , ' border-l' , ' border-gray-200' , ' dark:border-gray-700' , ' rounded-t-lg' ];
122
125
@@ -142,6 +145,19 @@ export default {
142
145
}
143
146
},
144
147
148
+ mounted () {
149
+ // Object.values(this.group.fields).forEach(field => {
150
+ // if (this.collapsedPreviewAttribute && this.getFieldAttribute(field) === this.collapsedPreviewAttribute) {
151
+ // this.collapsedPreview = field.value;
152
+ // }
153
+ // });
154
+
155
+ this .collapsedPreview = Object .values (this .group .fields ).find (field => {
156
+ return this .getFieldAttribute (field) === this .collapsedPreviewAttribute ;
157
+ })? .value ;
158
+
159
+ },
160
+
145
161
methods: {
146
162
/**
147
163
* Move this group up
@@ -150,6 +166,24 @@ export default {
150
166
this .$emit (' move-up' );
151
167
},
152
168
169
+ getFieldAttribute (item ) {
170
+ return item .attribute .split (' __' ).pop ();
171
+ },
172
+
173
+ truncate (value , length ) {
174
+ if (value .length > length) {
175
+ return value .substring (0 , length) + " ..." ;
176
+ } else {
177
+ return value;
178
+ }
179
+ },
180
+
181
+ handleFieldChanged (event , item ) {
182
+ if (this .getFieldAttribute (item) === this .collapsedPreviewAttribute ) {
183
+ this .collapsedPreview = event .target .value ;
184
+ }
185
+ },
186
+
153
187
/**
154
188
* Move this group down
155
189
*/
0 commit comments