-
Notifications
You must be signed in to change notification settings - Fork 659
/
property-options.interface.ts
151 lines (137 loc) · 3.37 KB
/
property-options.interface.ts
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
import { PropertyType } from '../../adapters/property/base-property.js'
/**
* Options passed to a given property
*/
export default interface PropertyOptions {
/**
* if given property should be visible. It can be either boolean for all possible views, or
* you can verify which view in particular should be hidden/shown.
*/
isVisible?: boolean | {
show?: boolean;
list?: boolean;
edit?: boolean;
filter?: boolean;
};
/**
* List of possible overridden components for given property.
*/
components?: {
show?: string;
list?: string;
edit?: string;
filter?: string;
};
/**
* Property type
*/
type?: PropertyType;
/**
* Indicates if property should be treated as an ID
*/
isId?: boolean;
/**
* One of given property should be treated as an "title property". Title property is "clickable"
* when user sees the record in a list or show views.
*
* @deprecated Use ResourceOptions#titleProperty
*/
isTitle?: boolean;
/**
* Indicates if given property should be treated as array of elements.
* @new In version 3.3
*/
isArray?: boolean;
/**
* Indicates if array elements should be draggable when editing.
* It is only usable if the property is an array.
* @new In version 3.5
*/
isDraggable?: boolean;
/**
* position of the field in a list,
* title field (isTitle) gets position -1 by default other
* fields gets position = 100.
*/
position?: number;
/**
* If options should be limited to finite set. After setting this
* in the UI you will see select box instead of the input
*/
availableValues?: Array<{
value: string | number;
label?: string;
}>;
/**
* Custom properties passed to the frontend in {@link PropertyJSON}
*/
custom?: {
[key: string]: any;
};
/**
* Additional props passed to the actual React component rendering given property in Edit
* component.
*
* @new in version 3.3
*/
props?: {
[key: string]: any;
};
/**
* Whether given property should be editable or not.
*/
isDisabled?: boolean;
/**
* Whether given property should be sortable on list or not.
*/
isSortable?: boolean;
/**
* Whether given property should be marked as required.
*/
isRequired?: boolean;
/**
* Whether label should be hidden - false by default
*/
hideLabel?: boolean;
/**
* Name of the resource to which this property should be a reference.
* If set - {@link PropertyOptions.type} always returns `reference`
* @new In version 3.3
*/
reference?: string;
/**
* Description of field. Shown as hoverable hint after label.
*
* To use translations provide it in locale with specified options key from resource
* @example
* ```js
* new AdminJS({
* resources: [
* {
* resource: myResource,
* options: {
* properties: {
* myAwesomeProperty: {
* description: "Plane description" || "awesomeHint", // <- message key in locale
* },
* },
* },
* },
* ],
* locale: {
* translations: {
* resources: {
* myResource: {
* messages: {
* awesomeHint: "Locale description",
* },
* },
* },
* },
* },
* });
* ```
* @new In version 5.6
*/
description?: string;
}