1
1
<template >
2
- <default-field :field =" field" :errors =" errors" :show-help-text =" false" >
2
+ <default-field :field =" field" :errors =" errors" :show-help-text =" false" class = " categories-tree " >
3
3
<template slot="field">
4
- <div :dir =" field.rtl ? 'rtl' : 'ltr'" class =" p-2 nova-tree-attach-many" >
5
- <treeselect v-model =" selectedValues"
6
- :id =" field.name"
7
- :multiple =" field.multiple"
8
- :options =" field.options"
9
- :flat =" field.flatten"
10
- :searchable =" field.searchable"
11
- :always-open =" field.alwaysOpen"
12
- :disabled =" field.disabled"
13
- :sort-value-by =" field.sortValueBy"
14
- :placeholder =" field.placeholder"
15
- :max-height =" field.maxHeight"
16
- :value-consists-of =" field.valueConsistsOf"
17
- :normalizer =" normalizer"
18
- />
4
+ <div class =" flex" >
5
+ <div :dir =" field.rtl ? 'rtl' : 'ltr'" class =" w-3/5 nova-tree-attach-many" >
6
+ <treeselect v-model =" selectedValues"
7
+ :id =" field.name"
8
+ :multiple =" field.multiple"
9
+ :options =" field.options"
10
+ :flat =" field.flatten"
11
+ :searchable =" field.searchable"
12
+ :always-open =" field.alwaysOpen"
13
+ :disabled =" field.disabled"
14
+ :sort-value-by =" field.sortValueBy"
15
+ :placeholder =" field.placeholder"
16
+ :max-height =" field.maxHeight"
17
+ :value-consists-of =" field.valueConsistsOf"
18
+ :normalizer =" normalizer"
19
+ />
20
+ </div >
21
+ <div class =" w-2/5 pl-8 pt-2" v-if =" field.displayPath && fullUrl" >
22
+ <ul class =" category-list pl-6" >
23
+ <li class =" py-1 text-80 text-sm capitalize" v-for =" (url,index) in fullUrl" :key =" index" ><strong >{{ index }}</strong > {{ url }}</li >
24
+ </ul >
25
+ </div >
19
26
</div >
20
27
</template >
21
28
</default-field >
22
29
</template >
23
30
31
+ <style type="text/css">
32
+ .categories-tree .py-6.px-8.w-1\/ 2 { width : 80% ; }
33
+ .category-list { list-style : none ;}
34
+ </style >
35
+
24
36
<script >
25
37
import {FormField , HandlesValidationErrors } from ' laravel-nova'
26
38
@@ -37,9 +49,28 @@ export default {
37
49
{
38
50
return {
39
51
selectedValues: null ,
52
+ fullUrl: null ,
40
53
};
41
54
},
55
+ watch: {
56
+ selectedValues : function (val ) {
57
+ // do something when the data changes.
58
+ if (val) {
59
+ this .getCategoryFullPath (val);
60
+ }
61
+ }
62
+ },
42
63
methods: {
64
+ getCategoryFullPath (val ){
65
+ Nova .request ().get (' /nova-vendor/nova-nested-tree-attach-many/get-category-full-path' ,{
66
+ params: {
67
+ categories: val || this .selectedValues ,
68
+ }
69
+ })
70
+ .then ( ( data ) => {
71
+ this .fullUrl = data .data ;
72
+ } );
73
+ },
43
74
normalizer ( node )
44
75
{
45
76
return {
@@ -79,6 +110,9 @@ export default {
79
110
{
80
111
this .selectedValues = data .data || [];
81
112
}
113
+ if (this .selectedValues .length > 0 ){
114
+ this .getCategoryFullPath (this .selectedValues );
115
+ }
82
116
} );
83
117
}
84
118
else
0 commit comments