types.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /*
  2. * <<
  3. * Davinci
  4. * ==
  5. * Copyright (C) 2016 - 2017 EDP
  6. * ==
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * >>
  19. */
  20. import {
  21. ControlTypes,
  22. DatePickerFormats,
  23. ControlFieldTypes,
  24. ControlOptionTypes,
  25. ControlDefaultValueTypes,
  26. ControlVisibilityTypes
  27. } from './constants'
  28. import { OperatorTypes } from 'utils/operatorTypes'
  29. import { IQueryConditions } from 'containers/Dashboard/types'
  30. export interface IControlRelatedItem {
  31. viewId: number
  32. checked: boolean
  33. }
  34. export interface IControlRelatedView {
  35. fieldType: ControlFieldTypes
  36. fields: string[]
  37. }
  38. export interface IControlRelatedViewFormValue {
  39. fieldType: ControlFieldTypes
  40. fields: string | string[]
  41. }
  42. export interface IControlOption {
  43. text: string
  44. value: string
  45. variables?: {
  46. [viewId: string]: string
  47. }
  48. }
  49. export interface IControlCondition {
  50. control: string
  51. operator: OperatorTypes
  52. value: string
  53. }
  54. export interface IControl {
  55. key: string
  56. name: string
  57. type: ControlTypes
  58. operator: OperatorTypes
  59. dateFormat?: DatePickerFormats
  60. multiple?: boolean
  61. radioType?: 'normal' | 'button'
  62. min?: number
  63. max?: number
  64. step?: number
  65. label?: boolean
  66. cache: boolean
  67. expired: number
  68. optionType?: ControlOptionTypes
  69. valueViewId?: number
  70. valueField?: string
  71. textField?: string
  72. parentField?: string
  73. customOptions?: IControlOption[]
  74. optionWithVariable?: boolean
  75. width: number
  76. visibility: ControlVisibilityTypes
  77. conditions?: IControlCondition[]
  78. defaultValueType: ControlDefaultValueTypes
  79. defaultValue?: any
  80. parent?: string
  81. relatedItems?: {
  82. [itemId: string]: IControlRelatedItem
  83. }
  84. relatedViews: {
  85. [viewId: string]: IControlRelatedView
  86. }
  87. }
  88. export interface IRenderTreeItem extends IControl {
  89. children?: IRenderTreeItem[]
  90. }
  91. export type ILocalControlConditions = Pick<
  92. IQueryConditions,
  93. 'tempFilters' | 'variables'
  94. >
  95. export type IGlobalControlConditions = Pick<
  96. IQueryConditions,
  97. 'globalFilters' | 'globalVariables'
  98. >
  99. export interface IGlobalControlConditionsByItem {
  100. [itemId: number]: IGlobalControlConditions
  101. }
  102. export interface IDistinctValueReqeustParams {
  103. columns: string[]
  104. filters?: string[]
  105. variables?: Array<{ name: string; value: string | number }>
  106. cache: boolean
  107. expired: number
  108. }
  109. export type OnGetControlOptions = (
  110. controlKey: string,
  111. userOptions: boolean,
  112. paramsOrOptions:
  113. | { [viewId: string]: IDistinctValueReqeustParams }
  114. | IControlOption[],
  115. itemId?: number
  116. ) => void
  117. export interface IMapControlOptions {
  118. [controlKey: string]: object[]
  119. }
  120. export interface IFilter {
  121. name: string
  122. type: string
  123. value: string[] | string
  124. operator: string
  125. sqlType: string
  126. children?: IFilter
  127. }