Source

adminjs/src/backend/decorators/property/property-options.interface.ts

  1. import { PropertyType } from '../../adapters/property/base-property'
  2. /**
  3. * Options passed to a given property
  4. */
  5. export default interface PropertyOptions {
  6. /**
  7. * if given property should be visible. It can be either boolean for all possible views, or
  8. * you can verify which view in particular should be hidden/shown.
  9. */
  10. isVisible?: boolean | {
  11. show?: boolean;
  12. list?: boolean;
  13. edit?: boolean;
  14. filter?: boolean;
  15. };
  16. /**
  17. * List of possible overridden components for given property.
  18. */
  19. components?: {
  20. show?: string;
  21. list?: string;
  22. edit?: string;
  23. filter?: string;
  24. };
  25. /**
  26. * Property type
  27. */
  28. type?: PropertyType;
  29. /**
  30. * Indicates if property should be treated as an ID
  31. */
  32. isId?: boolean;
  33. /**
  34. * One of given property should be treated as an "title property". Title property is "clickable"
  35. * when user sees the record in a list or show views.
  36. */
  37. isTitle?: boolean;
  38. /**
  39. * Indicates if given property should be treated as array of elements.
  40. * @new In version 3.3
  41. */
  42. isArray?: boolean;
  43. /**
  44. * Indicates if array elements should be draggable when editing.
  45. * It is only usable if the property is an array.
  46. * @new In version 3.5
  47. */
  48. isDraggable?: boolean;
  49. /**
  50. * position of the field in a list,
  51. * title field (isTitle) gets position -1 by default other
  52. * fields gets position = 100.
  53. */
  54. position?: number;
  55. /**
  56. * If options should be limited to finite set. After setting this
  57. * in the UI you will see select box instead of the input
  58. */
  59. availableValues?: Array<{
  60. value: string | number;
  61. label: string;
  62. }>;
  63. /**
  64. * Custom properties passed to the frontend in {@link PropertyJSON}
  65. */
  66. custom?: {
  67. [key: string]: any;
  68. };
  69. /**
  70. * Additional props passed to the actual React component rendering given property in Edit
  71. * component.
  72. *
  73. * @new in version 3.3
  74. */
  75. props?: {
  76. [key: string]: any;
  77. };
  78. /**
  79. * Whether given property should be editable or not.
  80. */
  81. isDisabled?: boolean;
  82. /**
  83. * Whether given property should be sortable on list or not.
  84. */
  85. isSortable?: boolean;
  86. /**
  87. * Whether given property should be marked as required.
  88. */
  89. isRequired?: boolean;
  90. /**
  91. * Whether label should be hidden - false by default
  92. */
  93. hideLabel?: boolean;
  94. /**
  95. * Name of the resource to which this property should be a reference.
  96. * If set - {@link PropertyOptions.type} always returns `reference`
  97. * @new In version 3.3
  98. */
  99. reference?: string;
  100. /**
  101. * Description of field. Shown as hoverable hint after label.
  102. *
  103. * To use translations provide it in locale with specified options key from resource
  104. * @example
  105. * ```js
  106. * new AdminJS({
  107. * resources: [
  108. * {
  109. * resource: myResource,
  110. * options: {
  111. * properties: {
  112. * myAwesomeProperty: {
  113. * description: "Plane description" || "awesomeHint", // <- message key in locale
  114. * },
  115. * },
  116. * },
  117. * },
  118. * ],
  119. * locale: {
  120. * translations: {
  121. * resources: {
  122. * myResource: {
  123. * messages: {
  124. * awesomeHint: "Locale description",
  125. * },
  126. * },
  127. * },
  128. * },
  129. * },
  130. * });
  131. * ```
  132. * @new In version 5.6
  133. */
  134. description?: string;
  135. }