Skip to content

Commit fd2d75d

Browse files
authored
Merge pull request #14 from haoflynet/master
fix field detail style
2 parents c2b6a3a + 3f5a7ce commit fd2d75d

File tree

2 files changed

+44996
-91
lines changed

2 files changed

+44996
-91
lines changed

dist/js/field.js

Lines changed: 44988 additions & 1 deletion
Large diffs are not rendered by default.
Lines changed: 8 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,17 @@
11
<template>
2-
<default-field :field="field" :errors="errors" :show-help-text="false">
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="true"
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-
/>
2+
<panel-item :field="field">
3+
<template slot="value">
4+
<div v-for="(value, index) in field.value" :style="{
5+
'marginTop': index === 0 ? '0' : '6px'
6+
}">
7+
{{ value[field.labelKey] }}
198
</div>
20-
<help-text class="error-text mt-2 text-danger" v-if="hasErrors">
21-
{{ firstError }}
22-
</help-text>
239
</template>
24-
</default-field>
10+
</panel-item>
2511
</template>
2612

2713
<script>
28-
import { FormField, HandlesValidationErrors } from "laravel-nova";
29-
30-
import Treeselect from "@riophae/vue-treeselect";
31-
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
32-
3314
export default {
34-
components: {Treeselect},
35-
mixins: [FormField, HandlesValidationErrors],
36-
37-
props: ['resourceName', 'resourceId', 'field'],
38-
39-
data()
40-
{
41-
return {
42-
selectedValues: null,
43-
};
44-
},
45-
methods: {
46-
normalizer( node )
47-
{
48-
return {
49-
id: node[this.field.idKey],
50-
label: node[this.field.labelKey],
51-
children: node.hasOwnProperty(this.field.childrenKey)
52-
&& node[this.field.childrenKey].length > 0
53-
? node[this.field.childrenKey]
54-
: false
55-
}
56-
},
57-
setInitialValue()
58-
{
59-
let baseUrl = '/nova-vendor/nova-nested-tree-attach-many/';
60-
61-
if( this.resourceId )
62-
{
63-
const url = [
64-
baseUrl + this.resourceName,
65-
this.resourceId,
66-
"attached",
67-
this.field.attribute,
68-
this.field.idKey
69-
];
70-
71-
Nova.request( url.join( "/" ) )
72-
.then( ( data ) =>
73-
{
74-
if(!this.field.multiple)
75-
{
76-
this.selectedValues = data.data || undefined;
77-
}
78-
else
79-
{
80-
this.selectedValues = data.data || [];
81-
}
82-
} );
83-
}
84-
},
85-
fill( formData )
86-
{
87-
formData.append( this.field.attribute, JSON.stringify( this.selectedValues ) )
88-
},
89-
},
90-
computed:{
91-
hasErrors: function() {
92-
return this.errors.errors.hasOwnProperty(this.field.attribute);
93-
},
94-
firstError: function() {
95-
return this.errors.errors[this.field.attribute][0]
96-
},
97-
}
15+
props: ['resourceName', 'resourceId', 'field']
9816
}
9917
</script>

0 commit comments

Comments
 (0)