-
-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathindex.vue
More file actions
200 lines (183 loc) · 4.4 KB
/
Copy pathindex.vue
File metadata and controls
200 lines (183 loc) · 4.4 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<template>
<k-lab-form>
<k-lab-examples class="k-lab-field-examples">
<k-box theme="notice" icon="alert">
The examples below are rendered from static props. There is no model
behind them, so everything that talks to the field endpoint (search,
pagination, sorting, uploads and batch deletion) answers with a 404 here
and only works in a real model view.
</k-box>
<k-lab-example label="Default">
<k-filelist-field :initial="state(files)" label="Files" />
</k-lab-example>
<k-lab-example label="Help">
<k-filelist-field
:initial="state(files)"
help="Every file of this page"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Empty">
<k-filelist-field
:initial="state([], { pagination: empty })"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Empty with custom text">
<k-filelist-field
:initial="state([], { pagination: empty })"
empty="No images have been added yet"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Invalid: fewer than min">
<k-filelist-field
:initial="state(files.slice(0, 1), { pagination: single })"
:min="2"
help="The label marks the field as invalid until a second file is added"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Layout: cardlets">
<k-filelist-field
:initial="state(files)"
label="Files"
layout="cardlets"
/>
</k-lab-example>
<k-lab-example label="Layout: cards">
<k-filelist-field
:initial="state(files)"
label="Files"
layout="cards"
/>
</k-lab-example>
<k-lab-example label="Layout: cards, size small">
<k-filelist-field
:initial="state(files)"
label="Files"
layout="cards"
size="small"
/>
</k-lab-example>
<k-lab-example label="Layout: table">
<k-filelist-field
:initial="state(tableRows, { columns })"
label="Files"
layout="table"
/>
</k-lab-example>
<k-lab-example label="Layout: table with columns">
<k-filelist-field
:initial="state(tableRows, { columns: customColumns })"
label="Files"
layout="table"
/>
</k-lab-example>
<k-lab-example label="Link to another parent">
<k-filelist-field
:initial="state(files)"
label="Files"
link="/pages/photography"
/>
</k-lab-example>
<k-lab-example label="Pagination">
<k-filelist-field
:endpoints="endpoints"
:initial="state(files.slice(0, 3), { pagination: paginated })"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Search">
<k-filelist-field
:endpoints="endpoints"
:initial="state(files)"
:searchable="true"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Batch">
<k-filelist-field
:batch="true"
:endpoints="endpoints"
:initial="state(files)"
label="Files"
/>
</k-lab-example>
<k-lab-example label="Upload">
<k-filelist-field
:endpoints="endpoints"
:initial="state(files, { upload })"
label="Files"
/>
</k-lab-example>
<k-lab-example label="All options">
<k-filelist-field
:batch="true"
:endpoints="endpoints"
:initial="
state(files.slice(0, 3), {
pagination: paginated,
sortable: true,
upload
})
"
:searchable="true"
help="Search, batch select, sorting and uploads at once"
label="Files"
/>
</k-lab-example>
</k-lab-examples>
</k-lab-form>
</template>
<script>
export default {
props: {
columns: Object,
customColumns: Object,
endpoints: Object,
files: Array,
paginated: Object,
pagination: Object,
upload: Object
},
computed: {
empty() {
return { limit: 20, offset: 0, page: 1, total: 0 };
},
single() {
return { limit: 20, offset: 0, page: 1, total: 1 };
},
/**
* `ModelListField::columnsValues()` adds the cell values
* for the table layout to every entry
*/
tableRows() {
return this.files.map((file) => ({
...file,
alt: "Alt text for " + file.text,
title: {
text: file.text,
href: file.link
}
}));
}
},
methods: {
/**
* `FileListField::state()` sends the entries together with
* the columns, pagination, sorting and upload settings
*/
state(models, state = {}) {
return {
columns: {},
models,
pagination: this.pagination,
sortable: false,
upload: false,
...state
};
}
}
};
</script>