forked from Cambalab/vue-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShowMagazines.vue
89 lines (87 loc) · 2.43 KB
/
ShowMagazines.vue
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<template>
<v-layout>
<v-flex xs12 sm6 offset-sm3>
<v-card>
<v-img src="banner.png" aspect-ratio="4" />
<v-card-title primary-title>
<h3 class="headline mb-2">Magazine</h3>
</v-card-title>
<div>
<v-form v-if="entity">
<v-container>
<v-layout column>
<v-flex xs12>
<v-text-field
:name="names.containerField('name')"
v-model="entity.name"
disabled
label="Name"
/>
<v-text-field
:name="names.containerField('issue')"
v-model="entity.issue"
disabled
label="Issue"
/>
<v-text-field
:name="names.containerField('publisher')"
v-model="entity.publisher"
disabled
label="Publisher"
/>
</v-flex>
</v-layout>
</v-container>
</v-form>
</div>
</v-card>
</v-flex>
</v-layout>
</template>
<script>
/**
* This is a custom component for creating magazines using a form, with a name,
* issue number and a publisher.
* When passed through the Resource, this custom component is automatically
* 'injected' with a 'va' prop used to create magazine entities.
* This prop contains getter and setter functions that must be used by your UI
* components, such as buttons, inputs, etc.
*/
// This is only used for e2e demo tests
import UI_NAMES from '@constants/ui.element.names'
export default {
name: 'ShowMagazines',
props: {
// This prop will be assigned by Vue Admin for you to use the functions
// shown below.
va: {
type: Object,
required: true,
},
},
data() {
// This is only needed for e2e demo tests
const resourceName = 'magazines'
const view = 'show'
const names = {
containerField: field =>
UI_NAMES.RESOURCE_VIEW_ELEMENT_FIELD.with({
resourceName,
view,
field,
}),
}
return { names }
},
created() {
// With fetchEntity you can have your 'resourceName' entity initialised.
this.va.fetchEntity()
},
computed: {
entity() {
// getEntity gets initialised data from the store
return this.va.getEntity()
},
},
}
</script>